Skip to content

bench: enable wallet creation benchmarks on all platforms - #30122

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
furszy:2024_bench_enable_wallet_create
May 29, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
furszy:2024_bench_enable_wallet_create

Conversation

@furszy

@furszy furszy commented May 16, 2024 •

Copy link
Copy Markdown
Member

Simple fix for #29816.

Since the wallet is appended to the global WalletContext during
creation, merely calling reset() on the benchmark shared_pointer
is insufficient to destruct the wallet. This no destruction of the
wallet object results in keeping the db connection open, which
was causes the fs::remove_all() failure on Windows.

@DrahtBot

DrahtBot commented May 16, 2024 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK maflcko, hebasto, kevkevinpal

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@fanquake

Copy link
Copy Markdown
Member

The native Windows CI (https://github.com/bitcoin/bitcoin/actions/runs/9112695910/job/25052498545?pr=30122#step:24:64) is failing with:

Run src\bench_bitcoin.exe -sanity-check
Running with -sanity-check option, output is being suppressed as benchmark results will be useless.
Error: Process completed with exit code 1.

@furszy
furszy force-pushed the 2024_bench_enable_wallet_create branch from 815f502 to fe5cdbf Compare May 16, 2024 13:47
@fanquake

Copy link
Copy Markdown
Member

It'd be good if the commit message could explain why this is being done. It seems like the current approach is just to try and refactor away the Windows bug, even though it might not have been properly identified (prior to #29816 (comment)). However now that the bug might have been found, it'd be good to at least document what it is, and if possible, fix/workaround it in a more targetted way, rather than refactor code that is currently perfectly fine for all other platforms.

@furszy

furszy commented May 16, 2024

Copy link
Copy Markdown
Member Author

It'd be good if the commit message could explain why this is being done. It seems like the current approach is just to try and refactor away the Windows bug, even though it might not have been properly identified (prior to #29816 (comment)). However now that the bug might have been found, it'd be good to at least document what it is, and if possible, fix/workaround it in a more targetted way, rather than refactor code that is currently perfectly fine for all other platforms.

Sure with a small nuance. This code is working fine for all other platforms but that does not mean the code is perfect.
When I wrote this benchmark, I was probably more concerned about the number of files the benchmark could open in parallel than the delays/inaccuracies introduced by the, OS dependent, directory removal line. Essentially, we shouldn't be removing a directory within the benchmarked code scope.
But yeah, np on splitting this in two well described commits.

@furszy
furszy force-pushed the 2024_bench_enable_wallet_create branch from fe5cdbf to 7323bf6 Compare May 16, 2024 14:51
@hebasto

hebasto commented May 16, 2024

Copy link
Copy Markdown
Member

Concept ACK.

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 7323bf6a2ecc3a2f1e2fdebce53b961767b06e08.

Maybe deduplicate code:

--- a/src/bench/wallet_create.cpp
+++ b/src/bench/wallet_create.cpp
@@ -35,8 +35,8 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
     std::vector<bilingual_str> warnings;
 
     int round = 0;
-    fs::path wallet_path = test_setup->m_path_root / strprintf("test_wallet%d_%d", round, random.rand32()).c_str();
     bench.run([&] {
+        auto wallet_path = test_setup->m_path_root / strprintf("test_wallet%d_%d", round++, random.rand32()).c_str();
         auto wallet = CreateWallet(context, wallet_path.utf8string(), /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
         assert(status == DatabaseStatus::SUCCESS);
         assert(wallet != nullptr);
@@ -44,7 +44,6 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
         // Unload wallet and update wallet directory for the next round
         RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
         UnloadWallet(std::move(wallet));
-        wallet_path = test_setup->m_path_root / strprintf("test_wallet%d_%d", ++round, random.rand32()).c_str();
     });
 }
 

?

@furszy
furszy force-pushed the 2024_bench_enable_wallet_create branch from 7323bf6 to b6b2d82 Compare May 16, 2024 16:22
@furszy

furszy commented May 16, 2024

Copy link
Copy Markdown
Member Author

Applied, thanks @hebasto 👍🏼.

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK b6b2d822eb06d705e6ec4318211163e5862008a6.

Comment thread src/bench/wallet_create.cpp Resolved
Comment thread src/bench/wallet_create.cpp Resolved
Comment thread src/bench/wallet_create.cpp Resolved
@furszy
furszy force-pushed the 2024_bench_enable_wallet_create branch from b6b2d82 to 7e30fda Compare May 17, 2024 15:45

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 7e30fdaa8fd7cc572505b7eac1b25f4ebe3b5443

Comment thread src/bench/wallet_create.cpp Resolved
@DrahtBot
DrahtBot requested a review from hebasto May 17, 2024 15:47
Since the wallet is appended to the global WalletContext during
creation, merely calling 'reset()' on the benchmark shared_pointer
is insufficient to destruct the wallet. This no destruction of the
wallet results in the db connection remaining open, which was the
cause of the 'fs::remove_all()' error in Windows.

Co-Authored-By: Hennadii Stepanov <[email protected]>
@furszy
furszy force-pushed the 2024_bench_enable_wallet_create branch from 7e30fda to 7c8abf3 Compare May 17, 2024 15:50
@maflcko

maflcko commented May 17, 2024

Copy link
Copy Markdown
Member

utACK 7c8abf3

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 7c8abf3, I agree with changes since my recent review.

@kevkevinpal

Copy link
Copy Markdown
Contributor

utACK 7c8abf3

@fanquake
fanquake merged commit 1016491 into bitcoin:master May 29, 2024
@bitcoin bitcoin locked and limited conversation to collaborators May 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants