Skip to content

Commit

Permalink
sharedcache: reduce the scope of TestSharedCacheRandomized under race
Browse files Browse the repository at this point in the history
Reduce the max number of shards and skip the random block size tests
under race. This significantly reduces the runtime and memory
footprint of the test.

Informs: #2741
  • Loading branch information
RaduBerinde committed Jul 18, 2023
1 parent 5f5be26 commit bf5f4c4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions objstorage/objstorageprovider/sharedcache/shared_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/pebble/internal/base"
"github.com/cockroachdb/pebble/internal/invariants"
"github.com/cockroachdb/pebble/objstorage"
"github.com/cockroachdb/pebble/objstorage/objstorageprovider"
"github.com/cockroachdb/pebble/objstorage/objstorageprovider/sharedcache"
Expand Down Expand Up @@ -135,7 +136,11 @@ func TestSharedCacheRandomized(t *testing.T) {
return func(t *testing.T) {
for _, concurrentReads := range []bool{false, true} {
t.Run(fmt.Sprintf("concurrentReads=%v", concurrentReads), func(t *testing.T) {
numShards := rand.Intn(64) + 1
maxShards := 64
if invariants.RaceEnabled {
maxShards = 8
}
numShards := rand.Intn(maxShards) + 1
cacheSize := shardingBlockSize * int64(numShards) // minimum allowed cache size

cache, err := sharedcache.Open(fs, base.DefaultLogger, "", blockSize, shardingBlockSize, cacheSize, numShards)
Expand Down Expand Up @@ -195,14 +200,16 @@ func TestSharedCacheRandomized(t *testing.T) {
t.Run("32 KB block size", helper(32*1024, 1024*1024))
t.Run("1 MB block size", helper(1024*1024, 1024*1024))

for i := 0; i < 5; i++ {
exp := rand.Intn(11) + 10 // [10, 20]
randomBlockSize := 1 << exp // [1 KB, 1 MB]
if !invariants.RaceEnabled {
for i := 0; i < 5; i++ {
exp := rand.Intn(11) + 10 // [10, 20]
randomBlockSize := 1 << exp // [1 KB, 1 MB]

factor := rand.Intn(10) + 1 // [1, 10]
randomShardingBlockSize := int64(randomBlockSize * factor) // [1 KB, 10 MB]
factor := rand.Intn(10) + 1 // [1, 10]
randomShardingBlockSize := int64(randomBlockSize * factor) // [1 KB, 10 MB]

t.Run("random block and sharding block size", helper(randomBlockSize, randomShardingBlockSize))
t.Run("random block and sharding block size", helper(randomBlockSize, randomShardingBlockSize))
}
}
}

Expand Down

0 comments on commit bf5f4c4

Please sign in to comment.