diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-03 17:36:57 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-10 10:37:15 +0000 |
| commit | a7a1cea58a31ffafc3d6473559349a52d46c33a0 (patch) | |
| tree | cdd3659d849768ad36fde93302c138271f8a0170 /pkg/corpus | |
| parent | 40f782db483d97f4dcc09fa7df468dd8d64d9b62 (diff) | |
pkg/corpus: don't keep serialized programs in memory
We only need serialized representation on some rare operations
(some web UI pages, and first hub connect). Don't keep them in memory.
In my instance this saves 503MB (15.5%) of heap,
which reduces RSS by 1GB (2x due to GC).
Diffstat (limited to 'pkg/corpus')
| -rw-r--r-- | pkg/corpus/corpus.go | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/pkg/corpus/corpus.go b/pkg/corpus/corpus.go index 5b2b9983f..4ad4f6f27 100644 --- a/pkg/corpus/corpus.go +++ b/pkg/corpus/corpus.go @@ -60,14 +60,13 @@ type ItemUpdate struct { // too hard to synchonize accesses to them across the whole project. // When Corpus updates one of its items, it saves a copy of it. type Item struct { - Sig string - Call int - Prog *prog.Prog - ProgData []byte // to save some Serialize() calls - HasAny bool // whether the prog contains squashed arguments - Signal signal.Signal - Cover []uint64 - Updates []ItemUpdate + Sig string + Call int + Prog *prog.Prog + HasAny bool // whether the prog contains squashed arguments + Signal signal.Signal + Cover []uint64 + Updates []ItemUpdate } func (item Item) StringCall() string { @@ -109,14 +108,13 @@ func (corpus *Corpus) Save(inp NewInput) { newCover.Merge(old.Cover) newCover.Merge(inp.Cover) newItem := &Item{ - Sig: sig, - Prog: old.Prog, - ProgData: progData, - Call: old.Call, - HasAny: old.HasAny, - Signal: newSignal, - Cover: newCover.Serialize(), - Updates: append([]ItemUpdate{}, old.Updates...), + Sig: sig, + Prog: old.Prog, + Call: old.Call, + HasAny: old.HasAny, + Signal: newSignal, + Cover: newCover.Serialize(), + Updates: append([]ItemUpdate{}, old.Updates...), } const maxUpdates = 32 if len(newItem.Updates) < maxUpdates { @@ -125,14 +123,13 @@ func (corpus *Corpus) Save(inp NewInput) { corpus.progs[sig] = newItem } else { corpus.progs[sig] = &Item{ - Sig: sig, - Call: inp.Call, - Prog: inp.Prog, - ProgData: progData, - HasAny: inp.Prog.ContainsAny(), - Signal: inp.Signal, - Cover: inp.Cover, - Updates: []ItemUpdate{update}, + Sig: sig, + Call: inp.Call, + Prog: inp.Prog, + HasAny: inp.Prog.ContainsAny(), + Signal: inp.Signal, + Cover: inp.Cover, + Updates: []ItemUpdate{update}, } corpus.saveProgram(inp.Prog, inp.Signal) } |
