-
Notifications
You must be signed in to change notification settings - Fork 217
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
Pipeline requests near the chain tip too, with care #1665
Conversation
lib/byron/1-percent.timelog
Outdated
1589384183.268922344s -0 | ||
1589384183.34260801s 1000 | ||
1589384183.401558201s 2000 | ||
1589384183.462808633s 3000 |
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.
Shouldn't be committed!
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.
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.
I might have abused git add lib
😄 ...
This is a bit tricky because, as soon as we enter the `tip - k` area, any 'RequestNext' may yield a 'RollBackward'. The strategy is however quite simple and boils down to two cases: - Either we have to rollback within blocks we have just collected but not yet sent for processing. - Either, we have to rollback beyond this. In the former case, we can simply discard blocks from what we have collected and continue as normal. In the latter, we have to forward the rollback requests to the wallet engine, but we have to keep on collecting the results for the requests we have already pipelined! We do so by stashing the results in a queue, so that they'd be available for the next 'RequestNext' command from the wallet. This effectively extend pipelining up to the point where we have caught up with the tip and start collecting requests one by one, in a calmly manner. This is visible from the logs: ``` ... Applying blocks [192.13732 ... 192.14731] Applying blocks [192.14732 ... 192.15731] Applying blocks [192.15732 ... 192.15977] Applying blocks [192.15978 ... 192.15978] Applying blocks [192.15979 ... 192.15979] Applying blocks [192.15980 ... 192.15980] ```
bf05724
to
f4d26b4
Compare
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.
lgtm.
I guess testing that everything works if the chain forks in the middle of collecting responses, etc, would be nice, but not sure how one would do that.
-- receiving future requests, we'll simply read them from the stash! | ||
, P.recvMsgRollBackward = \point _tip -> | ||
case rollback point blocks of | ||
[] -> do -- b) |
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.
It probably doesn't matter, but I think you can't differentiate between:
- Rolling back to the latest persisted block (
[]
, but norespond (Rollback point)
needed) - Rolling back to one before the latest persisted block (rollback needed)
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.
Yes, this would induce a rollback to where the wallet already is at, which is a no-op for the wallet and database. So, in principle, there's nothing wrong from it. Yet indeed, the client is blind to what the latest persisted block is so it can't really make this distinction.
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.
Looks good to me.
Would the design be simpler if we changed network layer from pull (nextBlocks) to push (onNextBlock)?
It would also be good to allocate some time to unit testing the cardano-node network layers because they are not totally simple any more.
nodeToClientProtocols NodeToClientProtocols | ||
-> m (NetworkClient m) | ||
mkWalletClient bp chainSyncQ = do | ||
stash <- atomically newTQueue |
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 could maybe be called "responseBuffer"
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.
done in: 0446953 👍
Yes, having the buffering done in the network clients is awkward and it seems more and more suggesting that a push approach would be better suited. Johannes also suggested that a few times; I am still worried about the amount of work this would require on both cardano-node + jormungandr :/ |
Yes, in particular, the behavior on roll backs is non trivial :( |
bors r+ |
1665: Pipeline requests near the chain tip too, with care r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1650 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 0a90f23 📍 **Pipeline requests near the chain tip too, with care** This is a bit tricky because, as soon as we enter the `tip - k` area, any 'RequestNext' may yield a 'RollBackward'. The strategy is however quite simple and boils down to two cases: - Either we have to rollback within blocks we have just collected but not yet sent for processing. - Either, we have to rollback beyond this. In the former case, we can simply discard blocks from what we have collected and continue as normal. In the latter, we have to forward the rollback requests to the wallet engine, but we have to keep on collecting the results for the requests we have already pipelined! We do so by stashing the results in a queue, so that they'd be available for the next 'RequestNext' command from the wallet. This effectively extend pipelining up to the point where we have caught up with the tip and start collecting requests one by one, in a calmly manner. This is visible from the logs: ``` ... Applying blocks [192.13732 ... 192.14731] Applying blocks [192.14732 ... 192.15731] Applying blocks [192.15732 ... 192.15977] Applying blocks [192.15978 ... 192.15978] Applying blocks [192.15979 ... 192.15979] Applying blocks [192.15980 ... 192.15980] ``` # Comments <!-- Additional comments or screenshots to attach if any --> This should fix #1650 <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]> Co-authored-by: IOHK <[email protected]>
Timed out |
Weird, the build succeeded but somehow bors never reported to github. https://buildkite.com/input-output-hk/cardano-wallet/builds/7548 |
Issue Number
#1650
Overview
0a90f23
📍 Pipeline requests near the chain tip too, with care
This is a bit tricky because, as soon as we enter the
tip - k
area,any 'RequestNext' may yield a 'RollBackward'. The strategy is however
quite simple and boils down to two cases:
Either we have to rollback within blocks we have just collected but
not yet sent for processing.
Either, we have to rollback beyond this.
In the former case, we can simply discard blocks from what we have
collected and continue as normal. In the latter, we have to forward
the rollback requests to the wallet engine, but we have to keep on
collecting the results for the requests we have already pipelined!
We do so by stashing the results in a queue, so that they'd be
available for the next 'RequestNext' command from the wallet.
This effectively extend pipelining up to the point where we have
caught up with the tip and start collecting requests one by one, in a
calmly manner. This is visible from the logs:
Comments
This should fix #1650