Disable memory pools when running on Mac (#2067)
* Turn off use_memory_pools when using TSAN with mac * Add TSAN check to nano_wallet * Turn off using memory pools on Mac entirely
This commit is contained in:
parent
156a744ad9
commit
5517e5275f
6 changed files with 34 additions and 6 deletions
|
|
@ -54,6 +54,12 @@ size_t get_allocated_size ()
|
||||||
|
|
||||||
TEST (memory_pool, validate_cleanup)
|
TEST (memory_pool, validate_cleanup)
|
||||||
{
|
{
|
||||||
|
// This might be turned off, e.g on Mac for instance, so don't do this test
|
||||||
|
if (!nano::get_use_memory_pools ())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nano::make_shared<nano::open_block> ();
|
nano::make_shared<nano::open_block> ();
|
||||||
nano::make_shared<nano::receive_block> ();
|
nano::make_shared<nano::receive_block> ();
|
||||||
nano::make_shared<nano::send_block> ();
|
nano::make_shared<nano::send_block> ();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,27 @@
|
||||||
#include <nano/lib/memory.hpp>
|
#include <nano/lib/memory.hpp>
|
||||||
|
|
||||||
bool nano::use_memory_pools{ true };
|
namespace
|
||||||
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/** TSAN on mac is generating some warnings. They need further investigating before using memory pools can be used, so disable them for now */
|
||||||
|
bool use_memory_pools{ false };
|
||||||
|
#else
|
||||||
|
bool use_memory_pools{ true };
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nano::get_use_memory_pools ()
|
||||||
|
{
|
||||||
|
return use_memory_pools;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This has no effect on Mac */
|
||||||
|
void nano::set_use_memory_pools (bool use_memory_pools_a)
|
||||||
|
{
|
||||||
|
#ifndef __APPLE__
|
||||||
|
use_memory_pools = use_memory_pools_a;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a) :
|
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a) :
|
||||||
cleanup_funcs (cleanup_funcs_a)
|
cleanup_funcs (cleanup_funcs_a)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
namespace nano
|
namespace nano
|
||||||
{
|
{
|
||||||
extern bool use_memory_pools;
|
bool get_use_memory_pools ();
|
||||||
|
void set_use_memory_pools (bool use_memory_pools);
|
||||||
|
|
||||||
/** This makes some heuristic assumptions about the implementation defined shared_ptr internals.
|
/** 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
|
Should only be used in the memory pool purge functions at exit, which doesn't matter much if
|
||||||
|
|
@ -46,7 +47,7 @@ private:
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
std::shared_ptr<T> make_shared (Args &&... args)
|
std::shared_ptr<T> make_shared (Args &&... args)
|
||||||
{
|
{
|
||||||
if (nano::use_memory_pools)
|
if (nano::get_use_memory_pools ())
|
||||||
{
|
{
|
||||||
return std::allocate_shared<T> (boost::fast_pool_allocator<T> (), std::forward<Args> (args)...);
|
return std::allocate_shared<T> (boost::fast_pool_allocator<T> (), std::forward<Args> (args)...);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
||||||
std::unique_ptr<nano::thread_runner> runner;
|
std::unique_ptr<nano::thread_runner> runner;
|
||||||
nano::daemon_config config (data_path);
|
nano::daemon_config config (data_path);
|
||||||
auto error = nano::read_and_update_daemon_config (data_path, config);
|
auto error = nano::read_and_update_daemon_config (data_path, config);
|
||||||
nano::use_memory_pools = config.node.use_memory_pools;
|
nano::set_use_memory_pools (config.node.use_memory_pools);
|
||||||
|
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
config.node.logging.init (data_path);
|
config.node.logging.init (data_path);
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
||||||
int result (0);
|
int result (0);
|
||||||
nano::jsonconfig json;
|
nano::jsonconfig json;
|
||||||
auto error (json.read_and_update (config, config_path));
|
auto error (json.read_and_update (config, config_path));
|
||||||
|
nano::set_use_memory_pools (config.node.use_memory_pools);
|
||||||
nano::set_secure_perm_file (config_path, error_chmod);
|
nano::set_secure_perm_file (config_path, error_chmod);
|
||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ void force_nano_test_network ();
|
||||||
int main (int argc, char ** argv)
|
int main (int argc, char ** argv)
|
||||||
{
|
{
|
||||||
nano::force_nano_test_network ();
|
nano::force_nano_test_network ();
|
||||||
nano::use_memory_pools = false;
|
nano::set_use_memory_pools (false);
|
||||||
nano::node_singleton_memory_pool_purge_guard cleanup_guard;
|
nano::node_singleton_memory_pool_purge_guard cleanup_guard;
|
||||||
testing::InitGoogleTest (&argc, argv);
|
testing::InitGoogleTest (&argc, argv);
|
||||||
auto res = RUN_ALL_TESTS ();
|
auto res = RUN_ALL_TESTS ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue