-
Notifications
You must be signed in to change notification settings - Fork 37.7k
bench: add benchmark for wallet 'AvailableCoins' function. #25234
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
bench: add benchmark for wallet 'AvailableCoins' function. #25234
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
Concept ACK on benchmarking these, however there have been recent complaints that the benchmarks are slow, and I've noticed these add more fairly slow to run benchmarks:
E.g. a total of 94 seconds to the runtime of |
Thanks laanwj for the review! It's interesting to see other results, locally this are my results:
But let me do something, going to decrease the bench number of iterations from 5 to 2. It should decrease the total time by half. |
ca8ef4c
to
4029293
Compare
Done, decreased the number of iterations to 2. And this are the results:
Total time: ~15 seconds to run the 5 new benchmarks at most here now. |
Aside from that, I think that a good future question to ask ourselves would be whether we want to always run all the benchmarks all the time or not. Because, sooner or later, as the project isn't going to stop growing, we could end up sacrificing accuracy, implementing not entirely real scenarios (skipping parts of the flow that is being benchmarked) in favor of decreasing the total bench time (there is where my comment in #24924 (review) heads to for example). But well, this is just me thinking out loud.. after #24924, the total bench time will be pretty decent to not have to worry about this for a while. |
src/bench/wallet_available_coins.cpp
Outdated
static void WalletAvailableCoinsOnlyBech32M(benchmark::Bench& bench) { WalletAvailableCoins(bench, {OutputType::BECH32M}); } | ||
static void WalletAvailableCoinsOnlyBech32(benchmark::Bench& bench) { WalletAvailableCoins(bench, {OutputType::BECH32}); } | ||
static void WalletAvailableCoinsOnlyP2SH_SEGWIT(benchmark::Bench& bench) { WalletAvailableCoins(bench, {OutputType::P2SH_SEGWIT}); } | ||
static void WalletAvailableCoinsOnlyLegacy(benchmark::Bench& bench) { WalletAvailableCoins(bench, {OutputType::LEGACY}); } | ||
static void WalletAvailableCoinsMulti(benchmark::Bench& bench) { WalletAvailableCoins(bench, {OutputType::LEGACY, OutputType::BECH32M, OutputType::BECH32, OutputType::P2SH_SEGWIT}); } | ||
|
||
BENCHMARK(WalletAvailableCoinsOnlyBech32M); | ||
BENCHMARK(WalletAvailableCoinsOnlyBech32); | ||
BENCHMARK(WalletAvailableCoinsOnlyP2SH_SEGWIT); | ||
BENCHMARK(WalletAvailableCoinsOnlyLegacy); | ||
BENCHMARK(WalletAvailableCoinsMulti); |
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.
In b791c2a "bench: add benchmark for wallet 'AvailableCoins' function."
I don't really think it is useful to have AvailableCoins
run for different OutputTypes
. There really isn't any difference for how AvailableCoins
behaves depending on the OutputType
.
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.
Hmm, wouldn't we be having the same benchmark times for all the cases if that would be the case? (we are adding the same amount of txs and outputs to each of them).
I mean, your #24699 improves exactly this. The time difference there is for the solving provider and IsMine
related calls.
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, it should be the same benchmark times for all cases, so it doesn't make sense to run it separately for each OutputType
.
4029293
to
fd583c8
Compare
Note: haven't updated this PR because a similar benchmark is introduced in #25685. So, once/if that one gets merged, will rebase this work on top. The amount of changes here will be pretty small. |
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 can see you also introduced that idea and the improvement is already merged and available; good stuff! |
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.
Code review ACK.
I've verified most changes were already merged on #25685, waiting for your next commit to re ACK this PR again.
yeah, will rebase + rearrange it in the coming days. Thanks for the ping 👍🏼 . |
fd583c8
to
b2ec705
Compare
b2ec705
to
3a4f8bc
Compare
ACK 3a4f8bc |
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.
ACK 3a4f8bc
This is my output :
|
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.
tested ACK.
Here my results:
|--------------------:|--------------------:|--------:|----------:|:----------
| 20,730,690.00 | 48.24 | 3.8% | 0.47 | `WalletAvailableCoins`
From time to time I get recommendations to increase the iters as it warns unstability:
|--------------------:|--------------------:|--------:|----------:|:----------
| 20,150,356.50 | 49.63 | 5.3% | 0.48 | :wavy_dash: `WalletAvailableCoins` (Unstable with ~2.0 iters. Increase `minEpochIterations` to e.g. 20)
Not sure if this could be an issue.
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.
ACK 3a4f8bc
BENCHMARK(WalletCreateTxUseOnlyPresetInputs, benchmark::PriorityLevel::LOW) | ||
BENCHMARK(WalletCreateTxUsePresetInputsAndCoinSelection, benchmark::PriorityLevel::LOW) | ||
BENCHMARK(WalletAvailableCoins, benchmark::PriorityLevel::LOW); |
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.
nit: missing new line
… function. 3a4f8bc bench: add benchmark for wallet 'AvailableCoins' function. (furszy) Pull request description: #### Rationale `AvailableCoins` is part of several important flows for the wallet; from RPC commands that create transactions like `fundrawtransaction`, `send`, `walletcreatefundedpsbt`, get the available balance, list the available coins with `listunspent` etc. to GUI connected processes that perform the same or similar actions: tx creation, available balance calculation, present the spendable coins in the coin control dialog. As we are improving this process in bitcoin#24699, bitcoin#25005 and there are more structural changes coming on the way. This benchmark aims to ensure us that, at least, there are no regressions (obviously performance improvements are great but, at least for me, this heads into the direction of having a base metric to compare future structural changes). #### Implementation Notes There are 5 new benchmarks, one per wallet supported output type (LEGACY, P2SH_SEGWIT, BECH32, BECH32M), plus a multi-output-type wallet benchmark which contains outputs from all the descriptor types. The test, by default, fills-up the wallet with 1k transactions, 2k outputs. Mainly to not consume much time if the user just want to verify that no substantial regressions were introduced. But, my expectation for those who are focused on this process is to use a much higher number locally to really note the differences across commits. ACKs for top commit: achow101: ACK 3a4f8bc hernanmarino: ACK 3a4f8bc aureleoules: ACK 3a4f8bc Tree-SHA512: d0bb4c165f1efa181b47cb31561e6217eff9135bcd1b6761a7292f9018e456d13d18a1b886c2e2268d35c52f9e1fd8e0f252972424e5c5f00c280620b79c5a1b
Rationale
AvailableCoins
is part of several important flows for the wallet; from RPC commands that create transactions likefundrawtransaction
,send
,walletcreatefundedpsbt
, get the available balance, list the available coins withlistunspent
etc. to GUI connected processes that perform the same or similar actions: tx creation, available balance calculation, present the spendable coins in the coin control dialog.As we are improving this process in #24699, #25005 and there are more structural changes coming on the way. This benchmark aims to ensure us that, at least, there are no regressions (obviously performance improvements are great but, at least for me, this heads into the direction of having a base metric to compare future structural changes).
Implementation Notes
There are 5 new benchmarks, one per wallet supported output type (LEGACY, P2SH_SEGWIT, BECH32, BECH32M), plus a multi-output-type wallet benchmark which contains outputs from all the descriptor types.
The test, by default, fills-up the wallet with 1k transactions, 2k outputs. Mainly to not consume much time if the user just want to verify that no substantial regressions were introduced. But, my expectation for those who are focused on this process is to use a much higher number locally to really note the differences across commits.