aboutsummaryrefslogtreecommitdiffstats
path: root/syz-manager/hub.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-03-29 15:02:10 +0100
committerDmitry Vyukov <dvyukov@google.com>2024-04-09 07:55:50 +0000
commit1be1a06281dccada078a2a51e8b483811af8f596 (patch)
tree6340df1c2d1704f1784ba63164d3088b7c91ef61 /syz-manager/hub.go
parent73f4b622a34ffc998a542f5e109fb05a1d892272 (diff)
all: refactor stats
Add ability for each package to create and export own stats. Each stat is self-contained, describes how it should be presented, and there is not need to copy them from one package to another. Stats also keep historical data and allow building graphs over time.
Diffstat (limited to 'syz-manager/hub.go')
-rw-r--r--syz-manager/hub.go33
1 files changed, 24 insertions, 9 deletions
diff --git a/syz-manager/hub.go b/syz-manager/hub.go
index 04904664d..405ab3075 100644
--- a/syz-manager/hub.go
+++ b/syz-manager/hub.go
@@ -17,6 +17,7 @@ import (
"github.com/google/syzkaller/pkg/report"
"github.com/google/syzkaller/pkg/report/crash"
"github.com/google/syzkaller/pkg/rpctype"
+ "github.com/google/syzkaller/pkg/stats"
"github.com/google/syzkaller/prog"
)
@@ -41,13 +42,20 @@ func (mgr *Manager) hubSyncLoop(keyGet keyGetter) {
mgr: mgr,
cfg: mgr.cfg,
target: mgr.target,
- stats: mgr.stats,
domain: mgr.cfg.TargetOS + "/" + mgr.cfg.HubDomain,
enabledCalls: mgr.targetEnabledSyscalls,
leak: mgr.checkResult.Features[host.FeatureLeak].Enabled,
fresh: mgr.fresh,
hubReproQueue: mgr.externalReproQueue,
keyGet: keyGet,
+
+ statSendProgAdd: stats.Create("hub send prog add", "", stats.Graph("hub progs")),
+ statSendProgDel: stats.Create("hub send prog del", "", stats.Graph("hub progs")),
+ statRecvProg: stats.Create("hub recv prog", "", stats.Graph("hub progs")),
+ statRecvProgDrop: stats.Create("hub recv prog drop", "", stats.NoGraph),
+ statSendRepro: stats.Create("hub send repro", "", stats.Graph("hub repros")),
+ statRecvRepro: stats.Create("hub recv repro", "", stats.Graph("hub repros")),
+ statRecvReproDrop: stats.Create("hub recv repro drop", "", stats.NoGraph),
}
if mgr.cfg.Reproduce && mgr.dash != nil {
hc.needMoreRepros = mgr.needMoreRepros
@@ -59,7 +67,6 @@ type HubConnector struct {
mgr HubManagerView
cfg *mgrconfig.Config
target *prog.Target
- stats *Stats
domain string
enabledCalls map[*prog.Syscall]bool
leak bool
@@ -69,6 +76,14 @@ type HubConnector struct {
hubReproQueue chan *Crash
needMoreRepros chan chan bool
keyGet keyGetter
+
+ statSendProgAdd *stats.Val
+ statSendProgDel *stats.Val
+ statRecvProg *stats.Val
+ statRecvProgDrop *stats.Val
+ statSendRepro *stats.Val
+ statRecvRepro *stats.Val
+ statRecvReproDrop *stats.Val
}
// HubManagerView restricts interface between HubConnector and Manager.
@@ -196,13 +211,13 @@ func (hc *HubConnector) sync(hub *rpctype.RPCClient, corpus [][]byte) error {
}
minimized, smashed, progDropped := hc.processProgs(r.Inputs)
reproDropped := hc.processRepros(r.Repros)
- hc.stats.hubSendProgAdd.add(len(a.Add))
- hc.stats.hubSendProgDel.add(len(a.Del))
- hc.stats.hubSendRepro.add(len(a.Repros))
- hc.stats.hubRecvProg.add(len(r.Inputs) - progDropped)
- hc.stats.hubRecvProgDrop.add(progDropped)
- hc.stats.hubRecvRepro.add(len(r.Repros) - reproDropped)
- hc.stats.hubRecvReproDrop.add(reproDropped)
+ hc.statSendProgAdd.Add(len(a.Add))
+ hc.statSendProgDel.Add(len(a.Del))
+ hc.statSendRepro.Add(len(a.Repros))
+ hc.statRecvProg.Add(len(r.Inputs) - progDropped)
+ hc.statRecvProgDrop.Add(progDropped)
+ hc.statRecvRepro.Add(len(r.Repros) - reproDropped)
+ hc.statRecvReproDrop.Add(reproDropped)
log.Logf(0, "hub sync: send: add %v, del %v, repros %v;"+
" recv: progs %v (min %v, smash %v), repros %v; more %v",
len(a.Add), len(a.Del), len(a.Repros),