Skip to content

Commit

Permalink
fix(benchmarks): use uint32 in filename generation (#1741)
Browse files Browse the repository at this point in the history
Note that the file ID can be 32 bit only, while the benchmarks were using 63-bit number for the same.

(cherry picked from commit 292a4be)
  • Loading branch information
joshua-goldstein committed Feb 18, 2023
1 parent 4e56d97 commit 6b0349a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func buildTable(t *testing.T, keyValues [][]string, bopts table.Options) *table.
defer b.Close()
// TODO: Add test for file garbage collection here. No files should be left after the tests here.

filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Int63())
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Uint32())

sort.Slice(keyValues, func(i, j int) bool {
return keyValues[i][0] < keyValues[j][0]
Expand Down
6 changes: 3 additions & 3 deletions table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func TestTableBigValues(t *testing.T) {
builder.Add(key, vs, 0)
}

filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Int63())
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Uint32())
tbl, err := CreateTable(filename, builder)
require.NoError(t, err, "unable to open table")
defer tbl.DecrRef()
Expand Down Expand Up @@ -754,7 +754,7 @@ func BenchmarkReadMerged(b *testing.B) {
require.NoError(b, err)

for i := 0; i < m; i++ {
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Int63())
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Uint32())
opts := Options{Compression: options.ZSTD, BlockSize: 4 * 1024, BloomFalsePositive: 0.01}
opts.BlockCache = cache
builder := NewTableBuilder(opts)
Expand Down Expand Up @@ -848,7 +848,7 @@ func getTableForBenchmarks(b *testing.B, count int, cache *ristretto.Cache) *Tab
opts.BlockCache = cache
builder := NewTableBuilder(opts)
defer builder.Close()
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Int63())
filename := fmt.Sprintf("%s%s%d.sst", os.TempDir(), string(os.PathSeparator), rand.Uint32())
for i := 0; i < count; i++ {
k := fmt.Sprintf("%016x", i)
v := fmt.Sprintf("%d", i)
Expand Down
5 changes: 3 additions & 2 deletions value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,8 +963,9 @@ func BenchmarkReadWrite(b *testing.B) {
dir, err := ioutil.TempDir("", "vlog-benchmark")
y.Check(err)
defer removeDir(dir)

db, err := Open(getTestOptions(dir))
opts := getTestOptions(dir)
opts.ValueThreshold = 0
db, err := Open(opts)
y.Check(err)

vl := &db.vlog
Expand Down

0 comments on commit 6b0349a

Please sign in to comment.