Skip to content

Commit

Permalink
sql/tests: disable profiling during sysbench setup
Browse files Browse the repository at this point in the history
This commit disables memory, mutex, and block profiling during sysbench
setup. All three of these profile types record events from process startup
onward if we don't manully disable them.

Epic: None
Release note: None
  • Loading branch information
nvanbenschoten committed Nov 4, 2024
1 parent ffa2ecb commit 8556bc7
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/sql/tests/sysbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
"fmt"
"math/rand"
"runtime"
"slices"
"testing"

Expand Down Expand Up @@ -638,23 +639,44 @@ func BenchmarkSysbench(b *testing.B) {
}
}()

// Set up the cluster and dataset.
disableProfiling()
ctx := context.Background()
sys, cleanup := driver.constructorFn(ctx, b)
defer cleanup()

rng := rand.New(rand.NewSource(0))
sys.prep(rng)

// Start profiling and timer, then run the workload.
enableProfiling()
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
workload.opFn(sys, rng)
}

// Stop timer and profiling to exclude (deferred) cluster teardown.
b.StopTimer()
disableProfiling()
})
}
})
}
}

func disableProfiling() {
runtime.MemProfileRate = 0
runtime.SetMutexProfileFraction(0)
runtime.SetBlockProfileRate(0)
}

func enableProfiling() {
runtime.GC()
runtime.MemProfileRate = 1
runtime.SetMutexProfileFraction(1)
runtime.SetBlockProfileRate(1)
}

func try0(err error) {
if err != nil {
panic(errors.WrapWithDepth(1, err, "try failed"))
Expand Down

0 comments on commit 8556bc7

Please sign in to comment.