From 7caf0a6aae6e0ae01a4baba2b7f4a61b12acac77 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Thu, 6 Apr 2017 14:18:30 +0200 Subject: [PATCH] Configurable shmem segment size --- fairmq/options/FairMQProgOptions.cxx | 3 +++ fairmq/shmem/FairMQTransportFactorySHM.cxx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index 75985f40..704fece5 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -309,6 +309,7 @@ void FairMQProgOptions::InitOptionDescription() ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") ("log-to-file", po::value()->default_value(""), "Log output to a file.") + ("shm-segment-size", po::value()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).") ; fMQOptionsInCfg.add_options() @@ -324,6 +325,7 @@ void FairMQProgOptions::InitOptionDescription() ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") ("log-to-file", po::value()->default_value(""), "Log output to a file.") + ("shm-segment-size", po::value()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).") ; } else @@ -341,6 +343,7 @@ void FairMQProgOptions::InitOptionDescription() ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") ("log-to-file", po::value()->default_value(""), "Log output to a file.") + ("shm-segment-size", po::value()->default_value(2000000000), "shmem transport: size of the shared memory segment (in bytes).") ; } diff --git a/fairmq/shmem/FairMQTransportFactorySHM.cxx b/fairmq/shmem/FairMQTransportFactorySHM.cxx index 39881937..c7dbeebc 100644 --- a/fairmq/shmem/FairMQTransportFactorySHM.cxx +++ b/fairmq/shmem/FairMQTransportFactorySHM.cxx @@ -38,9 +38,11 @@ FairMQTransportFactorySHM::FairMQTransportFactorySHM() void FairMQTransportFactorySHM::Initialize(const FairMQProgOptions* config) { int numIoThreads = 1; + size_t segmentSize = 2000000000; if (config) { numIoThreads = config->GetValue("io-threads"); + segmentSize = config->GetValue("shm-segment-size"); } else { @@ -58,8 +60,8 @@ void FairMQTransportFactorySHM::Initialize(const FairMQProgOptions* config) LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno); } - Manager::Instance().InitializeSegment("open_or_create", "FairMQSharedMemory", 2000000000); - LOG(DEBUG) << "shmem: created/opened shared memory segment of 2000000000 bytes. Available are " << Manager::Instance().Segment()->get_free_memory() << " bytes."; + Manager::Instance().InitializeSegment("open_or_create", "FairMQSharedMemory", segmentSize); + LOG(DEBUG) << "shmem: created/opened shared memory segment of " << segmentSize << " bytes. Available are " << Manager::Instance().Segment()->get_free_memory() << " bytes."; } FairMQMessagePtr FairMQTransportFactorySHM::CreateMessage() const