Skip to content

Commit

Permalink
Merge #135122
Browse files Browse the repository at this point in the history
135122: storage: don't cache benchmark fixtures in metamorphic builds r=RaduBerinde a=jbowens

In CI, we sometimes run benchmarks in metamorphic builds to ensure the benchmarks pass. We don't want to cache the fixtures generated by these runs, because we may end up caching fixtures that reflect metamorphic values. This can lead to very non-deterministic behavior in the benchmarks depending on what metamorphic settings were active when the fixture was generated.

Epic: none
Release note: none
Informs #135114.

Co-authored-by: Jackson Owens <[email protected]>
  • Loading branch information
craig[bot] and jbowens committed Nov 14, 2024
2 parents f60d2d3 + 0dcc3fa commit 39e43b8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkg/storage/bench_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/encoding"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/metamorphic"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -69,9 +70,23 @@ func getInitialStateEngine(
ctx context.Context, b *testing.B, initial initialState, inMemory bool,
) Engine {
name := strings.Join(initial.Key(), "-")
dir := testfixtures.ReuseOrGenerate(b, name, func(dir string) {

// In CI, we sometimes run benchmarks in metamorphic builds to ensure the
// benchmarks pass. We don't want to cache the fixtures generated by these
// runs, because we may end up caching fixtures that reflect metamorphic
// values. This can lead to very non-deterministic behavior in the
// benchmarks depending on what metamorphic settings were active when the
// fixture was generated.
var dir string
if metamorphic.IsMetamorphicBuild() {
b.Log("running in metamorphic build; ignoring existing fixtures and not caching new ones")
dir = b.TempDir()
buildInitialState(ctx, b, initial, dir)
})
} else {
dir = testfixtures.ReuseOrGenerate(b, name, func(dir string) {
buildInitialState(ctx, b, initial, dir)
})
}
dataDir := filepath.Join(dir, "data")

opts := append([]ConfigOption{
Expand Down

0 comments on commit 39e43b8

Please sign in to comment.