Repository navigation
p2p: cache compact block message to use for low bandwidth CMPCT_BLOCK - #26755
andrewtoth wants to merge 2 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
ad6afcb to
7aa57d7
Compare
7aa57d7 to
6947ca3
Compare
| )}; | ||
|
|
||
| bench.run([&] { | ||
| CSerializedNetMsg msg{lazy_ser.get().Copy()}; |
There was a problem hiding this comment.
Not sure how useful this is. Won't this massively elevate the duration of the first call compared to all following ones?
The speed-up I reported in #23880 (comment) is obviously dependent on the number of peers you send the message to. If there is only one peer, it will be slower, because the duration is Ser+Copy*1, which is more work than just Ser*1. However with sufficient peers N, there is a speed-up because Ser+Copy*N is faster than Ser*N.
There was a problem hiding this comment.
Hmm I suppose a better benchmark would be time it takes to copy to see what N needs to be for this optimization to make sense. I was making the assumption here that Copy is always faster than Ser, so if there's at least one high bandwidth peer we relayed too already then it makes sense to just Copy for any low bandwidth requests that come in rather than Ser.
There was a problem hiding this comment.
I think the confusion is that this PR was changing the first low bandwidth response to use a lazy serializer and copy. This is actually using a copy of the same lazy future that is used for the high bandwidth peers. So as long as there's at least one high bandwidth peer then this optimization makes sense because the serialization will already have been done.
|
Benefit doesn't seem to be worth the change here. |
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]
This commit is drawn from the closed bitcoin#26755. (bitcoin#26755) This also changes `std::launch::deferred` to `std::launch::async` since we are likely going to use this result very soon if someone has requested HB blocks from us, and if no one has, then performance here is not that critical. Co-authored-by: Andrew Toth <[email protected]>
Follow-up from #23880 (comment).
This stores the lazy serialized compact block message future for the last seen block, rather than a shared pointer to the compact block itself. Then we don't have to reserialize the message for any incoming CMPCTBLOCK messages from low-bandwidth peers.
It was mentioned there was a speed savings of 25% using this method for sending to high-bandwidth peers #23880 (comment). I've included benchmarks which seems to be an even higher speedup.
SerializeNetMsgCacheSerializeNetMsg