Skip to content

Commit 1016491

Browse files
committed
Merge bitcoin/bitcoin#30122: bench: enable wallet creation benchmarks on all platforms
7c8abf3 bench: bugfix, properly release wallet before erasing directory (furszy) Pull request description: 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. ACKs for top commit: maflcko: utACK 7c8abf3 kevkevinpal: utACK [7c8abf3](bitcoin/bitcoin@7c8abf3) hebasto: re-ACK 7c8abf3, I agree with changes since my recent [review](bitcoin/bitcoin#30122 (review)). Tree-SHA512: 279df65bea8f7aa02af0a2efed62dca9bf9b29cb748eb369c602d223e08a8a907dea7b1bffbd3dab91b1656c1d91b18a9a0534bc3f153bd751414b0e6230b3a4
2 parents 46d3477 + 7c8abf3 commit 1016491

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/bench/wallet_create.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,25 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
3434
bilingual_str error_string;
3535
std::vector<bilingual_str> warnings;
3636

37-
fs::path wallet_path = test_setup->m_path_root / strprintf("test_wallet_%d", random.rand32()).c_str();
37+
auto wallet_path = fs::PathToString(test_setup->m_path_root / "test_wallet");
3838
bench.run([&] {
39-
auto wallet = CreateWallet(context, wallet_path.utf8string(), /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
39+
auto wallet = CreateWallet(context, wallet_path, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
4040
assert(status == DatabaseStatus::SUCCESS);
4141
assert(wallet != nullptr);
4242

43-
// Cleanup
44-
wallet.reset();
43+
// Release wallet
44+
RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
45+
UnloadWallet(std::move(wallet));
4546
fs::remove_all(wallet_path);
4647
});
4748
}
4849

4950
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
5051
static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }
5152

52-
#ifndef _MSC_VER
53-
// TODO: Being built with MSVC, the fs::remove_all() call in
54-
// the WalletCreate() fails with the error "The process cannot
55-
// access the file because it is being used by another process."
5653
#ifdef USE_SQLITE
5754
BENCHMARK(WalletCreatePlain, benchmark::PriorityLevel::LOW);
5855
BENCHMARK(WalletCreateEncrypted, benchmark::PriorityLevel::LOW);
5956
#endif
60-
#endif
6157

6258
} // namespace wallet

0 commit comments

Comments
 (0)