Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: payload pushing #2058

Draft
wants to merge 3 commits into
base: pact5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions bench/Chainweb/Pact/Backend/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ import Chainweb.BlockHeader.Internal
import Chainweb.Graph
import Chainweb.Logger
import Chainweb.MerkleLogHash
import Chainweb.Pact.Backend.RelationalCheckpointer
import Chainweb.Pact.PactService.Checkpointer.Internal

import Chainweb.Pact.Backend.Types
import Chainweb.Pact.Backend.Utils
import Chainweb.Pact.Types
import Chainweb.Test.TestVersions
Expand All @@ -72,12 +73,12 @@ testChainId = unsafeChainId 0
-- allowing a straightforward list of blocks to be passed to the API,
-- and only exposing the PactDbEnv part of the block context
cpRestoreAndSave
:: (Monoid q)
:: (Monoid q, Logger logger)
=> Checkpointer logger
-> Maybe BlockHeader
-> [(BlockHeader, PactDbEnv (Pact4.BlockEnv logger) -> IO q)]
-> IO q
cpRestoreAndSave cp pc blks = snd <$> _cpRestoreAndSave cp (ParentHeader <$> pc)
cpRestoreAndSave cp pc blks = snd <$> restoreAndSave cp (ParentHeader <$> pc)
(traverse Stream.yield [Pact4RunnableBlock $ \dbEnv _ -> (,bh) <$> fun (Pact4._cpPactDbEnv dbEnv) | (bh, fun) <- blks])

-- | fabricate a `BlockHeader` for a block given its hash and its parent.
Expand Down Expand Up @@ -152,7 +153,7 @@ cpWithBench torun =
let neverLogger = genericLogger Error (\_ -> return ())
!sqliteEnv <- openSQLiteConnection dbFile chainwebPragmas
!cenv <-
initRelationalCheckpointer defaultModuleCacheLimit sqliteEnv DoNotPersistIntraBlockWrites neverLogger testVer testChainId
initCheckpointerResources defaultModuleCacheLimit sqliteEnv DoNotPersistIntraBlockWrites neverLogger testVer testChainId
return $ NoopNFData (sqliteEnv, cenv)

teardown (NoopNFData (sqliteEnv, _cenv)) = closeSQLiteConnection sqliteEnv
Expand All @@ -161,7 +162,7 @@ cpWithBench torun =
benches cpenv =
[ torun cpenv ]

cpBenchNoRewindOverBlock :: Int -> Checkpointer logger -> C.Benchmark
cpBenchNoRewindOverBlock :: Logger logger => Int -> Checkpointer logger -> C.Benchmark
cpBenchNoRewindOverBlock transactionCount cp = C.env setup' $ \ ~ut ->
C.bench name $ C.nfIO $ do
mv <- newMVar (initbytestring, pc01)
Expand Down Expand Up @@ -203,7 +204,7 @@ cpBenchNoRewindOverBlock transactionCount cp = C.env setup' $ \ ~ut ->
where
transaction db = incIntegerAtKey db ut f k 1

cpBenchOverBlock :: Int -> Checkpointer logger -> C.Benchmark
cpBenchOverBlock :: Logger logger => Int -> Checkpointer logger -> C.Benchmark
cpBenchOverBlock transactionCount cp = C.env setup' $ \ ~(ut) ->
C.bench benchname $ C.nfIO (go ut)
where
Expand Down Expand Up @@ -337,7 +338,7 @@ benchUserTableForKeys numSampleEvents dbEnv =
writeRow db Update ut f rowkeyb a


_cpBenchKeys :: Int -> Checkpointer logger -> C.Benchmark
_cpBenchKeys :: Logger logger => Int -> Checkpointer logger -> C.Benchmark
_cpBenchKeys numKeys cp =
C.env setup' $ \ ~(ut) -> C.bench name $ C.nfIO (go ut)
where
Expand Down Expand Up @@ -370,7 +371,7 @@ _cpBenchKeys numKeys cp =
let rowkey = RowKey $ "k" <> sshow numkey
incIntegerAtKey db ut f rowkey 1

cpBenchSampleKeys :: Int -> Checkpointer logger -> C.Benchmark
cpBenchSampleKeys :: Logger logger => Int -> Checkpointer logger -> C.Benchmark
cpBenchSampleKeys numSampleEvents cp =
C.env setup' $ \ ~(ut) -> C.bench name $ C.nfIO (go ut)
where
Expand Down Expand Up @@ -416,7 +417,7 @@ cpBenchSampleKeys numSampleEvents cp =
)]


cpBenchLookupProcessedTx :: Int -> Checkpointer logger -> C.Benchmark
cpBenchLookupProcessedTx :: Logger logger => Int -> Checkpointer logger -> C.Benchmark
cpBenchLookupProcessedTx transactionCount cp = C.env setup' $ \ ~(ut) ->
C.bench benchname $ C.nfIO (go ut)
where
Expand Down Expand Up @@ -444,5 +445,5 @@ cpBenchLookupProcessedTx transactionCount cp = C.env setup' $ \ ~(ut) ->
pc02 = childOf (Just pc01) hash02

go (NoopNFData _) = do
_cpReadFrom (_cpReadCp cp) (Just (ParentHeader pc02)) Pact4T $ \dbEnv _ ->
readFrom cp (Just (ParentHeader pc02)) Pact4T $ \dbEnv _ ->
Pact4._cpLookupProcessedTx dbEnv (V.fromList [Pact.RequestKey (Pact.toUntypedHash $ Pact.TypedHash "") | _ <- [1..transactionCount]])
1 change: 1 addition & 0 deletions bench/Chainweb/Pact/Backend/ForkingBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import Chainweb.Mempool.Mempool
import Chainweb.Miner.Pact
import Chainweb.Pact.Backend.Compaction qualified as C

import Chainweb.Pact.Backend.Types
import Chainweb.Pact.Backend.Utils
import Chainweb.Pact.PactService
import Chainweb.Pact.Service.BlockValidation
Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/kadena-io/pact-5.git
tag: 99e70e6af1977a5c5705affc59ef2de0d165682c
--sha256: 0hrir25c9dagid8h0x3qkqy4r23xzhlh03jk3af3c0r7p8mi3m7y
tag: c2f5fb7b19b2bc3e4153d1dd14711195c8fe774a
--sha256: 1nn719nsbwmry7fvyn4xv1zi2mm7a5q3s07whghw5gf17zqnjbda

source-repository-package
type: git
Expand Down
Loading
Loading