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

perf: use module cache output from readFrom #1972

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions changes/2024-06-19T182645-0400.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a performance bug in read-only replay which was not using a cache
for module data
11 changes: 8 additions & 3 deletions src/Chainweb/Pact/Backend/RelationalCheckpointer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ doReadFrom logger v cid sql moduleCacheVar maybeParent doRead = do
Nothing -> genesisHeight v cid
Just parent -> succ . _blockHeight . _parentHeader $ parent

withMVar moduleCacheVar $ \sharedModuleCache -> do
modifyMVar moduleCacheVar $ \sharedModuleCache -> do
bracket
(beginSavepoint sql BatchSavepoint)
(\_ -> abortSavepoint sql BatchSavepoint) $ \() -> do
getEndTxId "doReadFrom" sql maybeParent >>= traverse \startTxId -> do
h <- getEndTxId "doReadFrom" sql maybeParent >>= traverse \startTxId -> do
newDbEnv <- newMVar $ BlockEnv
(mkBlockHandlerEnv v cid currentHeight sql DoNotPersistIntraBlockWrites logger)
(initBlockState defaultModuleCacheLimit startTxId)
Expand All @@ -184,7 +184,12 @@ doReadFrom logger v cid sql moduleCacheVar maybeParent doRead = do
, _cpLookupProcessedTx = \hs ->
runBlockEnv newDbEnv (doLookupSuccessful currentHeight hs)
}
doRead curBlockDbEnv
r <- doRead curBlockDbEnv
finalCache <- _bsModuleCache . _benvBlockState <$> readMVar newDbEnv
return (r, finalCache)
case h of
NoHistory -> return (sharedModuleCache, NoHistory)
Historical (r, finalCache) -> return (finalCache, Historical r)



Expand Down
Loading