File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -200,17 +200,15 @@ type config struct {
200200
201201// randomizeCompactionParams sets compaction parameters in cfg to random values
202202// to spread out compaction behavior across different nodes.
203+ //
204+ // #nosec G404 // non-crypto randomness is fine here
203205func randomizeCompactionParams (cfg * config ) {
204- r := rand .New (rand .NewSource (time .Now ().UnixNano ())) // #nosec G404 -- non-crypto randomness is fine here
205-
206- // generate random defaults for CompactionL0Trigger
207- compactionL0Trigger := r .Intn (maxCompactionL0Trigger - minCompactionL0Trigger + 1 ) + minCompactionL0Trigger
208-
209- // generate random defaults for CompactionTableSize
210- compactionTableSize := (r .Intn (maxCompactionTableSize - minCompactionTableSize + 1 ) + minCompactionTableSize )
211-
212- cfg .CompactionL0Trigger = compactionL0Trigger
213- cfg .CompactionTableSize = compactionTableSize
206+ const (
207+ rangeCompactionL0Trigger = maxCompactionL0Trigger - minCompactionL0Trigger + 1
208+ rangeCompactionTableSize = maxCompactionTableSize - minCompactionTableSize + 1
209+ )
210+ cfg .CompactionL0Trigger = rand .Intn (rangeCompactionL0Trigger ) + minCompactionL0Trigger
211+ cfg .CompactionTableSize = rand .Intn (rangeCompactionTableSize ) + minCompactionTableSize
214212}
215213
216214// New returns a wrapped LevelDB object.
You can’t perform that action at this time.
0 commit comments