Skip to content

Commit

Permalink
notes
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Apr 25, 2024
1 parent 38cf66c commit 21e033f
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions bench/macro/lsm-tree-bench-wp8.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}

{- Benchmark requirements:
A. The benchmark should use the external interface of the disk backend,
and no internal interfaces.
B. The benchmark should use a workload ratio of 1 insert, to 1 delete,
to 1 lookup. This is the workload ratio for the UTxO. Thus the
performance is to be evaluated on the combination of the operations,
not on operations individually.
C. The benchmark should use 34 byte keys, and 60 byte values. This
corresponds roughly to the UTxO.
D. The benchmark should use keys that are evenly spread through the
key space, such as cryptographic hashes.
E. The benchmark should start with a table of 100 million entries.
This corresponds to the stretch target for the UTxO size.
This table may be pre-generated. The time to construct the table
should not be included in the benchmark time.
F. The benchmark workload should ensure that all inserts are for
`fresh' keys, and that all lookups and deletes are for keys that
are present. This is the typical workload for the UTxO.
G. It is acceptable to pre-generate the sequence of operations for the
benchmark, or to take any other measure to exclude the cost of
generating or reading the sequence of operations.
H. The benchmark should use the external interface of the disk backend
to present batches of operations: a first batch consisting of 256
lookups, followed by a second batch consisting of 256 inserts plus
256 deletes. This corresponds to the UTxO workload using 64kb
blocks, with 512 byte txs with 2 inputs and 2 outputs.
I. The benchmark should be able to run in two modes, using the
external interface of the disk backend in two ways: serially (in
batches), or fully pipelined (in batches).
-}
module Main (main) where

import Control.Applicative ((<**>))
import Control.Exception (bracket)
import Control.Monad (forM_)
import qualified Crypto.Hash.SHA256 as SHA256
import Control.Monad (forM_)
import qualified Data.Binary as B
import qualified Data.ByteString as BS
import Data.Void (Void)
Expand Down Expand Up @@ -81,7 +114,12 @@ globalOptsP = pure GlobalOpts

cmdP :: O.Parser Cmd
cmdP = O.subparser $ mconcat
[ O.command "setup" $ O.info (CmdSetup <$> setupOptsP <**> O.helper) (O.progDesc "Setup benchmark")
[ O.command "setup" $ O.info
(CmdSetup <$> setupOptsP <**> O.helper)
(O.progDesc "Setup benchmark")
, O.command "dry-run" $ O.info
(pure CmdDryRun <**> O.helper)
(O.progDesc "Dry run, measure overhead")
]

setupOptsP :: O.Parser SetupOpts
Expand Down Expand Up @@ -141,6 +179,22 @@ doSetup gopts opts = do

LSM.snapshot name tbh

-------------------------------------------------------------------------------
-- dry-run
-------------------------------------------------------------------------------

doDryRun :: GlobalOpts -> IO ()
doDryRun _gopts = return ()
-- TODO: open session

{-
implement generation of unbounded sequence of insert/delete operations
matching UTxO style from spec: interleaved batches insert and lookup
configurable batch sizes
1 insert, 1 delete, 1 lookup per key.
-}

-------------------------------------------------------------------------------
-- main
-------------------------------------------------------------------------------
Expand All @@ -152,7 +206,7 @@ main = do
print cmd
case cmd of
CmdSetup opts -> doSetup gopts opts
CmdDryRun -> return () -- TODO
CmdDryRun -> doDryRun gopts
CmdRun -> return () -- TODO
where
cliP = O.info ((,) <$> globalOptsP <*> cmdP <**> O.helper) O.fullDesc
Expand Down

0 comments on commit 21e033f

Please sign in to comment.