-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: Fix bug in transaction generation in ComplexMempool benchmark #22856
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
Conversation
f65b92f to
8ae1334
Compare
|
Please modify the commit message to actually explain the changes. |
src/bench/mempool_stress.cpp
Outdated
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.
can use available_coins.back() here too.
fe3d95f to
b3f89cc
Compare
Available in line 59 is made a reference , so contents of the coin can be modified While generating transactions we select ancestors from available_coins ,in case we exhaust all the outputs of an entry in available_coins then we need to remove it from available_coins before the next iteration of choosing a potential ancestor , it is now implemented with this patch by ,As the index of the entry is randomly chosen from available_coins , In order to remove it from the vector if index of the selected entry is not at the end of available_coins vector, it is swapped with the entry at the back of the vector , then the entry at the end of available_coins is popped out. Code generating outputs for the transaction is moved out of the loop, as it needs to be done only once before adding the transaction to ordered_coins
b3f89cc to
29e9833
Compare
theStack
left a comment
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.
Concept ACK
If I understand correctly, this PR actually contains two bug fixes (remove correct element from available_coins, make modification to available_coins[idx] effective by declaring coin as reference) and one performance improvement?
Would maybe be worth splitting up into two commits. Also the commit body looks a bit messy currently (too long lines, confusing interpunction, grammar). In the course of doing that, a rebase on master couldn't hurt -- I am actually surprised that there is no merge conflict, since #23157 generalized the CreateOrderedCoins helper function.
|
i'm not sure if @shoryak is still watching bitcoin core stuff since the semester is quite busy and this was a SoB project... i think it'd be fine to merge as is? |
|
That's a valid reason to no longer work on it, but "author doesn't have time" is not a valid reason for something to be merged while ignoring reviewer comments. Normally we'd close and label "up for grabs". But in this particular case, yes, it's probably fine like this. @theStack do you agree? |
|
@laanwj: My concerns were mainly considering aesthetics (commit message formatting etc.), but the code change itself looks correct to me, so yes, I agree 👍 |
|
@theStack I would be happy to make any changes in the formatting of the commit message, though I prefer it to be just a single commit rather than two. |
|
| Available& coin = available_coins[idx]; | ||
| uint256 hash = coin.ref->GetHash(); | ||
| // biased towards taking just one ancestor, but maybe more | ||
| size_t n_to_take = det_rand.randrange(2) == 0 ? 1 : 1+det_rand.randrange(coin.ref->vout.size() - coin.vin_left); |
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.
bench/mempool_stress.cpp:59:89: runtime error: unsigned integer overflow: 9 - 11 cannot be represented in type 'unsigned long'
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've reverted the merge in commit 95fe477 again due to this
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.
interesting -- why was it passing here but not on master?
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.
we changed from clang-12 to clang-13, maybe?
…exMempool benchmark 29e9833 Fixes Bug in Transaction generation in ComplexMempool benchmark (Shorya) Pull request description: This fixes issues with `ComplexMempool` benchmark introduced in [bitcoin#17292](bitcoin#17292) , this stress test benchmarks performance of ancestor and descendant tracking of mempool graph algorithms on a complex Mempool. This Benchmark first creates 100 base transactions and stores them in `available_coins` vector. `available_coins` is used for selecting ancestor transactions while creating 800 new transactions. For this a random transaction is picked from `available_coins` and some of its outputs are mapped to the inputs of the new transaction being created. Now in case we exhaust all the outputs of an entry in `available_coins` then we need to remove it from `available_coins` before the next iteration of choosing a potential ancestor , it is now implemented with this patch. As the index of the entry is randomly chosen from `available_coins` , In order to remove it from the vector , if index of the selected entry is not at the end of `available_coins` vector , it is swapped with the entry at the back of the vector , then the entry at the end of `available_coins` is popped out. Earlier the code responsible for constructing outputs of the newly created transaction was inside the loop used for assigning ancestors to the transaction , which does some unnecessary work as it creates outputs of the transaction again and again , now it is moved out of the loop so outputs of the transaction are created just once before adding it to the final list of the transactions created. This one is a minor change to save some computation. These changes have changed the `ComplexMempool` benchmark results on `bitcoin:master` as follows : **Before** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 232,881,625.00 | 4.29 | 0.7% | 2.55 | `ComplexMemPool` **After** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 497,275,135.00 | 2.01 | 0.5% | 5.49 | `ComplexMemPool` Top commit has no ACKs. Tree-SHA512: d6946d7e65c55f54c84cc49d7abee52e59ffc8b7668b3c80b4ce15a57690ab00a600c6241cc71a2a075def9c30792a311256fed325ef162f37aeacd2cce93624
…in ComplexMempool benchmark 2b02e09 Fixes Bug in Transaction generation in ComplexMempool benchmark (Shorya) Pull request description: This fixes issues with `ComplexMempool` benchmark introduced in [#17292](bitcoin/bitcoin#17292) , this stress test benchmarks performance of ancestor and descendant tracking of mempool graph algorithms on a complex Mempool. This Benchmark first creates 100 base transactions and stores them in `available_coins` vector. `available_coins` is used for selecting ancestor transactions while creating 800 new transactions. For this a random transaction is picked from `available_coins` and some of its outputs are mapped to the inputs of the new transaction being created. Now in case we exhaust all the outputs of an entry in `available_coins` then we need to remove it from `available_coins` before the next iteration of choosing a potential ancestor , it is now implemented with this patch. As the index of the entry is randomly chosen from `available_coins` , In order to remove it from the vector , if index of the selected entry is not at the end of `available_coins` vector , it is swapped with the entry at the back of the vector , then the entry at the end of `available_coins` is popped out. Earlier the code responsible for constructing outputs of the newly created transaction was inside the loop used for assigning ancestors to the transaction , which does some unnecessary work as it creates outputs of the transaction again and again , now it is moved out of the loop so outputs of the transaction are created just once before adding it to the final list of the transactions created. This one is a minor change to save some computation. These changes have changed the `ComplexMempool` benchmark results on `bitcoin:master` as follows : **Before** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 232,881,625.00 | 4.29 | 0.7% | 2.55 | `ComplexMemPool` **After** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 497,275,135.00 | 2.01 | 0.5% | 5.49 | `ComplexMemPool` Top commit has no ACKs. Tree-SHA512: d6946d7e65c55f54c84cc49d7abee52e59ffc8b7668b3c80b4ce15a57690ab00a600c6241cc71a2a075def9c30792a311256fed325ef162f37aeacd2cce93624
…exMempool benchmark 29e9833 Fixes Bug in Transaction generation in ComplexMempool benchmark (Shorya) Pull request description: This fixes issues with `ComplexMempool` benchmark introduced in [bitcoin#17292](bitcoin#17292) , this stress test benchmarks performance of ancestor and descendant tracking of mempool graph algorithms on a complex Mempool. This Benchmark first creates 100 base transactions and stores them in `available_coins` vector. `available_coins` is used for selecting ancestor transactions while creating 800 new transactions. For this a random transaction is picked from `available_coins` and some of its outputs are mapped to the inputs of the new transaction being created. Now in case we exhaust all the outputs of an entry in `available_coins` then we need to remove it from `available_coins` before the next iteration of choosing a potential ancestor , it is now implemented with this patch. As the index of the entry is randomly chosen from `available_coins` , In order to remove it from the vector , if index of the selected entry is not at the end of `available_coins` vector , it is swapped with the entry at the back of the vector , then the entry at the end of `available_coins` is popped out. Earlier the code responsible for constructing outputs of the newly created transaction was inside the loop used for assigning ancestors to the transaction , which does some unnecessary work as it creates outputs of the transaction again and again , now it is moved out of the loop so outputs of the transaction are created just once before adding it to the final list of the transactions created. This one is a minor change to save some computation. These changes have changed the `ComplexMempool` benchmark results on `bitcoin:master` as follows : **Before** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 232,881,625.00 | 4.29 | 0.7% | 2.55 | `ComplexMemPool` **After** > | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 497,275,135.00 | 2.01 | 0.5% | 5.49 | `ComplexMemPool` Top commit has no ACKs. Tree-SHA512: d6946d7e65c55f54c84cc49d7abee52e59ffc8b7668b3c80b4ce15a57690ab00a600c6241cc71a2a075def9c30792a311256fed325ef162f37aeacd2cce93624
This fixes issues with
ComplexMempoolbenchmark introduced in #17292 , this stress test benchmarks performance of ancestor and descendant tracking of mempool graph algorithms on a complex Mempool.This Benchmark first creates 100 base transactions and stores them in
available_coinsvector.available_coinsis used for selecting ancestor transactions while creating 800 new transactions. For this a random transaction is picked fromavailable_coinsand some of its outputs are mapped to the inputs of the new transaction being created.Now in case we exhaust all the outputs of an entry in
available_coinsthen we need to remove it fromavailable_coinsbefore the next iteration of choosing a potential ancestor , it is now implemented with this patch.As the index of the entry is randomly chosen from
available_coins, In order to remove it from the vector , if index of the selected entry is not at the end ofavailable_coinsvector , it is swapped with the entry at the back of the vector , then the entry at the end ofavailable_coinsis popped out.Earlier the code responsible for constructing outputs of the newly created transaction was inside the loop used for assigning ancestors to the transaction , which does some unnecessary work as it creates outputs of the transaction again and again , now it is moved out of the loop so outputs of the transaction are created just once before adding it to the final list of the transactions created. This one is a minor change to save some computation.
These changes have changed the
ComplexMempoolbenchmark results onbitcoin:masteras follows :Before
ComplexMemPoolAfter
ComplexMemPool