Removing use_noops from write_queue.

This commit is contained in:
Colin LeMahieu 2024-09-27 18:25:11 +01:00
commit 076df48948
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
14 changed files with 17 additions and 37 deletions

View file

@ -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);

View file

@ -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<unsigned>::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<unsigned>::max () };
nano::keypair key1;
nano::block_builder builder;

View file

@ -3,11 +3,11 @@
#include <nano/store/lmdb/lmdb.hpp>
#include <nano/store/rocksdb/rocksdb.hpp>
std::unique_ptr<nano::store::component> 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::store::component> 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<nano::store::rocksdb::component> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only, force_use_write_queue);
return std::make_unique<nano::store::rocksdb::component> (logger, add_db_postfix ? path / "rocksdb" : path, constants, rocksdb_config, read_only);
}
return std::make_unique<nano::store::lmdb::component> (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);

View file

@ -22,5 +22,5 @@ class component;
namespace nano
{
std::unique_ptr<nano::store::component> 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<nano::store::component> 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);
}

View file

@ -83,7 +83,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> 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<nano::mdb_wallets_store> (application_path_a / "wallets.ldb", config_a.lmdb_config)),

View file

@ -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 };

View file

@ -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<unsigned>::max () };
std::atomic<bool> 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 };

View file

@ -7,7 +7,7 @@
#include <nano/store/confirmation_height.hpp>
#include <nano/store/rep_weight.hpp>
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)
{
}

View file

@ -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;

View file

@ -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 },

View file

@ -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 },

View file

@ -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<nano::tables> const & tables_requiring_lock = {}, std::vector<nano::tables> const & tables_no_lock = {}) override;
store::read_transaction tx_begin_read () const override;

View file

@ -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<nano::mutex> 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<nano::mutex> 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<nano::mutex> guard{ mutex };
release_assert (!queue.empty ());
@ -116,4 +105,4 @@ void nano::store::write_queue::release (writer writer)
queue.pop_front ();
}
condition.notify_all ();
}
}

View file

@ -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<writer> queue;
mutable nano::mutex mutex;
nano::condition_variable condition;