From 076df48948f4099f271c02f14763f426f40e7e1c Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Fri, 27 Sep 2024 18:25:11 +0100 Subject: [PATCH] Removing use_noops from write_queue. --- nano/core_test/confirming_set.cpp | 2 -- nano/core_test/ledger_confirm.cpp | 4 ++-- nano/node/make_store.cpp | 4 ++-- nano/node/make_store.hpp | 2 +- nano/node/node.cpp | 2 +- nano/node/nodeconfig.hpp | 1 - nano/slow_test/node.cpp | 4 ++-- nano/store/component.cpp | 3 +-- nano/store/component.hpp | 3 +-- nano/store/lmdb/lmdb.cpp | 3 +-- nano/store/rocksdb/rocksdb.cpp | 5 ++--- nano/store/rocksdb/rocksdb.hpp | 2 +- nano/store/write_queue.cpp | 15 ++------------- nano/store/write_queue.hpp | 4 +--- 14 files changed, 17 insertions(+), 37 deletions(-) diff --git a/nano/core_test/confirming_set.cpp b/nano/core_test/confirming_set.cpp index 47b8eaf7e..905bf523a 100644 --- a/nano/core_test/confirming_set.cpp +++ b/nano/core_test/confirming_set.cpp @@ -119,7 +119,6 @@ TEST (confirmation_callback, confirmed_history) { nano::test::system system; nano::node_flags node_flags; - node_flags.force_use_write_queue = true; node_flags.disable_ascending_bootstrap = true; nano::node_config node_config = system.default_config (); node_config.backlog_population.enable = false; @@ -194,7 +193,6 @@ TEST (confirmation_callback, dependent_election) { nano::test::system system; nano::node_flags node_flags; - node_flags.force_use_write_queue = true; nano::node_config node_config = system.default_config (); node_config.backlog_population.enable = false; auto node = system.add_node (node_config, node_flags); diff --git a/nano/core_test/ledger_confirm.cpp b/nano/core_test/ledger_confirm.cpp index 65f351bac..360a3512b 100644 --- a/nano/core_test/ledger_confirm.cpp +++ b/nano/core_test/ledger_confirm.cpp @@ -784,7 +784,7 @@ TEST (ledger_confirm, pruned_source) ASSERT_TRUE (!store->init_error ()); nano::ledger ledger (*store, system.stats, nano::dev::constants); ledger.pruning = true; - nano::store::write_queue write_queue (false); + nano::store::write_queue write_queue; nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; nano::keypair key1, key2; nano::block_builder builder; @@ -868,7 +868,7 @@ TEST (ledger_confirmDeathTest, rollback_added_block) auto store = nano::make_store (system.logger, path, nano::dev::constants); ASSERT_TRUE (!store->init_error ()); nano::ledger ledger (*store, system.stats, nano::dev::constants); - nano::store::write_queue write_queue (false); + nano::store::write_queue write_queue; nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; nano::keypair key1; nano::block_builder builder; diff --git a/nano/node/make_store.cpp b/nano/node/make_store.cpp index 9122a23d0..87c15700f 100644 --- a/nano/node/make_store.cpp +++ b/nano/node/make_store.cpp @@ -3,11 +3,11 @@ #include #include -std::unique_ptr nano::make_store (nano::logger & logger, std::filesystem::path const & path, nano::ledger_constants & constants, bool read_only, bool add_db_postfix, nano::rocksdb_config const & rocksdb_config, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade, bool force_use_write_queue) +std::unique_ptr nano::make_store (nano::logger & logger, std::filesystem::path const & path, nano::ledger_constants & constants, bool read_only, bool add_db_postfix, nano::rocksdb_config const & rocksdb_config, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, nano::lmdb_config const & lmdb_config_a, bool backup_before_upgrade) { if (rocksdb_config.enable) { - return std::make_unique (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only, force_use_write_queue); + return std::make_unique (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only); } return std::make_unique (logger, add_db_postfix ? path / "data.ldb" : path, constants, txn_tracking_config_a, block_processor_batch_max_time_a, lmdb_config_a, backup_before_upgrade); diff --git a/nano/node/make_store.hpp b/nano/node/make_store.hpp index d66db5cbf..5f5b5f937 100644 --- a/nano/node/make_store.hpp +++ b/nano/node/make_store.hpp @@ -22,5 +22,5 @@ class component; namespace nano { -std::unique_ptr make_store (nano::logger &, std::filesystem::path const & path, nano::ledger_constants & constants, bool open_read_only = false, bool add_db_postfix = true, nano::rocksdb_config const & rocksdb_config = nano::rocksdb_config{}, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false, bool force_use_write_queue = false); +std::unique_ptr make_store (nano::logger &, std::filesystem::path const & path, nano::ledger_constants & constants, bool open_read_only = false, bool add_db_postfix = true, nano::rocksdb_config const & rocksdb_config = nano::rocksdb_config{}, nano::txn_tracking_config const & txn_tracking_config_a = nano::txn_tracking_config{}, std::chrono::milliseconds block_processor_batch_max_time_a = std::chrono::milliseconds (5000), nano::lmdb_config const & lmdb_config_a = nano::lmdb_config{}, bool backup_before_upgrade = false); } diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 46519b080..9a3b35e2c 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -83,7 +83,7 @@ nano::node::node (std::shared_ptr io_ctx_a, std::filesy flags (flags_a), work (work_a), distributed_work (*this), - store_impl (nano::make_store (logger, application_path_a, network_params.ledger, flags.read_only, true, config_a.rocksdb_config, config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_config, config_a.backup_before_upgrade, flags.force_use_write_queue)), + store_impl (nano::make_store (logger, application_path_a, network_params.ledger, flags.read_only, true, config_a.rocksdb_config, config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_config, config_a.backup_before_upgrade)), store (*store_impl), unchecked{ config.max_unchecked_blocks, stats, flags.disable_block_processor_unchecked_deletion }, wallets_store_impl (std::make_unique (application_path_a / "wallets.ldb", config_a.lmdb_config)), diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 6f9ec2d80..8981ccf87 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -182,7 +182,6 @@ public: bool allow_bootstrap_peers_duplicates{ false }; bool disable_max_peers_per_ip{ false }; // For testing only bool disable_max_peers_per_subnetwork{ false }; // For testing only - bool force_use_write_queue{ false }; // For testing only. RocksDB does not use the database queue, but some tests rely on it being used. bool disable_search_pending{ false }; // For testing only bool enable_pruning{ false }; bool fast_bootstrap{ false }; diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index 09c2f22fb..d5e168c88 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -1139,13 +1139,13 @@ TEST (confirmation_height, many_accounts_send_receive_self_no_elections) ASSERT_TRUE (!store->init_error ()); nano::stats stats{ logger }; nano::ledger ledger (*store, stats, nano::dev::constants); - nano::store::write_queue write_database_queue (false); + nano::store::write_queue write_database_queue; nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits::max () }; std::atomic stopped{ false }; boost::latch initialized_latch{ 0 }; nano::block_hash block_hash_being_processed{ 0 }; - nano::store::write_queue write_queue{ false }; + nano::store::write_queue write_queue; nano::confirming_set_config confirming_set_config{}; nano::confirming_set confirming_set{ confirming_set_config, ledger, stats }; diff --git a/nano/store/component.cpp b/nano/store/component.cpp index 815f3e595..5d8c8bec2 100644 --- a/nano/store/component.cpp +++ b/nano/store/component.cpp @@ -7,7 +7,7 @@ #include #include -nano::store::component::component (nano::store::block & block_store_a, nano::store::account & account_store_a, nano::store::pending & pending_store_a, nano::store::online_weight & online_weight_store_a, nano::store::pruned & pruned_store_a, nano::store::peer & peer_store_a, nano::store::confirmation_height & confirmation_height_store_a, nano::store::final_vote & final_vote_store_a, nano::store::version & version_store_a, nano::store::rep_weight & rep_weight_a, bool use_noops_a) : +nano::store::component::component (nano::store::block & block_store_a, nano::store::account & account_store_a, nano::store::pending & pending_store_a, nano::store::online_weight & online_weight_store_a, nano::store::pruned & pruned_store_a, nano::store::peer & peer_store_a, nano::store::confirmation_height & confirmation_height_store_a, nano::store::final_vote & final_vote_store_a, nano::store::version & version_store_a, nano::store::rep_weight & rep_weight_a) : block (block_store_a), account (account_store_a), pending (pending_store_a), @@ -17,7 +17,6 @@ nano::store::component::component (nano::store::block & block_store_a, nano::sto confirmation_height (confirmation_height_store_a), final_vote (final_vote_store_a), version (version_store_a), - write_queue (use_noops_a), rep_weight (rep_weight_a) { } diff --git a/nano/store/component.hpp b/nano/store/component.hpp index a64ae1a60..e85de20aa 100644 --- a/nano/store/component.hpp +++ b/nano/store/component.hpp @@ -53,8 +53,7 @@ namespace store nano::store::confirmation_height &, nano::store::final_vote &, nano::store::version &, - nano::store::rep_weight &, - bool use_noops_a + nano::store::rep_weight & ); // clang-format on virtual ~component () = default; diff --git a/nano/store/lmdb/lmdb.cpp b/nano/store/lmdb/lmdb.cpp index a2fbb618e..b9bc04721 100644 --- a/nano/store/lmdb/lmdb.cpp +++ b/nano/store/lmdb/lmdb.cpp @@ -26,8 +26,7 @@ nano::store::lmdb::component::component (nano::logger & logger_a, std::filesyste confirmation_height_store, final_vote_store, version_store, - rep_weight_store, - false // write_queue use_noops + rep_weight_store }, // clang-format on block_store{ *this }, diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index 439cb92db..c16c6f57d 100644 --- a/nano/store/rocksdb/rocksdb.cpp +++ b/nano/store/rocksdb/rocksdb.cpp @@ -35,7 +35,7 @@ private: }; } -nano::store::rocksdb::component::component (nano::logger & logger_a, std::filesystem::path const & path_a, nano::ledger_constants & constants, nano::rocksdb_config const & rocksdb_config_a, bool open_read_only_a, bool force_use_write_queue) : +nano::store::rocksdb::component::component (nano::logger & logger_a, std::filesystem::path const & path_a, nano::ledger_constants & constants, nano::rocksdb_config const & rocksdb_config_a, bool open_read_only_a) : // clang-format off nano::store::component{ block_store, @@ -47,8 +47,7 @@ nano::store::rocksdb::component::component (nano::logger & logger_a, std::filesy confirmation_height_store, final_vote_store, version_store, - rep_weight_store, - !force_use_write_queue // write_queue use_noops + rep_weight_store }, // clang-format on block_store{ *this }, diff --git a/nano/store/rocksdb/rocksdb.hpp b/nano/store/rocksdb/rocksdb.hpp index e106931c3..fe197536e 100644 --- a/nano/store/rocksdb/rocksdb.hpp +++ b/nano/store/rocksdb/rocksdb.hpp @@ -64,7 +64,7 @@ public: friend class nano::store::rocksdb::version; friend class nano::store::rocksdb::rep_weight; - explicit component (nano::logger &, std::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false, bool force_use_write_queue = false); + explicit component (nano::logger &, std::filesystem::path const &, nano::ledger_constants & constants, nano::rocksdb_config const & = nano::rocksdb_config{}, bool open_read_only = false); store::write_transaction tx_begin_write (std::vector const & tables_requiring_lock = {}, std::vector const & tables_no_lock = {}) override; store::read_transaction tx_begin_read () const override; diff --git a/nano/store/write_queue.cpp b/nano/store/write_queue.cpp index 154a62cee..41b687ce7 100644 --- a/nano/store/write_queue.cpp +++ b/nano/store/write_queue.cpp @@ -54,8 +54,7 @@ void nano::store::write_guard::renew () * write_queue */ -nano::store::write_queue::write_queue (bool use_noops_a) : - use_noops{ use_noops_a } +nano::store::write_queue::write_queue () { } @@ -66,7 +65,6 @@ nano::store::write_guard nano::store::write_queue::wait (writer writer) bool nano::store::write_queue::contains (writer writer) const { - debug_assert (!use_noops); nano::lock_guard guard{ mutex }; return std::find (queue.cbegin (), queue.cend (), writer) != queue.cend (); } @@ -83,11 +81,6 @@ void nano::store::write_queue::pop () void nano::store::write_queue::acquire (writer writer) { - if (use_noops) - { - return; // Pass immediately - } - nano::unique_lock lock{ mutex }; // There should be no duplicates in the queue @@ -105,10 +98,6 @@ void nano::store::write_queue::acquire (writer writer) void nano::store::write_queue::release (writer writer) { - if (use_noops) - { - return; // Pass immediately - } { nano::lock_guard guard{ mutex }; release_assert (!queue.empty ()); @@ -116,4 +105,4 @@ void nano::store::write_queue::release (writer writer) queue.pop_front (); } condition.notify_all (); -} \ No newline at end of file +} diff --git a/nano/store/write_queue.hpp b/nano/store/write_queue.hpp index e4f1fdc69..6b4688618 100644 --- a/nano/store/write_queue.hpp +++ b/nano/store/write_queue.hpp @@ -54,7 +54,7 @@ class write_queue final friend class write_guard; public: - explicit write_queue (bool use_noops); + explicit write_queue (); /** Blocks until we are at the head of the queue and blocks other waiters until write_guard goes out of scope */ [[nodiscard ("write_guard blocks other waiters")]] write_guard wait (writer writer); @@ -70,8 +70,6 @@ private: void release (writer writer); private: - bool const use_noops; - std::deque queue; mutable nano::mutex mutex; nano::condition_variable condition;