-
Notifications
You must be signed in to change notification settings - Fork 98
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
Faster catchup #1206
base: master
Are you sure you want to change the base?
Faster catchup #1206
Conversation
@@ -126,6 +126,7 @@ import qualified Data.Text as T | |||
import Data.Word | |||
|
|||
import GHC.Generics (Generic) | |||
import GHC.Stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the call stack still needed, or was that just for debugging?
@@ -210,7 +210,8 @@ cutMap :: Getter Cut (HM.HashMap ChainId BlockHeader) | |||
cutMap = cutHeaders | |||
|
|||
lookupCutM | |||
:: MonadThrow m | |||
:: HasCallStack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above. Is this for debugging?
src/Chainweb/CutDB.hs
Outdated
@@ -730,17 +733,20 @@ blockDiffStream :: MonadIO m => CutDb cas -> S.Stream (Of (Either BlockHeader Bl | |||
blockDiffStream db = cutStreamToHeaderDiffStream db $ cutStream db | |||
|
|||
cutHashesToBlockHeaderMap | |||
:: PayloadCas cas | |||
:: forall cas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This quantification should not be necessary; you aren't using the variable within the function anywhere that I can see.
Nothing -> casLookup cas payloadHash >>= \case | ||
(Just !x) -> return $! payloadWithOutputsToPayloadData x | ||
Nothing -> memo memoMap payloadHash $ \k -> | ||
pullOrigin k maybeOrigin >>= \case | ||
Nothing -> do | ||
t <- queryPayloadTask k | ||
pQueueInsert queue t | ||
awaitTask t | ||
head <$> awaitTask t -- FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed before merging.
Nothing -- cursor | ||
Nothing -- limit | ||
(Just . int $ min (_blockHeight curHdr) trgHeight) -- minimum rank | ||
-- FIXME guarantee that at least one block is returned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix :)
rs $ S.next >=> \case | ||
Left _ -> return Nothing | ||
Right (x, r) -> do | ||
unless (_blockHash x == k) $ error "pullOrigin: assertion failed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would guard
do the same thing here?
memoBatchAsync tm@(TaskMap var) ks batchTask = do | ||
modifyMVarMasked var $ \m -> do | ||
let missing = filter (not . (`HM.member` m)) ks | ||
t <- asyncWithUnmask $ \umask -> umask (batchTask missing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use WithUnmask
here if you immediately unmask the entire block being passed? What is the benefit?
-- this is somewhat expensive but only relevant during chaingraph | ||
-- transitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this more or less free, now that the genesis headers are cached?
casLookup candidateStore payloadHash >>= \case | ||
Just !x -> return x | ||
Just !x -> do | ||
logfun Info $ taskMsg "got payload from candidate store" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this maybe too much logging? Should this be Debug
level?
return Nothing | ||
pullOrigin k (Just origin) = do | ||
pullOrigin k (Just origin) = flip catchAllSynchronous (\_ -> return Nothing) $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this catchAllSynchronous
for?
instance (Typeable k, Show k) => Exception (NoBatchResultException k) | ||
|
||
-- | Schedule a task that computes a batch of task map entries, that can be | ||
-- awaited as indiviual tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/indiviual/individual
@@ -282,7 +324,10 @@ getBlockHeaderInternal headerStore payloadStore candidateHeaderCas candidatePayl | |||
-- - task queue of P2P network | |||
-- | |||
(maybeOrigin', header) <- casLookup candidateHeaderCas k' >>= \case | |||
Just !x -> return (maybeOrigin, x) | |||
Just !x -> do | |||
logg Info $ taskMsg k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ Ditto, maybe Debug
?
No description provided.