@@ -160,8 +160,7 @@ data RunOpts = RunOpts
160160 , batchSize :: ! Int
161161 , check :: ! Bool
162162 , seed :: ! Word64
163- , pipelined :: ! Bool
164- , lookuponly :: ! Bool
163+ , mode :: ! RunMode
165164 }
166165 deriving stock Show
167166
@@ -189,21 +188,25 @@ mkTableConfigSetup GlobalOpts{diskCachePolicy}
189188 }
190189
191190mkTableConfigRun :: GlobalOpts -> RunOpts -> LSM. TableConfig -> LSM. TableConfig
192- mkTableConfigRun GlobalOpts {diskCachePolicy} RunOpts {pipelined } conf =
191+ mkTableConfigRun GlobalOpts {diskCachePolicy} RunOpts {mode } conf =
193192 conf {
194193 LSM. confDiskCachePolicy = diskCachePolicy,
195- LSM. confMergeBatchSize = if pipelined
196- then LSM. MergeBatchSize 1
197- else LSM. confMergeBatchSize conf
194+ LSM. confMergeBatchSize =
195+ case mode of
196+ Sequential -> LSM. confMergeBatchSize conf
197+ Pipelined -> LSM. MergeBatchSize 1
198+ LookupOnly -> LSM. confMergeBatchSize conf
198199 }
199200
200201mkTableConfigOverride :: GlobalOpts -> RunOpts -> LSM. TableConfigOverride
201- mkTableConfigOverride GlobalOpts {diskCachePolicy} RunOpts {pipelined } =
202+ mkTableConfigOverride GlobalOpts {diskCachePolicy} RunOpts {mode } =
202203 LSM. noTableConfigOverride {
203204 LSM. overrideDiskCachePolicy = Just diskCachePolicy,
204- LSM. overrideMergeBatchSize = if pipelined
205- then Just (LSM. MergeBatchSize 1 )
206- else Nothing
205+ LSM. overrideMergeBatchSize =
206+ case mode of
207+ Sequential -> Nothing
208+ Pipelined -> Just $ LSM. MergeBatchSize 1
209+ LookupOnly -> Nothing
207210 }
208211
209212mkTracer :: GlobalOpts -> Tracer IO LSM. LSMTreeTrace
@@ -269,8 +272,20 @@ runOptsP = pure RunOpts
269272 <*> O. option O. auto (O. long " batch-size" <> O. value 256 <> O. showDefault <> O. help " Batch size" )
270273 <*> O. switch (O. long " check" <> O. help " Check generated key distribution" )
271274 <*> O. option O. auto (O. long " seed" <> O. value 1337 <> O. showDefault <> O. help " Random seed" )
272- <*> O. switch (O. long " pipelined" <> O. help " Use pipelined mode" )
273- <*> O. switch (O. long " lookup-only" <> O. help " Use lookup only mode" )
275+ <*> O. option O. auto (O. long " mode" <> O. value Sequential <> O. showDefault
276+ <> O. help " Mode [Sequential | Pipelined | LookupOnly]" )
277+
278+ -- | The run mode affects the method of performing
279+ data RunMode =
280+ -- | Use sequential mode: wait for a batch of operations to complete before
281+ -- starting the next one.
282+ Sequential
283+ -- | Use pipelined mode: overlap batches of operations.
284+ | Pipelined
285+ -- | Use lookup-only sequential mode: like sequential mode, but only perform
286+ -- the lookups and not the updates.
287+ | LookupOnly
288+ deriving stock (Show , Eq , Read )
274289
275290deriving stock instance Read LSM. DiskCachePolicy
276291deriving stock instance Read LSM. BloomFilterAlloc
@@ -620,10 +635,10 @@ doRun gopts opts =
620635 fail $ " lookup result mismatch in batch " ++ show b
621636 writeIORef checkvar xs
622637
623- let benchmarkIterations
624- | pipelined opts = pipelinedIterations h
625- | lookuponly opts = sequentialIterationsLO
626- | otherwise = sequentialIterations h
638+ let benchmarkIterations = case mode opts of
639+ Sequential -> sequentialIterations h
640+ Pipelined -> pipelinedIterations h
641+ LookupOnly -> sequentialIterationsLO
627642 ! progressInterval = max 1 ((batchCount opts) `div` 100 )
628643 madeProgress b = b `mod` progressInterval == 0
629644 (time, _, _) <- timed_ $ do
0 commit comments