github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/fuzzer/stats.go (about)

     1  // Copyright 2024 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package fuzzer
     5  
     6  import (
     7  	"sync/atomic"
     8  
     9  	"github.com/google/syzkaller/pkg/stat"
    10  	"github.com/google/syzkaller/prog"
    11  )
    12  
    13  type Stats struct {
    14  	// Indexed by prog.Syscall.ID + the last element for extra/remote.
    15  	Syscalls []SyscallStats
    16  
    17  	statCandidates          *stat.Val
    18  	statNewInputs           *stat.Val
    19  	statJobs                *stat.Val
    20  	statJobsTriage          *stat.Val
    21  	statJobsTriageCandidate *stat.Val
    22  	statJobsSmash           *stat.Val
    23  	statJobsFaultInjection  *stat.Val
    24  	statJobsHints           *stat.Val
    25  	statExecTime            *stat.Val
    26  	statExecGenerate        *stat.Val
    27  	statExecFuzz            *stat.Val
    28  	statExecCandidate       *stat.Val
    29  	statExecTriage          *stat.Val
    30  	statExecMinimize        *stat.Val
    31  	statExecSmash           *stat.Val
    32  	statExecFaultInject     *stat.Val
    33  	statExecHint            *stat.Val
    34  	statExecSeed            *stat.Val
    35  	statExecCollide         *stat.Val
    36  	statCoverOverflows      *stat.Val
    37  	statCompsOverflows      *stat.Val
    38  }
    39  
    40  type SyscallStats struct {
    41  	// Number of times coverage buffer for this syscall has overflowed.
    42  	CoverOverflows atomic.Uint64
    43  	// Number of times comparisons buffer for this syscall has overflowed.
    44  	CompsOverflows atomic.Uint64
    45  }
    46  
    47  func newStats(target *prog.Target) Stats {
    48  	return Stats{
    49  		Syscalls: make([]SyscallStats, len(target.Syscalls)+1),
    50  		statCandidates: stat.New("candidates", "Number of candidate programs in triage queue",
    51  			stat.Console, stat.Graph("corpus")),
    52  		statNewInputs: stat.New("new inputs", "Potential untriaged corpus candidates",
    53  			stat.Graph("corpus")),
    54  		statJobs: stat.New("fuzzer jobs", "Total running fuzzer jobs", stat.NoGraph),
    55  		statJobsTriage: stat.New("triage jobs", "Running triage jobs", stat.StackedGraph("jobs"),
    56  			stat.Link("/jobs?type=triage")),
    57  		statJobsTriageCandidate: stat.New("candidate triage jobs", "Running candidate triage jobs",
    58  			stat.StackedGraph("jobs"), stat.Link("/jobs?type=triage")),
    59  		statJobsSmash: stat.New("smash jobs", "Running smash jobs", stat.StackedGraph("jobs"),
    60  			stat.Link("/jobs?type=smash")),
    61  		statJobsFaultInjection: stat.New("fault jobs", "Running fault injection jobs", stat.StackedGraph("jobs")),
    62  		statJobsHints: stat.New("hints jobs", "Running hints jobs", stat.StackedGraph("jobs"),
    63  			stat.Link("/jobs?type=hints")),
    64  		statExecTime: stat.New("prog exec time", "Test program execution time (ms)", stat.Distribution{}),
    65  		statExecGenerate: stat.New("exec gen", "Executions of generated programs", stat.Rate{},
    66  			stat.StackedGraph("exec")),
    67  		statExecFuzz: stat.New("exec fuzz", "Executions of mutated programs",
    68  			stat.Rate{}, stat.StackedGraph("exec")),
    69  		statExecCandidate: stat.New("exec candidate", "Executions of candidate programs",
    70  			stat.Rate{}, stat.StackedGraph("exec")),
    71  		statExecTriage: stat.New("exec triage", "Executions of corpus triage programs",
    72  			stat.Rate{}, stat.StackedGraph("exec")),
    73  		statExecMinimize: stat.New("exec minimize", "Executions of programs during minimization",
    74  			stat.Rate{}, stat.StackedGraph("exec")),
    75  		statExecSmash: stat.New("exec smash", "Executions of smashed programs",
    76  			stat.Rate{}, stat.StackedGraph("exec")),
    77  		statExecFaultInject: stat.New("exec inject", "Executions of fault injection",
    78  			stat.Rate{}, stat.StackedGraph("exec")),
    79  		statExecHint: stat.New("exec hints", "Executions of programs generated using hints",
    80  			stat.Rate{}, stat.StackedGraph("exec")),
    81  		statExecSeed: stat.New("exec seeds", "Executions of programs for hints extraction",
    82  			stat.Rate{}, stat.StackedGraph("exec")),
    83  		statExecCollide: stat.New("exec collide", "Executions of programs in collide mode",
    84  			stat.Rate{}, stat.StackedGraph("exec")),
    85  		statCoverOverflows: stat.New("cover overflows", "Number of times the coverage buffer overflowed",
    86  			stat.Rate{}, stat.NoGraph),
    87  		statCompsOverflows: stat.New("comps overflows", "Number of times the comparisons buffer overflowed",
    88  			stat.Rate{}, stat.NoGraph),
    89  	}
    90  }