Skip to content

Commit b395f92

Browse files
authored
use badger defaults in write benchmark tool (#1448)
use badger defaults in write benchmark tool and add flag for syncWrites
1 parent cd3a822 commit b395f92

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

badger/cmd/write_bench.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ var writeBenchCmd = &cobra.Command{
4141
Use: "write",
4242
Short: "Writes random data to Badger to benchmark write speed.",
4343
Long: `
44-
This command writes random data to Badger to benchmark write speed. Useful for testing and
45-
performance analysis.
46-
`,
44+
This command writes random data to Badger to benchmark write speed. Useful for testing and
45+
performance analysis.
46+
`,
4747
RunE: writeBench,
4848
}
4949

5050
var (
51-
keySz int
52-
valSz int
53-
numKeys float64
54-
force bool
55-
sorted bool
56-
showLogs bool
51+
keySz int
52+
valSz int
53+
numKeys float64
54+
syncWrites bool
55+
force bool
56+
sorted bool
57+
showLogs bool
5758

5859
sizeWritten uint64
5960
entriesWritten uint64
@@ -96,27 +97,29 @@ func init() {
9697
writeBenchCmd.Flags().IntVarP(&valSz, "val-size", "v", 128, "Size of value")
9798
writeBenchCmd.Flags().Float64VarP(&numKeys, "keys-mil", "m", 10.0,
9899
"Number of keys to add in millions")
100+
writeBenchCmd.Flags().BoolVar(&syncWrites, "sync", true,
101+
"If true, sync writes to disk.")
99102
writeBenchCmd.Flags().BoolVarP(&force, "force-compact", "f", true,
100103
"Force compact level 0 on close.")
101104
writeBenchCmd.Flags().BoolVarP(&sorted, "sorted", "s", false, "Write keys in sorted order.")
102105
writeBenchCmd.Flags().BoolVarP(&showLogs, "logs", "l", false, "Show Badger logs.")
103106
writeBenchCmd.Flags().IntVarP(&valueThreshold, "value-th", "t", 1<<10, "Value threshold")
104107
writeBenchCmd.Flags().IntVarP(&numVersions, "num-version", "n", 1, "Number of versions to keep")
105-
writeBenchCmd.Flags().Int64VarP(&maxCacheSize, "max-cache", "C", 1<<30, "Max size of cache")
106-
writeBenchCmd.Flags().BoolVarP(&keepBlockIdxInCache, "keep-bidx", "b", true,
108+
writeBenchCmd.Flags().Int64VarP(&maxCacheSize, "max-cache", "C", 0, "Max size of cache")
109+
writeBenchCmd.Flags().BoolVarP(&keepBlockIdxInCache, "keep-bidx", "b", false,
107110
"Keep block indices in cache")
108-
writeBenchCmd.Flags().BoolVarP(&keepBlocksInCache, "keep-blocks", "B", true,
111+
writeBenchCmd.Flags().BoolVarP(&keepBlocksInCache, "keep-blocks", "B", false,
109112
"Keep blocks in cache")
110-
writeBenchCmd.Flags().Int64VarP(&maxBfCacheSize, "max-bf-cache", "c", 500<<20,
113+
writeBenchCmd.Flags().Int64VarP(&maxBfCacheSize, "max-bf-cache", "c", 0,
111114
"Maximum Bloom Filter Cache Size")
112-
writeBenchCmd.Flags().Uint32Var(&vlogMaxEntries, "vlog-maxe", 10000, "Value log Max Entries")
115+
writeBenchCmd.Flags().Uint32Var(&vlogMaxEntries, "vlog-maxe", 1000000, "Value log Max Entries")
113116
writeBenchCmd.Flags().StringVarP(&encryptionKey, "encryption-key", "e", "",
114117
"If it is true, badger will encrypt all the data stored on the disk.")
115118
writeBenchCmd.Flags().StringVar(&loadingMode, "loading-mode", "mmap",
116119
"Mode for accessing SSTables")
117-
writeBenchCmd.Flags().BoolVar(&loadBloomsOnOpen, "load-blooms", false,
120+
writeBenchCmd.Flags().BoolVar(&loadBloomsOnOpen, "load-blooms", true,
118121
"Load Bloom filter on DB open.")
119-
writeBenchCmd.Flags().BoolVar(&detectConflicts, "conficts", false,
122+
writeBenchCmd.Flags().BoolVar(&detectConflicts, "conficts", true,
120123
"If true, it badger will detect the conflicts")
121124
writeBenchCmd.Flags().BoolVar(&compression, "compression", false,
122125
"If true, badger will use ZSTD mode")
@@ -243,7 +246,7 @@ func writeBench(cmd *cobra.Command, args []string) error {
243246
opt := badger.DefaultOptions(sstDir).
244247
WithValueDir(vlogDir).
245248
WithTruncate(truncate).
246-
WithSyncWrites(false).
249+
WithSyncWrites(syncWrites).
247250
WithCompactL0OnClose(force).
248251
WithValueThreshold(valueThreshold).
249252
WithNumVersionsToKeep(numVersions).

0 commit comments

Comments
 (0)