diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-02 12:24:19 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-02 13:05:24 +0000 |
| commit | aed5b33a040a2b82edb7ec053cf61930a2648a44 (patch) | |
| tree | 0af3578ea1e093cb4dbf9a9cdd79c65a34d22225 | |
| parent | fb6fb6ed7e5734bffbff0af8d67a177ee7640f39 (diff) | |
syz-manager: preload corpus asynchronously
With load of inputs and slow disk preloading can take
tens of seconds. During that time we don't even serve
web interface, and don't start VMs.
Preload it asynchronously, we need it much later.
| -rw-r--r-- | syz-manager/manager.go | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 87e459270..3f7cb1254 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -48,28 +48,29 @@ var ( ) type Manager struct { - cfg *mgrconfig.Config - vmPool *vm.Pool - target *prog.Target - sysTarget *targets.Target - reporter *report.Reporter - crashdir string - serv *RPCServer - corpus *corpus.Corpus - corpusDB *db.DB - corpusDBMu sync.Mutex // for concurrent operations on corpusDB - startTime time.Time - firstConnect time.Time - fuzzingTime time.Duration - stats *Stats - crashTypes map[string]bool - vmStop chan bool - checkResult *rpctype.CheckArgs - fresh bool - expertMode bool - numFuzzing uint32 - numReproducing uint32 - nextInstanceID atomic.Uint64 + cfg *mgrconfig.Config + vmPool *vm.Pool + target *prog.Target + sysTarget *targets.Target + reporter *report.Reporter + crashdir string + serv *RPCServer + corpus *corpus.Corpus + corpusDB *db.DB + corpusDBMu sync.Mutex // for concurrent operations on corpusDB + corpusPreloaded chan bool + startTime time.Time + firstConnect time.Time + fuzzingTime time.Duration + stats *Stats + crashTypes map[string]bool + vmStop chan bool + checkResult *rpctype.CheckArgs + fresh bool + expertMode bool + numFuzzing uint32 + numReproducing uint32 + nextInstanceID atomic.Uint64 dash *dashapi.Dashboard @@ -171,6 +172,7 @@ func RunManager(cfg *mgrconfig.Config) { cfg: cfg, vmPool: vmPool, corpus: corpus.NewMonitoredCorpus(context.Background(), corpusUpdates), + corpusPreloaded: make(chan bool), target: cfg.Target, sysTarget: cfg.SysTarget, reporter: reporter, @@ -190,7 +192,7 @@ func RunManager(cfg *mgrconfig.Config) { saturatedCalls: make(map[string]bool), } - mgr.preloadCorpus() + go mgr.preloadCorpus() mgr.initStats() // Initializes prometheus variables. mgr.initHTTP() // Creates HTTP server. mgr.collectUsedFiles() @@ -587,7 +589,6 @@ func (pool *ResourcePool) TakeOne() *int { } func (mgr *Manager) preloadCorpus() { - log.Logf(0, "loading corpus...") corpusDB, err := db.Open(filepath.Join(mgr.cfg.Workdir, "corpus.db"), true) if err != nil { if corpusDB == nil { @@ -610,9 +611,11 @@ func (mgr *Manager) preloadCorpus() { mgr.seeds = append(mgr.seeds, data) } } + close(mgr.corpusPreloaded) } func (mgr *Manager) loadCorpus() { + <-mgr.corpusPreloaded // By default we don't re-minimize/re-smash programs from corpus, // it takes lots of time on start and is unnecessary. // However, on version bumps we can selectively re-minimize/re-smash. |
