Skip to content

Commit

Permalink
Merge bitcoin#30122: bench: enable wallet creation benchmarks on all …
Browse files Browse the repository at this point in the history
…platforms

7c8abf3 bench: bugfix, properly release wallet before erasing directory (furszy)

Pull request description:

  Simple fix for bitcoin#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@7c8abf3)
  hebasto:
    re-ACK 7c8abf3, I agree with changes since my recent [review](bitcoin#30122 (review)).

Tree-SHA512: 279df65bea8f7aa02af0a2efed62dca9bf9b29cb748eb369c602d223e08a8a907dea7b1bffbd3dab91b1656c1d91b18a9a0534bc3f153bd751414b0e6230b3a4
  • Loading branch information
fanquake committed May 29, 2024
2 parents 46d3477 + 7c8abf3 commit 1016491
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/bench/wallet_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,25 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
bilingual_str error_string;
std::vector<bilingual_str> warnings;

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

// Cleanup
wallet.reset();
// Release wallet
RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
UnloadWallet(std::move(wallet));
fs::remove_all(wallet_path);
});
}

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

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

} // namespace wallet

0 comments on commit 1016491

Please sign in to comment.