aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-07-26 11:42:15 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-07-26 13:48:19 +0000
commit46eb10b79c61c4032281212d862c913683ab32a0 (patch)
tree5e1ca2335b0c18301ff9e2d97d44cd4403c849fb /vm
parent7e805b6a42655e3b327f820cd56f88b99ab4db2a (diff)
vm/dispatcher: move boot duration calculation to vm
This should be calculated in dispatcher.Pool that actually does boot VMs.
Diffstat (limited to 'vm')
-rw-r--r--vm/dispatcher/pool.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/vm/dispatcher/pool.go b/vm/dispatcher/pool.go
index 5135a231d..7ad934cfb 100644
--- a/vm/dispatcher/pool.go
+++ b/vm/dispatcher/pool.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/google/syzkaller/pkg/log"
+ "github.com/google/syzkaller/pkg/stat"
)
type Instance interface {
@@ -26,6 +27,7 @@ type CreateInstance[T Instance] func(int) (T, error)
// dynamically controlled sub-pool might be reserved for the arbitrary Runners.
type Pool[T Instance] struct {
BootErrors chan error
+ BootTime stat.AverageValue[time.Duration]
creator CreateInstance[T]
defaultJob Runner[T]
@@ -80,6 +82,7 @@ func (p *Pool[T]) runInstance(ctx context.Context, inst *poolInstance[T]) {
inst.reset(cancel)
p.mu.Unlock()
+ start := time.Now()
inst.status(StateBooting)
defer inst.status(StateOffline)
@@ -90,6 +93,8 @@ func (p *Pool[T]) runInstance(ctx context.Context, inst *poolInstance[T]) {
}
defer obj.Close()
+ p.BootTime.Save(time.Since(start))
+
inst.status(StateWaiting)
// The job and jobChan fields are subject to concurrent updates.
inst.mu.Lock()