Skip to content

Commit

Permalink
storage: augment BenchmarkGarbageCollect to different deletion ratios
Browse files Browse the repository at this point in the history
Before this change, BenchmarkGarbageCollect always benchmarked collecting
all but the last version of a key. This change expands the test to benchmark
different numbers of deleted versions to highlight that the current
implementation is linear in the number of versions.

Release note: None
  • Loading branch information
ajwerner committed Jul 8, 2020
1 parent 7d69b0a commit 42f1d96
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions pkg/storage/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ func BenchmarkMVCCGarbageCollect(b *testing.B) {
keySizes := []int{128}
valSizes := []int{128}
numKeys := []int{1, 1024}
versions := []int{2, 1024}
versionConfigs := []struct {
total int
toDelete []int
}{
{2, []int{1}},
{1024, []int{1, 16, 32, 512, 1015, 1023}},
}
engineMakers := []struct {
name string
create engineMaker
Expand All @@ -65,18 +71,22 @@ func BenchmarkMVCCGarbageCollect(b *testing.B) {
b.Run(fmt.Sprintf("valSize=%d", valSize), func(b *testing.B) {
for _, numKeys := range numKeys {
b.Run(fmt.Sprintf("numKeys=%d", numKeys), func(b *testing.B) {
for _, numVersions := range versions {
b.Run(fmt.Sprintf("numVersions=%d", numVersions), func(b *testing.B) {
runMVCCGarbageCollect(ctx, b, engineImpl.create,
benchGarbageCollectOptions{
benchDataOptions: benchDataOptions{
numKeys: numKeys,
numVersions: numVersions,
valueBytes: valSize,
},
keyBytes: keySize,
deleteVersions: numVersions - 1,
for _, versions := range versionConfigs {
b.Run(fmt.Sprintf("numVersions=%d", versions.total), func(b *testing.B) {
for _, toDelete := range versions.toDelete {
b.Run(fmt.Sprintf("deleteVersions=%d", toDelete), func(b *testing.B) {
runMVCCGarbageCollect(ctx, b, engineImpl.create,
benchGarbageCollectOptions{
benchDataOptions: benchDataOptions{
numKeys: numKeys,
numVersions: versions.total,
valueBytes: valSize,
},
keyBytes: keySize,
deleteVersions: toDelete,
})
})
}
})
}
})
Expand Down

0 comments on commit 42f1d96

Please sign in to comment.