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:
Wesley Shillingford 2019-06-11 09:23:56 +01:00 committed by GitHub
commit 5517e5275f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 6 deletions

View file

@ -54,6 +54,12 @@ size_t get_allocated_size ()
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::receive_block> ();
nano::make_shared<nano::send_block> ();

View file

@ -1,6 +1,27 @@
#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) :
cleanup_funcs (cleanup_funcs_a)

View file

@ -8,7 +8,8 @@
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.
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>
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)...);
}

View file

@ -91,8 +91,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
std::unique_ptr<nano::thread_runner> 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;
nano::set_use_memory_pools (config.node.use_memory_pools);
if (!error)
{
config.node.logging.init (data_path);

View file

@ -237,6 +237,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
int result (0);
nano::jsonconfig json;
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);
if (!error)
{

View file

@ -11,7 +11,7 @@ void force_nano_test_network ();
int main (int argc, char ** argv)
{
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;
testing::InitGoogleTest (&argc, argv);
auto res = RUN_ALL_TESTS ();