Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Apr 25, 2024
1 parent a4116e0 commit 6f64372
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions bench/macro/lsm-tree-bench-wp8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type B = Void
makeKey :: Word64 -> K
makeKey w64 = SHA256.hashlazy (B.encode w64) <> "=="

-- We use constant value. This shouldn't affect anything.
theValue :: V
theValue = BS.replicate 60 120 -- 'x'
{-# NOINLINE theValue #-}
Expand All @@ -94,8 +95,6 @@ data GlobalOpts = GlobalOpts
deriving Show

data SetupOpts = SetupOpts
{ size :: Int -- TODO remove
}
deriving Show

data RunOpts = RunOpts
Expand Down Expand Up @@ -138,7 +137,6 @@ cmdP = O.subparser $ mconcat

setupOptsP :: O.Parser SetupOpts
setupOptsP = pure SetupOpts
<*> pure 10000 -- TODO: change to 100e6

runOptsP :: O.Parser RunOpts
runOptsP = pure RunOpts
Expand Down Expand Up @@ -251,19 +249,7 @@ doDryRun' gopts opts = do
(IS.difference keys new)
(IS.fromList $ map fromIntegral inserts)

-- first batch is lookups
let batch1 :: [K]
batch1 = map makeKey lookups

batch2 :: [(K, LSM.Update V B)]
batch2 =
[ (k, LSM.Delete)
| k <- batch1
] ++
[ (makeKey k, LSM.Insert theValue Nothing)
| k <- inserts
]

let (batch1, batch2) = toOperations lookups inserts
_ <- evaluate $ force (batch1, batch2)

return nextG
Expand All @@ -272,6 +258,10 @@ doDryRun' gopts opts = do
duplicates <- readIORef duplicateRef
printf "True duplicates: %d\n" duplicates

-------------------------------------------------------------------------------
-- Batch generation
-------------------------------------------------------------------------------

{- | Implement generation of unbounded sequence of insert/delete operations
matching UTxO style from spec: interleaved batches insert and lookup
Expand All @@ -295,6 +285,22 @@ generateBatch initialSize batchSize g b = (nextG, lookups, inserts)
inserts :: [Word64]
inserts = [ maxK .. maxK + fromIntegral batchSize - 1 ]

-- | Generate operation inputs
toOperations :: [Word64] -> [Word64] -> ([K], [(K, LSM.Update V B)])
toOperations lookups inserts = (batch1, batch2)
where
batch1 :: [K]
batch1 = map makeKey lookups

batch2 :: [(K, LSM.Update V B)]
batch2 =
[ (k, LSM.Delete)
| k <- batch1
] ++
[ (makeKey k, LSM.Insert theValue Nothing)
| k <- inserts
]

-------------------------------------------------------------------------------
-- run
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -350,8 +356,4 @@ forFoldM_ !s (x:xs) f = do

_unused :: ()
_unused = const ()
( makeKey
, theValue
, timed
, timed_
)
timed

0 comments on commit 6f64372

Please sign in to comment.