diff --git a/nano/core_test/memory_pool.cpp b/nano/core_test/memory_pool.cpp index 337269058..dff49da17 100644 --- a/nano/core_test/memory_pool.cpp +++ b/nano/core_test/memory_pool.cpp @@ -54,12 +54,12 @@ size_t get_allocated_size () TEST (memory_pool, validate_cleanup) { - nano::make_shared (true); - nano::make_shared (true); - nano::make_shared (true); - nano::make_shared (true); - nano::make_shared (true); - nano::make_shared (true); + nano::make_shared (); + nano::make_shared (); + nano::make_shared (); + nano::make_shared (); + nano::make_shared (); + nano::make_shared (); ASSERT_TRUE (nano::purge_singleton_pool_memory ()); ASSERT_TRUE (nano::purge_singleton_pool_memory ()); diff --git a/nano/core_test/message.cpp b/nano/core_test/message.cpp index 518b9bea4..1a8e62649 100644 --- a/nano/core_test/message.cpp +++ b/nano/core_test/message.cpp @@ -79,7 +79,7 @@ TEST (message, confirm_ack_serialization) nano::bufferstream stream2 (bytes.data (), bytes.size ()); bool error (false); nano::message_header header (error, stream2); - nano::confirm_ack con2 (error, stream2, header, true); + nano::confirm_ack con2 (error, stream2, header); ASSERT_FALSE (error); ASSERT_EQ (con1, con2); ASSERT_EQ (header.block_type (), nano::block_type::send); @@ -106,7 +106,7 @@ TEST (message, confirm_ack_hash_serialization) nano::bufferstream stream2 (bytes.data (), bytes.size ()); bool error (false); nano::message_header header (error, stream2); - nano::confirm_ack con2 (error, stream2, header, true); + nano::confirm_ack con2 (error, stream2, header); ASSERT_FALSE (error); ASSERT_EQ (con1, con2); std::vector vote_blocks; diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 6c92c237d..e69e54caf 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -707,7 +707,7 @@ TEST (node_config, v16_v17_upgrade) ASSERT_FALSE (tree.get_optional_child ("tcp_incoming_connections_max")); ASSERT_FALSE (tree.get_optional_child ("vote_generator_delay")); ASSERT_FALSE (tree.get_optional_child ("diagnostics")); - ASSERT_FALSE (tree.get_optional_child ("use_memory_pool")); + ASSERT_FALSE (tree.get_optional_child ("use_memory_pools")); ASSERT_FALSE (tree.get_optional_child ("confirmation_history_size")); config.deserialize_json (upgraded, tree); @@ -719,7 +719,7 @@ TEST (node_config, v16_v17_upgrade) ASSERT_TRUE (!!tree.get_optional_child ("tcp_incoming_connections_max")); ASSERT_TRUE (!!tree.get_optional_child ("vote_generator_delay")); ASSERT_TRUE (!!tree.get_optional_child ("diagnostics")); - ASSERT_TRUE (!!tree.get_optional_child ("use_memory_pool")); + ASSERT_TRUE (!!tree.get_optional_child ("use_memory_pools")); ASSERT_TRUE (!!tree.get_optional_child ("confirmation_history_size")); ASSERT_TRUE (upgraded); @@ -755,7 +755,7 @@ TEST (node_config, v17_values) nano::jsonconfig diagnostics_l; diagnostics_l.put_child ("txn_tracking", txn_tracking_l); tree.put_child ("diagnostics", diagnostics_l); - tree.put ("use_memory_pool", true); + tree.put ("use_memory_pools", true); tree.put ("confirmation_history_size", 2048); } @@ -770,7 +770,7 @@ TEST (node_config, v17_values) ASSERT_EQ (config.diagnostics_config.txn_tracking.min_read_txn_time.count (), 0); ASSERT_EQ (config.diagnostics_config.txn_tracking.min_write_txn_time.count (), 0); ASSERT_TRUE (config.diagnostics_config.txn_tracking.ignore_writes_below_block_processor_max_time); - ASSERT_TRUE (config.use_memory_pool); + ASSERT_TRUE (config.use_memory_pools); ASSERT_EQ (config.confirmation_history_size, 2048); // Check config is correct with other values @@ -788,7 +788,7 @@ TEST (node_config, v17_values) nano::jsonconfig diagnostics_l; diagnostics_l.replace_child ("txn_tracking", txn_tracking_l); tree.replace_child ("diagnostics", diagnostics_l); - tree.put ("use_memory_pool", false); + tree.put ("use_memory_pools", false); tree.put ("confirmation_history_size", std::numeric_limits::max ()); upgraded = false; @@ -805,7 +805,7 @@ TEST (node_config, v17_values) ASSERT_EQ (config.tcp_incoming_connections_max, std::numeric_limits::max ()); ASSERT_EQ (config.diagnostics_config.txn_tracking.min_write_txn_time.count (), std::numeric_limits::max ()); ASSERT_FALSE (config.diagnostics_config.txn_tracking.ignore_writes_below_block_processor_max_time); - ASSERT_FALSE (config.use_memory_pool); + ASSERT_FALSE (config.use_memory_pools); ASSERT_EQ (config.confirmation_history_size, std::numeric_limits::max ()); } diff --git a/nano/lib/blocks.cpp b/nano/lib/blocks.cpp index 6b551b636..17f6722ba 100644 --- a/nano/lib/blocks.cpp +++ b/nano/lib/blocks.cpp @@ -18,10 +18,10 @@ bool blocks_equal (T const & first, nano::block const & second) } template -std::shared_ptr deserialize_block (nano::stream & stream_a, bool use_memory_pool) +std::shared_ptr deserialize_block (nano::stream & stream_a) { auto error (false); - auto result = nano::make_shared (use_memory_pool, error, stream_a); + auto result = nano::make_shared (error, stream_a); if (error) { result = nullptr; @@ -1259,46 +1259,46 @@ std::shared_ptr nano::deserialize_block_json (boost::property_tree: return result; } -std::shared_ptr nano::deserialize_block (nano::stream & stream_a, bool use_memory_pool) +std::shared_ptr nano::deserialize_block (nano::stream & stream_a) { nano::block_type type; auto error (try_read (stream_a, type)); std::shared_ptr result; if (!error) { - result = nano::deserialize_block (stream_a, type, use_memory_pool); + result = nano::deserialize_block (stream_a, type); } return result; } -std::shared_ptr nano::deserialize_block (nano::stream & stream_a, nano::block_type type_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +std::shared_ptr nano::deserialize_block (nano::stream & stream_a, nano::block_type type_a, nano::block_uniquer * uniquer_a) { std::shared_ptr result; switch (type_a) { case nano::block_type::receive: { - result = ::deserialize_block (stream_a, use_memory_pool); + result = ::deserialize_block (stream_a); break; } case nano::block_type::send: { - result = ::deserialize_block (stream_a, use_memory_pool); + result = ::deserialize_block (stream_a); break; } case nano::block_type::open: { - result = ::deserialize_block (stream_a, use_memory_pool); + result = ::deserialize_block (stream_a); break; } case nano::block_type::change: { - result = ::deserialize_block (stream_a, use_memory_pool); + result = ::deserialize_block (stream_a); break; } case nano::block_type::state: { - result = ::deserialize_block (stream_a, use_memory_pool); + result = ::deserialize_block (stream_a); break; } default: diff --git a/nano/lib/blocks.hpp b/nano/lib/blocks.hpp index 13becc8f2..deaad5af3 100644 --- a/nano/lib/blocks.hpp +++ b/nano/lib/blocks.hpp @@ -356,8 +356,8 @@ private: std::unique_ptr collect_seq_con_info (block_uniquer & block_uniquer, const std::string & name); -std::shared_ptr deserialize_block (nano::stream &, bool use_memory_pool); -std::shared_ptr deserialize_block (nano::stream &, nano::block_type, bool use_memory_pool, nano::block_uniquer * = nullptr); +std::shared_ptr deserialize_block (nano::stream &); +std::shared_ptr deserialize_block (nano::stream &, nano::block_type, nano::block_uniquer * = nullptr); std::shared_ptr deserialize_block_json (boost::property_tree::ptree const &, nano::block_uniquer * = nullptr); void serialize_block (nano::stream &, nano::block const &); void block_memory_pool_purge (); diff --git a/nano/lib/memory.cpp b/nano/lib/memory.cpp index 656b6727c..012566edc 100644 --- a/nano/lib/memory.cpp +++ b/nano/lib/memory.cpp @@ -1,5 +1,7 @@ #include +bool nano::use_memory_pools{ true }; + nano::cleanup_guard::cleanup_guard (std::vector> const & cleanup_funcs_a) : cleanup_funcs (cleanup_funcs_a) { diff --git a/nano/lib/memory.hpp b/nano/lib/memory.hpp index f331de7cf..7ecda8564 100644 --- a/nano/lib/memory.hpp +++ b/nano/lib/memory.hpp @@ -8,6 +8,8 @@ namespace nano { +extern bool use_memory_pools; + /** This makes some heuristic assumptions about the implementation defined shared_ptr internals. Should only be used in the memory pool purge functions at exit, which doesn't matter much if it is incorrect (other than reports from heap memory analysers) */ @@ -42,9 +44,9 @@ private: }; template -std::shared_ptr make_shared (bool use_memory_pool, Args &&... args) +std::shared_ptr make_shared (Args &&... args) { - if (use_memory_pool) + if (nano::use_memory_pools) { return std::allocate_shared (boost::fast_pool_allocator (), std::forward (args)...); } diff --git a/nano/load_test/entry.cpp b/nano/load_test/entry.cpp index d73868f93..13df5d3b9 100644 --- a/nano/load_test/entry.cpp +++ b/nano/load_test/entry.cpp @@ -50,6 +50,8 @@ void write_config_files (boost::filesystem::path const & data_path, int index) json.read_and_update (daemon_config, data_path / "config.json"); auto node_l = json.get_required_child ("node"); node_l.put ("peering_port", peering_port_start + index); + // Alternate use of memory pool + node_l.put ("use_memory_pools", (index % 2) == 0); auto tcp = node_l.get_required_child ("ipc").get_required_child ("tcp"); tcp.put ("enable", true); tcp.put ("port", ipc_port_start + index); diff --git a/nano/nano_node/daemon.cpp b/nano/nano_node/daemon.cpp index c6fb01bbc..c2669c7c3 100644 --- a/nano/nano_node/daemon.cpp +++ b/nano/nano_node/daemon.cpp @@ -91,6 +91,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano:: std::unique_ptr runner; nano::daemon_config config (data_path); auto error = nano::read_and_update_daemon_config (data_path, config); + nano::use_memory_pools = config.node.use_memory_pools; if (!error) { diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index ed0fa852f..644e37753 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -431,7 +431,7 @@ bool nano::active_transactions::add (std::shared_ptr block_a, std:: auto existing (roots.find (root)); if (existing == roots.end ()) { - auto election (nano::make_shared (node.config.use_memory_pool, node, block_a, confirmation_action_a)); + auto election (nano::make_shared (node, block_a, confirmation_action_a)); uint64_t difficulty (0); auto error (nano::work_validate (*block_a, &difficulty)); release_assert (!error); diff --git a/nano/node/bootstrap.cpp b/nano/node/bootstrap.cpp index 475a68724..0f14ee0fb 100644 --- a/nano/node/bootstrap.cpp +++ b/nano/node/bootstrap.cpp @@ -434,7 +434,7 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e if (!ec) { nano::bufferstream stream (connection->receive_buffer->data (), size_a); - std::shared_ptr block (nano::deserialize_block (stream, type_a, connection->node->config.use_memory_pool)); + std::shared_ptr block (nano::deserialize_block (stream, type_a)); if (block != nullptr && !nano::work_validate (*block)) { auto hash (block->hash ()); @@ -2215,7 +2215,7 @@ void nano::bootstrap_server::receive_confirm_ack_action (boost::system::error_co { auto error (false); nano::bufferstream stream (receive_buffer->data (), size_a); - std::unique_ptr request (new nano::confirm_ack (error, stream, header_a, node->config.use_memory_pool)); + std::unique_ptr request (new nano::confirm_ack (error, stream, header_a)); if (!error) { if (node_id_handshake_finished) @@ -3123,7 +3123,7 @@ void nano::bulk_push_server::received_block (boost::system::error_code const & e if (!ec) { nano::bufferstream stream (receive_buffer->data (), size_a); - auto block (nano::deserialize_block (stream, type_a, connection->node->config.use_memory_pool)); + auto block (nano::deserialize_block (stream, type_a)); if (block != nullptr && !nano::work_validate (*block)) { if (!connection->node->block_processor.full ()) diff --git a/nano/node/common.cpp b/nano/node/common.cpp index 0bfe8d2e6..d783a81c4 100644 --- a/nano/node/common.cpp +++ b/nano/node/common.cpp @@ -520,10 +520,10 @@ void nano::publish::serialize (nano::stream & stream_a) const block->serialize (stream_a); } -bool nano::publish::deserialize (nano::stream & stream_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +bool nano::publish::deserialize (nano::stream & stream_a, nano::block_uniquer * uniquer_a) { assert (header.type == nano::message_type::publish); - block = nano::deserialize_block (stream_a, header.block_type (), use_memory_pool, uniquer_a); + block = nano::deserialize_block (stream_a, header.block_type (), uniquer_a); auto result (block == nullptr); return result; } @@ -599,7 +599,7 @@ void nano::confirm_req::serialize (nano::stream & stream_a) const } } -bool nano::confirm_req::deserialize (nano::stream & stream_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +bool nano::confirm_req::deserialize (nano::stream & stream_a, nano::block_uniquer * uniquer_a) { bool result (false); assert (header.type == nano::message_type::confirm_req); @@ -627,7 +627,7 @@ bool nano::confirm_req::deserialize (nano::stream & stream_a, bool use_memory_po } else { - block = nano::deserialize_block (stream_a, header.block_type (), true, uniquer_a); + block = nano::deserialize_block (stream_a, header.block_type (), uniquer_a); result = block == nullptr; } } @@ -680,9 +680,9 @@ size_t nano::confirm_req::size (nano::block_type type_a, size_t count) return result; } -nano::confirm_ack::confirm_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, bool use_memory_pool, nano::vote_uniquer * uniquer_a) : +nano::confirm_ack::confirm_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::vote_uniquer * uniquer_a) : message (header_a), -vote (nano::make_shared (use_memory_pool, error_a, stream_a, header.block_type (), use_memory_pool)) +vote (nano::make_shared (error_a, stream_a, header.block_type ())) { if (!error_a && uniquer_a) { diff --git a/nano/node/common.hpp b/nano/node/common.hpp index b3f473af6..7c19844d9 100644 --- a/nano/node/common.hpp +++ b/nano/node/common.hpp @@ -298,7 +298,7 @@ public: explicit publish (std::shared_ptr); void visit (nano::message_visitor &) const override; void serialize (nano::stream &) const override; - bool deserialize (nano::stream &, bool use_memory_pool, nano::block_uniquer * = nullptr); + bool deserialize (nano::stream &, nano::block_uniquer * = nullptr); bool operator== (nano::publish const &) const; std::shared_ptr block; }; @@ -310,7 +310,7 @@ public: confirm_req (std::vector> const &); confirm_req (nano::block_hash const &, nano::block_hash const &); void serialize (nano::stream &) const override; - bool deserialize (nano::stream &, bool use_memory_pool, nano::block_uniquer * = nullptr); + bool deserialize (nano::stream &, nano::block_uniquer * = nullptr); void visit (nano::message_visitor &) const override; bool operator== (nano::confirm_req const &) const; std::shared_ptr block; @@ -321,7 +321,7 @@ public: class confirm_ack final : public message { public: - confirm_ack (bool &, nano::stream &, nano::message_header const &, bool use_memory_pool, nano::vote_uniquer * = nullptr); + confirm_ack (bool &, nano::stream &, nano::message_header const &, nano::vote_uniquer * = nullptr); explicit confirm_ack (std::shared_ptr); void serialize (nano::stream &) const override; void visit (nano::message_visitor &) const override; diff --git a/nano/node/lmdb.cpp b/nano/node/lmdb.cpp index 0b00829d1..4644e9103 100644 --- a/nano/node/lmdb.cpp +++ b/nano/node/lmdb.cpp @@ -147,10 +147,9 @@ void * nano::write_mdb_txn::get_handle () const return handle; } -nano::mdb_val::mdb_val (bool use_memory_pool_a, nano::epoch epoch_a) : +nano::mdb_val::mdb_val (nano::epoch epoch_a) : value ({ 0, nullptr }), -epoch (epoch_a), -use_memory_pool (use_memory_pool_a) +epoch (epoch_a) { } @@ -197,8 +196,8 @@ mdb_val (sizeof (val_a), const_cast (&val_a)) static_assert (std::is_standard_layout::value, "Standard layout is required"); } -nano::mdb_val::mdb_val (nano::unchecked_info const & val_a, bool use_memory_pool_a) : -buffer (std::make_shared> ()), use_memory_pool (use_memory_pool_a) +nano::mdb_val::mdb_val (nano::unchecked_info const & val_a) : +buffer (std::make_shared> ()) { { nano::vectorstream stream (*buffer); @@ -219,8 +218,8 @@ mdb_val (sizeof (val_a), const_cast (&val_a)) static_assert (std::is_standard_layout::value, "Standard layout is required"); } -nano::mdb_val::mdb_val (std::shared_ptr const & val_a, bool use_memory_pool_a) : -buffer (std::make_shared> ()), use_memory_pool (use_memory_pool_a) +nano::mdb_val::mdb_val (std::shared_ptr const & val_a) : +buffer (std::make_shared> ()) { { nano::vectorstream stream (*buffer); @@ -298,7 +297,7 @@ nano::mdb_val::operator nano::unchecked_info () const { nano::bufferstream stream (reinterpret_cast (value.mv_data), value.mv_size); nano::unchecked_info result; - bool error (result.deserialize (stream, use_memory_pool)); + bool error (result.deserialize (stream)); assert (!error); return result; } @@ -343,7 +342,7 @@ nano::mdb_val::operator nano::no_value () const nano::mdb_val::operator std::shared_ptr () const { nano::bufferstream stream (reinterpret_cast (value.mv_data), value.mv_size); - std::shared_ptr result (nano::deserialize_block (stream, use_memory_pool)); + std::shared_ptr result (nano::deserialize_block (stream)); return result; } @@ -396,7 +395,7 @@ nano::mdb_val::operator std::shared_ptr () const { nano::bufferstream stream (reinterpret_cast (value.mv_data), value.mv_size); auto error (false); - auto result (nano::make_shared (use_memory_pool, error, stream, use_memory_pool)); + auto result (nano::make_shared (error, stream)); assert (!error); return result; } @@ -602,8 +601,8 @@ bool nano::mdb_iterator::operator== (nano::store_iterator_impl const template void nano::mdb_iterator::clear () { - current.first = nano::mdb_val (current.first.use_memory_pool, current.first.epoch); - current.second = nano::mdb_val (current.second.use_memory_pool, current.second.epoch); + current.first = nano::mdb_val (current.first.epoch); + current.second = nano::mdb_val (current.second.epoch); assert (is_end_sentinal ()); } @@ -823,12 +822,11 @@ nano::store_iterator> nano::mdb_store return nano::store_iterator> (nullptr); } -nano::mdb_store::mdb_store (bool & error_a, nano::logger_mt & logger_a, boost::filesystem::path const & path_a, bool use_memory_pool_a, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, int lmdb_max_dbs, bool drop_unchecked, size_t const batch_size) : +nano::mdb_store::mdb_store (bool & error_a, nano::logger_mt & logger_a, boost::filesystem::path const & path_a, nano::txn_tracking_config const & txn_tracking_config_a, std::chrono::milliseconds block_processor_batch_max_time_a, int lmdb_max_dbs, bool drop_unchecked, size_t const batch_size) : logger (logger_a), env (error_a, path_a, lmdb_max_dbs), mdb_txn_tracker (logger_a, txn_tracking_config_a, block_processor_batch_max_time_a), -txn_tracking_enabled (txn_tracking_config_a.enable), -use_memory_pool (use_memory_pool_a) +txn_tracking_enabled (txn_tracking_config_a.enable) { if (!error_a) { @@ -964,7 +962,7 @@ void nano::mdb_store::version_put (nano::transaction const & transaction_a, int int nano::mdb_store::version_get (nano::transaction const & transaction_a) const { nano::uint256_union version_key (1); - nano::mdb_val data (use_memory_pool); + nano::mdb_val data; auto error (mdb_get (env.tx (transaction_a), meta, nano::mdb_val (version_key), data)); int result (1); if (error != MDB_NOTFOUND) @@ -1474,7 +1472,7 @@ void nano::mdb_store::block_put (nano::transaction const & transaction_a, nano:: boost::optional nano::mdb_store::block_raw_get_by_type (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const { - nano::mdb_val value (use_memory_pool); + nano::mdb_val value; auto status (MDB_NOTFOUND); switch (type_a) { @@ -1526,7 +1524,7 @@ boost::optional nano::mdb_store::block_raw_get_by_type (nano::transacti MDB_val nano::mdb_store::block_raw_get (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_type & type_a) const { - nano::mdb_val result (use_memory_pool); + nano::mdb_val result; // Table lookups are ordered by match probability nano::block_type block_types[]{ nano::block_type::state, nano::block_type::send, nano::block_type::receive, nano::block_type::open, nano::block_type::change }; for (auto current_type : block_types) @@ -1681,7 +1679,7 @@ std::shared_ptr nano::mdb_store::block_get (nano::transaction const if (value.mv_size != 0) { nano::bufferstream stream (reinterpret_cast (value.mv_data), value.mv_size); - result = nano::deserialize_block (stream, type, use_memory_pool); + result = nano::deserialize_block (stream, type); assert (result != nullptr); if (sideband_a) { @@ -2161,7 +2159,7 @@ nano::store_iterator nano::mdb_store::pen bool nano::mdb_store::block_info_get (nano::transaction const & transaction_a, nano::block_hash const & hash_a, nano::block_info & block_info_a) const { assert (!full_sideband (transaction_a)); - nano::mdb_val value (use_memory_pool); + nano::mdb_val value; auto status (mdb_get (env.tx (transaction_a), blocks_info, nano::mdb_val (hash_a), value)); release_assert (status == 0 || status == MDB_NOTFOUND); bool result (true); @@ -2180,7 +2178,7 @@ bool nano::mdb_store::block_info_get (nano::transaction const & transaction_a, n nano::uint128_t nano::mdb_store::representation_get (nano::transaction const & transaction_a, nano::account const & account_a) { - nano::mdb_val value (use_memory_pool); + nano::mdb_val value; auto status (mdb_get (env.tx (transaction_a), representation, nano::mdb_val (account_a), value)); release_assert (status == 0 || status == MDB_NOTFOUND); nano::uint128_t result = 0; @@ -2210,7 +2208,7 @@ void nano::mdb_store::unchecked_clear (nano::transaction const & transaction_a) void nano::mdb_store::unchecked_put (nano::transaction const & transaction_a, nano::unchecked_key const & key_a, nano::unchecked_info const & info_a) { - auto status (mdb_put (env.tx (transaction_a), unchecked, nano::mdb_val (key_a), nano::mdb_val (info_a, use_memory_pool), 0)); + auto status (mdb_put (env.tx (transaction_a), unchecked, nano::mdb_val (key_a), nano::mdb_val (info_a), 0)); release_assert (status == 0); } @@ -2223,7 +2221,7 @@ void nano::mdb_store::unchecked_put (nano::transaction const & transaction_a, na std::shared_ptr nano::mdb_store::vote_get (nano::transaction const & transaction_a, nano::account const & account_a) { - nano::mdb_val value (use_memory_pool); + nano::mdb_val value; auto status (mdb_get (env.tx (transaction_a), vote, nano::mdb_val (account_a), value)); release_assert (status == 0 || status == MDB_NOTFOUND); if (status == 0) diff --git a/nano/node/lmdb.hpp b/nano/node/lmdb.hpp index 93517e183..5fd5db5b5 100644 --- a/nano/node/lmdb.hpp +++ b/nano/node/lmdb.hpp @@ -76,20 +76,20 @@ public: class mdb_val { public: - mdb_val (bool use_memory_pool = true, nano::epoch = nano::epoch::unspecified); + mdb_val (nano::epoch = nano::epoch::unspecified); mdb_val (nano::account_info const &); mdb_val (nano::account_info_v13 const &); mdb_val (nano::block_info const &); mdb_val (MDB_val const &, nano::epoch = nano::epoch::unspecified); mdb_val (nano::pending_info const &); mdb_val (nano::pending_key const &); - mdb_val (nano::unchecked_info const &, bool); + mdb_val (nano::unchecked_info const &); mdb_val (size_t, void *); mdb_val (nano::uint128_union const &); mdb_val (nano::uint256_union const &); mdb_val (nano::endpoint_key const &); - mdb_val (std::shared_ptr const &, bool); - mdb_val (std::shared_ptr const &, bool); + mdb_val (std::shared_ptr const &); + mdb_val (std::shared_ptr const &); mdb_val (uint64_t); void * data () const; size_t size () const; @@ -117,7 +117,6 @@ public: MDB_val value; std::shared_ptr> buffer; nano::epoch epoch{ nano::epoch::unspecified }; - bool use_memory_pool{ true }; }; class block_store; @@ -183,7 +182,7 @@ class mdb_store : public block_store friend class nano::block_predecessor_set; public: - mdb_store (bool &, nano::logger_mt &, boost::filesystem::path const &, bool use_memory_pool_a = true, 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), int lmdb_max_dbs = 128, bool drop_unchecked = false, size_t batch_size = 512); + mdb_store (bool &, nano::logger_mt &, boost::filesystem::path const &, 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), int lmdb_max_dbs = 128, bool drop_unchecked = false, size_t batch_size = 512); nano::write_transaction tx_begin_write () override; nano::read_transaction tx_begin_read () override; @@ -442,7 +441,6 @@ private: nano::mdb_txn_tracker mdb_txn_tracker; nano::mdb_txn_callbacks create_txn_callbacks (); bool txn_tracking_enabled; - bool use_memory_pool; static int constexpr version{ 14 }; }; class wallet_value diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 9fdd04a92..f7619d43d 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -201,7 +201,7 @@ flags (flags_a), alarm (alarm_a), work (work_a), logger (config_a.logging.min_time_between_log_output), -store_impl (std::make_unique (init_a.block_store_init, logger, application_path_a / "data.ldb", config_a.use_memory_pool, config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_max_dbs, !flags.disable_unchecked_drop, flags.sideband_batch_size)), +store_impl (std::make_unique (init_a.block_store_init, logger, application_path_a / "data.ldb", config_a.diagnostics_config.txn_tracking, config_a.block_processor_batch_max_time, config_a.lmdb_max_dbs, !flags.disable_unchecked_drop, flags.sideband_batch_size)), store (*store_impl), wallets_store_impl (std::make_unique (init_a.wallets_store_init, application_path_a / "wallets.ldb", config_a.lmdb_max_dbs)), wallets_store (*wallets_store_impl), diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index ee973b5c9..3296b9e0c 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -120,7 +120,7 @@ nano::error nano::node_config::serialize_json (nano::jsonconfig & json) const json.put ("external_address", external_address.to_string ()); json.put ("external_port", external_port); json.put ("tcp_incoming_connections_max", tcp_incoming_connections_max); - json.put ("use_memory_pool", use_memory_pool); + json.put ("use_memory_pools", use_memory_pools); nano::jsonconfig websocket_l; websocket_config.serialize_json (websocket_l); json.put_child ("websocket", websocket_l); @@ -247,7 +247,7 @@ bool nano::node_config::upgrade_json (unsigned version_a, nano::jsonconfig & jso json.put ("external_port", external_port); json.put ("tcp_incoming_connections_max", tcp_incoming_connections_max); json.put ("vote_generator_delay", vote_generator_delay.count ()); - json.put ("use_memory_pool", use_memory_pool); + json.put ("use_memory_pools", use_memory_pools); json.put ("confirmation_history_size", confirmation_history_size); } case 17: @@ -395,7 +395,7 @@ nano::error nano::node_config::deserialize_json (bool & upgraded_a, nano::jsonco auto pow_sleep_interval_l (pow_sleep_interval.count ()); json.get (pow_sleep_interval_key, pow_sleep_interval_l); pow_sleep_interval = std::chrono::nanoseconds (pow_sleep_interval_l); - json.get ("use_memory_pool", use_memory_pool); + json.get ("use_memory_pools", use_memory_pools); json.get ("confirmation_history_size", confirmation_history_size); // Validate ranges diff --git a/nano/node/nodeconfig.hpp b/nano/node/nodeconfig.hpp index 2128ec33b..139f15aa2 100644 --- a/nano/node/nodeconfig.hpp +++ b/nano/node/nodeconfig.hpp @@ -69,7 +69,7 @@ public: std::chrono::nanoseconds pow_sleep_interval{ 0 }; /** Default maximum incoming TCP connections, including realtime network & bootstrap */ unsigned tcp_incoming_connections_max{ 1024 }; - bool use_memory_pool{ true }; + bool use_memory_pools{ true }; static std::chrono::seconds constexpr keepalive_period = std::chrono::seconds (60); static std::chrono::seconds constexpr keepalive_cutoff = keepalive_period * 5; static std::chrono::minutes constexpr wallet_backup_interval = std::chrono::minutes (5); diff --git a/nano/rpc_test/entry.cpp b/nano/rpc_test/entry.cpp index f8efc1065..2fd0e3362 100644 --- a/nano/rpc_test/entry.cpp +++ b/nano/rpc_test/entry.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -10,6 +11,7 @@ void force_nano_test_network (); int main (int argc, char ** argv) { nano::force_nano_test_network (); + nano::use_memory_pools = false; nano::node_singleton_memory_pool_purge_guard cleanup_guard; testing::InitGoogleTest (&argc, argv); auto res = RUN_ALL_TESTS (); diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index ced8cae35..511e33145 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -311,9 +311,9 @@ void nano::unchecked_info::serialize (nano::stream & stream_a) const nano::write (stream_a, verified); } -bool nano::unchecked_info::deserialize (nano::stream & stream_a, bool use_memory_pool) +bool nano::unchecked_info::deserialize (nano::stream & stream_a) { - block = nano::deserialize_block (stream_a, use_memory_pool); + block = nano::deserialize_block (stream_a); bool error (block == nullptr); if (!error) { @@ -432,12 +432,12 @@ signature (other_a.signature) { } -nano::vote::vote (bool & error_a, nano::stream & stream_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +nano::vote::vote (bool & error_a, nano::stream & stream_a, nano::block_uniquer * uniquer_a) { - error_a = deserialize (stream_a, use_memory_pool, uniquer_a); + error_a = deserialize (stream_a, uniquer_a); } -nano::vote::vote (bool & error_a, nano::stream & stream_a, nano::block_type type_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +nano::vote::vote (bool & error_a, nano::stream & stream_a, nano::block_type type_a, nano::block_uniquer * uniquer_a) { try { @@ -455,7 +455,7 @@ nano::vote::vote (bool & error_a, nano::stream & stream_a, nano::block_type type } else { - std::shared_ptr block (nano::deserialize_block (stream_a, type_a, use_memory_pool, uniquer_a)); + std::shared_ptr block (nano::deserialize_block (stream_a, type_a, uniquer_a)); if (block == nullptr) { throw std::runtime_error ("Block is null"); @@ -588,7 +588,7 @@ void nano::vote::serialize (nano::stream & stream_a) const } } -bool nano::vote::deserialize (nano::stream & stream_a, bool use_memory_pool, nano::block_uniquer * uniquer_a) +bool nano::vote::deserialize (nano::stream & stream_a, nano::block_uniquer * uniquer_a) { auto error (false); try @@ -615,7 +615,7 @@ bool nano::vote::deserialize (nano::stream & stream_a, bool use_memory_pool, nan } else { - std::shared_ptr block (nano::deserialize_block (stream_a, type, use_memory_pool, uniquer_a)); + std::shared_ptr block (nano::deserialize_block (stream_a, type, uniquer_a)); if (block == nullptr) { throw std::runtime_error ("Block is empty"); diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 605b58b9e..dbbb83682 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -182,7 +182,7 @@ public: unchecked_info () = default; unchecked_info (std::shared_ptr, nano::account const &, uint64_t, nano::signature_verification = nano::signature_verification::unknown); void serialize (nano::stream &) const; - bool deserialize (nano::stream &, bool use_memory_pool); + bool deserialize (nano::stream &); std::shared_ptr block; nano::account account{ 0 }; /** Seconds since posix epoch */ @@ -221,8 +221,8 @@ class vote final public: vote () = default; vote (nano::vote const &); - vote (bool &, nano::stream &, bool use_memory_pool, nano::block_uniquer * = nullptr); - vote (bool &, nano::stream &, nano::block_type, bool use_memory_pool, nano::block_uniquer * = nullptr); + vote (bool &, nano::stream &, nano::block_uniquer * = nullptr); + vote (bool &, nano::stream &, nano::block_type, nano::block_uniquer * = nullptr); vote (nano::account const &, nano::raw_key const &, uint64_t, std::shared_ptr); vote (nano::account const &, nano::raw_key const &, uint64_t, std::vector const &); std::string hashes_string () const; @@ -233,7 +233,7 @@ public: void serialize (nano::stream &, nano::block_type) const; void serialize (nano::stream &) const; void serialize_json (boost::property_tree::ptree & tree) const; - bool deserialize (nano::stream &, bool use_memory_pool, nano::block_uniquer * = nullptr); + bool deserialize (nano::stream &, nano::block_uniquer * = nullptr); bool validate () const; boost::transform_iterator begin () const; boost::transform_iterator end () const;