diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-08-06 16:58:02 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-08-07 09:36:05 +0000 |
| commit | 4a714d91c637245fad1462f970c27c43b80b50a4 (patch) | |
| tree | 2fef21bf216467d2fa1a4aa5e2293e55f9f9f37e /pkg/corpus | |
| parent | 9f48730151b9672237f493192dae562dca04dbdd (diff) | |
pkg/corpus: prefer smaller programs during minimization
Occasionally, deflake() and minimize() fail and we end up with huge
programs in the syzkaller corpus. Huge programs in the corpus, in turn,
lead to slower corpus triage and slower exec/sec overall, since many of
the executed programs are based on the ones from the corpus.
A slightly bigger corpus with on average shorter and more focused
programs sounds like a more desirable outcome.
Give preference to smaller programs during minimization. It should
hopefully improve the situation over time.
Diffstat (limited to 'pkg/corpus')
| -rw-r--r-- | pkg/corpus/minimize.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pkg/corpus/minimize.go b/pkg/corpus/minimize.go index b23f9f29e..8eac96122 100644 --- a/pkg/corpus/minimize.go +++ b/pkg/corpus/minimize.go @@ -25,10 +25,16 @@ func (corpus *Corpus) Minimize(cover bool) { // This gives some intentional non-determinism during minimization. // However, we want to give preference to non-squashed inputs, // so let's sort by this criteria. + // We also want to give preference to smaller corpus programs: + // - they are faster to execute, + // - minimization occasionally fails, so we need to clean it up over time. sort.SliceStable(inputs, func(i, j int) bool { - firstAny := inputs[i].Context.(*Item).HasAny - secondAny := inputs[j].Context.(*Item).HasAny - return !firstAny && secondAny + first := inputs[i].Context.(*Item) + second := inputs[j].Context.(*Item) + if first.HasAny != second.HasAny { + return !first.HasAny + } + return len(first.Prog.Calls) < len(second.Prog.Calls) }) corpus.progs = make(map[string]*Item) |
