libfoedus-core
FOEDUS Core Library
foedus::EngineOptions Struct Referencefinal

Set of option values given to the engine at start-up. More...

Detailed Description

Set of option values given to the engine at start-up.

This object is a collection of engine-wide settings and settings for individual modules (XxxOptions). To configure options, instantiate this class then modify values in each sub-module's options. When you start-up the database engine, you have to provide this object.

Instantiating EngineOptions object

To instantiate an EngineOptions object, simply call the default constructor like:

EngineOptions options;

This sets default values to all settings. See each module's option classes for the description of their default values.

Externalization: Loading and Saving config values.

You can save and load this object to an XML file:

EngineOptions options;
... (change something in options)
if (options.save_to_file("/your/path/to/foedus_config.xml").is_error()) {
// handle errors. It might be file permission issue or other file I/O issues.
}
.... (after doing something else, possibly after restarting the program)
.... (or, maybe the user has edited the config file on text editor)
if (options.load_from_file("/your/path/to/foedus_config.xml").is_error()) {
// handle errors. It might be file permission, corrupted XML files, etc.
}

Definition at line 75 of file engine_options.hpp.

#include <engine_options.hpp>

Inheritance diagram for foedus::EngineOptions:
Collaboration diagram for foedus::EngineOptions:

Public Member Functions

 EngineOptions ()
 Constructs option values with default values. More...
 
 EngineOptions (const EngineOptions &other)
 
EngineOptionsoperator= (const EngineOptions &other)
 
void calculate_required_memory (uint64_t *shared_bytes, uint64_t *local_bytes) const
 
ErrorStack prescreen (std::ostream *details_out) const
 Checks the machine environment and raises as many errors as possible before the engine starts up. More...
 
void prescreen_ulimits (uint64_t required_total_safe_bytes, bool *has_any_error, std::ostream *details_out) const
 Subroutine of prescreen to check ulimit values. More...
 
void prescreen_sysctl (uint64_t required_shared_safe_bytes, bool *has_any_error, std::ostream *details_out) const
 Subroutine of prescreen to check sysctl values. More...
 
ErrorStack load (tinyxml2::XMLElement *element) override
 Reads the content of this object from the given XML element. More...
 
ErrorStack save (tinyxml2::XMLElement *element) const override
 Writes the content of this object to the given XML element. More...
 
const char * get_tag_name () const override
 Returns an XML tag name for this object as a root element. More...
 
void assign (const foedus::externalize::Externalizable *other) override
 Polymorphic assign operator. More...
 
- Public Member Functions inherited from foedus::externalize::Externalizable
ErrorStack load_from_string (const std::string &xml)
 Load the content of this object from the given XML string. More...
 
void save_to_stream (std::ostream *ptr) const
 Invokes save() and directs the resulting XML text to the given stream. More...
 
ErrorStack load_from_file (const fs::Path &path)
 Load the content of this object from the specified XML file. More...
 
ErrorStack save_to_file (const fs::Path &path) const
 Atomically and durably writes out this object to the specified XML file. More...
 

Static Public Member Functions

static uint64_t read_int_from_proc_fs (const char *path, std::ostream *details_out)
 A utility method to read /proc/ value in linux. More...
 
static uint64_t get_available_hugepage_memory (std::ostream *details_out)
 A utility method to check how much hugepage memory is currently available. More...
 
- Static Public Member Functions inherited from foedus::externalize::Externalizable
static ErrorStack insert_comment (tinyxml2::XMLElement *element, const std::string &comment)
 
static ErrorStack append_comment (tinyxml2::XMLElement *parent, const std::string &comment)
 
static ErrorStack create_element (tinyxml2::XMLElement *parent, const std::string &name, tinyxml2::XMLElement **out)
 
template<typename T >
static ErrorStack add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, T value)
 Only declaration in header. More...
 
template<uint MAXLEN, typename CHAR >
static ErrorStack add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const assorted::FixedString< MAXLEN, CHAR > &value)
 
template<typename T >
static ErrorStack add_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const std::vector< T > &value)
 vector version More...
 
template<typename ENUM >
static ErrorStack add_enum_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, ENUM value)
 enum version More...
 
static ErrorStack add_child_element (tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const Externalizable &child)
 child Externalizable version More...
 
template<typename T >
static ErrorStack get_element (tinyxml2::XMLElement *parent, const std::string &tag, T *out, bool optional=false, T value=0)
 Only declaration in header. More...
 
static ErrorStack get_element (tinyxml2::XMLElement *parent, const std::string &tag, std::string *out, bool optional=false, const char *value="")
 string type is bit special. More...
 
template<uint MAXLEN, typename CHAR >
static ErrorStack get_element (tinyxml2::XMLElement *parent, const std::string &tag, assorted::FixedString< MAXLEN, CHAR > *out, bool optional=false, const assorted::FixedString< MAXLEN, CHAR > &value=assorted::FixedString< MAXLEN, CHAR >())
 
template<typename ENUM >
static ErrorStack get_enum_element (tinyxml2::XMLElement *parent, const std::string &tag, ENUM *out, bool optional=false, ENUM default_value=static_cast< ENUM >(0))
 enum version More...
 
template<typename T >
static ErrorStack get_element (tinyxml2::XMLElement *parent, const std::string &tag, std::vector< T > *out, bool optional=false)
 vector version. More...
 
static ErrorStack get_child_element (tinyxml2::XMLElement *parent, const std::string &tag, Externalizable *child, bool optional=false)
 child Externalizable version More...
 

Public Attributes

cache::CacheOptions cache_
 
debugging::DebuggingOptions debugging_
 
log::LogOptions log_
 
memory::MemoryOptions memory_
 
proc::ProcOptions proc_
 
restart::RestartOptions restart_
 
savepoint::SavepointOptions savepoint_
 
snapshot::SnapshotOptions snapshot_
 
soc::SocOptions soc_
 
storage::StorageOptions storage_
 
thread::ThreadOptions thread_
 
xct::XctOptions xct_
 

Friends

std::ostream & operator<< (std::ostream &o, const EngineOptions &v)
 

Constructor & Destructor Documentation

foedus::EngineOptions::EngineOptions ( )

Constructs option values with default values.

Definition at line 38 of file engine_options.cpp.

Referenced by load().

38  {
39 }

Here is the caller graph for this function:

foedus::EngineOptions::EngineOptions ( const EngineOptions other)

Definition at line 40 of file engine_options.cpp.

References operator=().

40  {
41  operator=(other);
42 }
EngineOptions & operator=(const EngineOptions &other)

Here is the call graph for this function:

Member Function Documentation

void foedus::EngineOptions::assign ( const foedus::externalize::Externalizable other)
inlineoverridevirtual

Polymorphic assign operator.

This should invoke operator= of the derived class.

Parameters
[in]otherassigned value. It must be dynamic-castable to the assignee class.

Implements foedus::externalize::Externalizable.

Definition at line 149 of file engine_options.hpp.

void foedus::EngineOptions::calculate_required_memory ( uint64_t *  shared_bytes,
uint64_t *  local_bytes 
) const
Parameters
[out]shared_bytesByte size of shared hugepage memory the engine will consume when an engine starts up with these option values.
[out]local_bytesByte size of node-local hugepage memory the engine will consume when an engine starts up with these option values.

Definition at line 341 of file engine_options.cpp.

References cache_, foedus::soc::SharedMemoryRepo::calculate_global_memory_size(), foedus::memory::NumaCoreMemory::calculate_local_small_memory_size(), foedus::soc::SharedMemoryRepo::calculate_node_memory_size(), foedus::thread::ThreadOptions::get_total_thread_count(), foedus::thread::ThreadOptions::group_count_, foedus::xct::XctOptions::local_work_memory_size_mb_, log_, foedus::log::LogOptions::log_buffer_kb_, foedus::log::LogOptions::loggers_per_node_, memory_, foedus::memory::MemoryOptions::page_pool_size_mb_per_node_, foedus::cache::CacheOptions::snapshot_cache_size_mb_per_node_, thread_, and xct_.

Referenced by prescreen().

343  {
344  const uint32_t nodes = thread_.group_count_;
345  const uint32_t total_threads = thread_.get_total_thread_count();
346 
347  // First, shared memories. soc::SharedMemoryRepo has exact methods for that.
348  *shared_bytes = 0;
349 
350  // No idea how big the XML representation would be, but surely within 4MB.
351  uint64_t kMaxXmlSize = 1ULL << 22;
352  *shared_bytes += soc::SharedMemoryRepo::calculate_global_memory_size(kMaxXmlSize, *this);
353  *shared_bytes += soc::SharedMemoryRepo::calculate_node_memory_size(*this) * nodes;
354  *shared_bytes += (static_cast<uint64_t>(memory_.page_pool_size_mb_per_node_) << 20) * nodes;
355 
356  // Then, local memories, which are allocated in various places, so
357  // we need to list up each of them.. maybe missing something.
358  *local_bytes = 0;
359 
360  // snapshot cache pool
361  *local_bytes += cache_.snapshot_cache_size_mb_per_node_ * (1ULL << 20) * nodes;
362 
363  // logger buffer
364  *local_bytes += log_.log_buffer_kb_ * (1ULL << 10) * log_.loggers_per_node_ * nodes;
365 
366  // misc memory in NumaNodeMemory. for volatile pool and snapshot cache pool
367  *local_bytes += sizeof(memory::PagePoolOffsetChunk) * 2ULL * total_threads * 2;
368 
369  // core-local memories in NumaCoreMemory. work_memory and "small_memory" (terrible name, yes)
370  *local_bytes += xct_.local_work_memory_size_mb_ * (1ULL << 20) * total_threads;
371  *local_bytes += memory::NumaCoreMemory::calculate_local_small_memory_size(*this) * total_threads;
372 }
memory::MemoryOptions memory_
uint32_t log_buffer_kb_
Size in KB of log buffer for each worker thread.
Definition: log_options.hpp:83
static uint64_t calculate_global_memory_size(uint64_t xml_size, const EngineOptions &options)
static uint64_t calculate_node_memory_size(const EngineOptions &options)
uint16_t group_count_
Number of ThreadGroup in the engine.
thread::ThreadOptions thread_
static uint64_t calculate_local_small_memory_size(const EngineOptions &options)
uint32_t page_pool_size_mb_per_node_
Size of the page pool in MB per each NUMA node.
ThreadId get_total_thread_count() const
uint32_t snapshot_cache_size_mb_per_node_
Size of the snapshot cache in MB per each NUMA node.
uint32_t local_work_memory_size_mb_
Size of local and temporary work memory one transaction can use during transaction.
cache::CacheOptions cache_
uint16_t loggers_per_node_
Number of loggers per NUMA node.
Definition: log_options.hpp:80

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::EngineOptions::get_available_hugepage_memory ( std::ostream *  details_out)
static

A utility method to check how much hugepage memory is currently available.

Returns byte size of available memory backed by non-transparent hugepages.

Parameters
[out]details_outif there is any concern, we output some message to this stream.
Returns
byte size of available memory backed by non-transparent hugepages.

Definition at line 96 of file engine_options.cpp.

References ASSERT_ND.

Referenced by prescreen().

96  {
97  std::ifstream file("/proc/meminfo");
98  if (!file.is_open()) {
99  *details_out << "[FOEDUS] Failed to open /proc/meminfo. Cannot check available hugepages."
100  << std::endl;
101  return 0;
102  }
103 
104  std::string line;
105  uint64_t hugepage_size = 1ULL << 21;
106  uint64_t hugepage_count = 0;
107  while (std::getline(file, line)) {
108  if (line.find("Hugepagesize:") != std::string::npos) {
109  // /proc/meminfo should have "Hugepagesize: 1048576 kB" for 1GB hugepages
110  if (line.find("1048576 kB") != std::string::npos) {
111  hugepage_size = 1ULL << 30;
112  } else {
113  ASSERT_ND(line.find("2048 kB") != std::string::npos);
114  }
115  } else if (line.find("HugePages_Free:") != std::string::npos) {
116  ASSERT_ND(hugepage_count == 0);
117  // And "HugePages_Free: 12345" for the number of available hugepages.
118  std::string pages_str = line.substr(std::string("HugePages_Free:").length());
119  hugepage_count = std::stoull(pages_str);
120  }
121  }
122  file.close();
123  return hugepage_count * hugepage_size;
124 }
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the caller graph for this function:

const char* foedus::EngineOptions::get_tag_name ( ) const
inlineoverridevirtual

Returns an XML tag name for this object as a root element.

We might want to give a different name for same externalizable objects, so this is used only when it is the root element of xml.

Implements foedus::externalize::Externalizable.

Definition at line 149 of file engine_options.hpp.

ErrorStack foedus::EngineOptions::load ( tinyxml2::XMLElement *  element)
overridevirtual

Reads the content of this object from the given XML element.

Parameters
[in]elementthe XML element that represents this object

Expect errors due to missing-elements, out-of-range values, etc.

Implements foedus::externalize::Externalizable.

Definition at line 79 of file engine_options.cpp.

References CHECK_ERROR, EngineOptions(), foedus::externalize::Externalizable::get_child_element(), foedus::get_children(), and foedus::kRetOk.

79  {
80  *this = EngineOptions(); // This guarantees default values for optional XML elements.
81  for (externalize::Externalizable* child : get_children(this)) {
82  CHECK_ERROR(get_child_element(element, child->get_tag_name(), child));
83  }
84  return kRetOk;
85 }
std::vector< externalize::Externalizable * > get_children(EngineOptions *option)
static ErrorStack get_child_element(tinyxml2::XMLElement *parent, const std::string &tag, Externalizable *child, bool optional=false)
child Externalizable version
EngineOptions()
Constructs option values with default values.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.

Here is the call graph for this function:

EngineOptions & foedus::EngineOptions::operator= ( const EngineOptions other)

Definition at line 69 of file engine_options.cpp.

References ASSERT_ND, and foedus::get_children().

Referenced by EngineOptions().

69  {
70  auto mine = get_children(this);
71  auto others = get_children(&other);
72  ASSERT_ND(mine.size() == others.size());
73  for (size_t i = 0; i < mine.size(); ++i) {
74  mine[i]->assign(others[i]);
75  }
76  return *this;
77 }
std::vector< externalize::Externalizable * > get_children(EngineOptions *option)
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::EngineOptions::prescreen ( std::ostream *  details_out) const

Checks the machine environment and raises as many errors as possible before the engine starts up.

Parameters
[out]details_outWe write out detailed messages (more like a documentation to help users configure linux) to this stream, not to glog, because glog might not be initialized at this point.

There are several linux configurations the user must get right. Some, not all, of misconfigurations can be detected beforehand by checking the machine configuration and values of EngineOptions. This method has no side-effect. It just checks the environment.

Attention
This method can NOT detect all errors. For example, even if the number of hugepages is apparantely sufficient at this point but other processes might consume all of them by the time this engine allocates memory. Still, this method is supposed to catch 99% of mis-configurations beforehand.

Definition at line 126 of file engine_options.cpp.

References ASSERT_ND, calculate_required_memory(), ERROR_STACK_MSG, get_available_hugepage_memory(), foedus::assorted::int_div_ceil(), foedus::kErrorCodeEnvPrescreenFailed, foedus::kRetOk, memory_, prescreen_sysctl(), prescreen_ulimits(), foedus::memory::MemoryOptions::rigorous_page_boundary_check_, and foedus::memory::MemoryOptions::suppress_memory_prescreening_.

Referenced by foedus::EnginePimpl::check_valid_options().

126  {
127  ASSERT_ND(details_out);
128  std::stringstream out_buffer;
129  const uint64_t kMarginRatio = 4; // Add 1/4 to be safe
130 
131  // we don't stop prescreening on individual errors so that
132  // the user can see all issues at once.
133  bool has_any_error = false;
134 
135  if (RUNNING_ON_VALGRIND && memory_.rigorous_page_boundary_check_) {
136  out_buffer
137  << "[FOEDUS] WARNING. We strongly discourage rigorous_page_boundary_check_ on valgrind."
138  << " If you are sure what you are doing, consider increasing VG_N_SEGMENTS and recompile"
139  << " valgrind."
140  << std::endl;
141  }
142 
143  // Check available hugepages
144  uint64_t available_hugepage_bytes = get_available_hugepage_memory(&out_buffer);
145  uint64_t required_shared_bytes;
146  uint64_t required_local_bytes;
147  calculate_required_memory(&required_shared_bytes, &required_local_bytes);
148 
149  uint64_t required_total_bytes = required_shared_bytes + required_local_bytes;
150  uint64_t required_total_safe_bytes = required_total_bytes + required_total_bytes / kMarginRatio;
151  if (available_hugepage_bytes < required_total_safe_bytes) {
152  has_any_error = true;
153 
154  out_buffer
155  << "[FOEDUS] There are not enough hugepages available."
156  << " Based on the values in EngineOptions, the machine should have at least "
157  << required_total_safe_bytes << " bytes ("
158  << assorted::int_div_ceil(required_total_safe_bytes, 1ULL << 21) << " 2MB pages, or "
159  << assorted::int_div_ceil(required_total_safe_bytes, 1ULL << 30) << " 1GB pages)"
160  << " of hugepages, but there are only " << available_hugepage_bytes << " bytes available."
161  << " eg: sudo sh -c 'echo xyz > /proc/sys/vm/nr_hugepages' "
162  << std::endl;
163  }
164 
165  // Check ulimit values
166  prescreen_ulimits(required_total_safe_bytes, &has_any_error, &out_buffer);
167 
168  // Check sysctl values
169  uint64_t required_shared_safe_bytes
170  = required_shared_bytes + required_shared_bytes / kMarginRatio;
171  prescreen_sysctl(required_shared_safe_bytes, &has_any_error, &out_buffer);
172 
173  std::string error_messages = out_buffer.str();
174  *details_out << error_messages;
175 
176  if (has_any_error) {
178  *details_out
179  << "**********************************************************" << std::endl
180  << "**** ENVIRONMENT PRESCREENING DETECTED SOME ISSUES." << std::endl
181  << "**** HOWEVER, suppress_memory_prescreening option was specified." << std::endl
182  << "**** FOEDUS will start up." << std::endl
183  << "**********************************************************" << std::endl;
184  return kRetOk;
185  } else {
186  *details_out
187  << "**********************************************************" << std::endl
188  << "**** ENVIRONMENT PRESCREENING FAILED." << std::endl
189  << "**** FOEDUS does not start up because of issues listed above." << std::endl
190  << "**********************************************************" << std::endl;
191  return ERROR_STACK_MSG(kErrorCodeEnvPrescreenFailed, error_messages.c_str());
192  }
193  } else {
194  return kRetOk;
195  }
196 }
void prescreen_ulimits(uint64_t required_total_safe_bytes, bool *has_any_error, std::ostream *details_out) const
Subroutine of prescreen to check ulimit values.
memory::MemoryOptions memory_
0x000E : "GENERAL: Pre-screening of the environment detected" " an issue before start up...
Definition: error_code.hpp:122
void prescreen_sysctl(uint64_t required_shared_safe_bytes, bool *has_any_error, std::ostream *details_out) const
Subroutine of prescreen to check sysctl values.
static uint64_t get_available_hugepage_memory(std::ostream *details_out)
A utility method to check how much hugepage memory is currently available.
const ErrorStack kRetOk
Normal return value for no-error case.
void calculate_required_memory(uint64_t *shared_bytes, uint64_t *local_bytes) const
int64_t int_div_ceil(int64_t dividee, int64_t dividor)
Efficient ceil(dividee/dividor) for integer.
#define ERROR_STACK_MSG(e, m)
Overload of ERROR_STACK(e) to receive a custom error message.
bool suppress_memory_prescreening_
Whether to tolerate insufficient hugepages etc in the prescreen check.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
bool rigorous_page_boundary_check_
Whether to use mprotect() for page boundaries to detect bogus memory accesses.

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::EngineOptions::prescreen_sysctl ( uint64_t  required_shared_safe_bytes,
bool *  has_any_error,
std::ostream *  details_out 
) const

Subroutine of prescreen to check sysctl values.

Definition at line 269 of file engine_options.cpp.

References read_int_from_proc_fs().

Referenced by prescreen().

272  {
273  uint64_t shmall = read_int_from_proc_fs("/proc/sys/kernel/shmall", details_out);
274  if (shmall < required_shared_safe_bytes) {
275  *has_any_error = true;
276 
277  *details_out
278  << "[FOEDUS] /proc/sys/kernel/shmall is too small (" << shmall << ".)"
279  << " It must be at least " << required_shared_safe_bytes
280  << ". We recommend to simply set semi-inifinite value: "
281  << " sudo sysctl -w kernel.shmall=1152921504606846720"
282  << " and adding an entry 'kernel.shmall = 1152921504606846720' to /etc/sysctl.conf"
283  << " then sudo sysctl -p"
284  << std::endl;
285  }
286 
287  uint64_t shmmax = read_int_from_proc_fs("/proc/sys/kernel/shmmax", details_out);
288  if (shmmax < required_shared_safe_bytes) {
289  *has_any_error = true;
290 
291  *details_out
292  << "[FOEDUS] /proc/sys/kernel/shmmax is too small(" << shmmax << ")."
293  << " It must be at least " << required_shared_safe_bytes
294  << ". We recommend to simply set semi-inifinite value: "
295  << " sudo sysctl -w kernel.shmmax=9223372036854775807"
296  << " and adding an entry 'kernel.shmmax = 9223372036854775807' to /etc/sysctl.conf"
297  << " then sudo sysctl -p"
298  << std::endl;
299  }
300 
301  uint64_t shmmni = read_int_from_proc_fs("/proc/sys/kernel/shmmni", details_out);
302  const uint64_t kMinShmmni = 4096;
303  if (shmmni < kMinShmmni) {
304  *has_any_error = true;
305 
306  *details_out
307  << "[FOEDUS] /proc/sys/kernel/shmmni is too small(" << shmmni << ")."
308  << " It must be at least " << kMinShmmni
309  << ". We recommend to set : "
310  << " sudo sysctl -w kernel.shmmni=" << kMinShmmni
311  << " and adding an entry 'kernel.shmmni = " << kMinShmmni << "' to /etc/sysctl.conf"
312  << " then sudo sysctl -p"
313  << std::endl;
314  }
315 
316  uint64_t shm_group = read_int_from_proc_fs("/proc/sys/vm/hugetlb_shm_group", details_out);
317  // This one is not an error. It works in some environment even without this parameter.
318  // So, we only warn about it so far. Also, we don't even check if the user is in this group.
319  if (shm_group == 0) {
320  *details_out
321  << "[FOEDUS] Warning: /proc/sys/vm/hugetlb_shm_group is not set."
322  << " In some environment, this is fine: FOEDUS can allocate shared memory backed by hugepages"
323  << " without configuring it, but some environment might fail without it"
324  << std::endl;
325  }
326 
327  uint64_t map_count = read_int_from_proc_fs("/proc/sys/vm/max_map_count", details_out);
328  if (map_count <= 65530U) {
329  *details_out
330  << "[FOEDUS] /proc/sys/vm/max_map_count is only " << map_count
331  << " When rigorous_memory_boundary_check or rigorous_page_boundary_check features"
332  << " are specified, you must set a large number to it."
333  << ". We recommend to set : "
334  << " sudo sysctl -w vm.max_map_count=2147483647"
335  << " and adding an entry 'vm.max_map_count=2147483647' to /etc/sysctl.conf"
336  << " then sudo sysctl -p"
337  << std::endl;
338  }
339 }
static uint64_t read_int_from_proc_fs(const char *path, std::ostream *details_out)
A utility method to read /proc/ value in linux.

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::EngineOptions::prescreen_ulimits ( uint64_t  required_total_safe_bytes,
bool *  has_any_error,
std::ostream *  details_out 
) const

Subroutine of prescreen to check ulimit values.

Definition at line 198 of file engine_options.cpp.

References foedus::thread::ThreadOptions::get_total_thread_count(), and thread_.

Referenced by prescreen().

201  {
202  // nofile (number of file/socket that can be opened)
203  ::rlimit nofile_limit;
204  ::getrlimit(RLIMIT_NOFILE, &nofile_limit);
205  const uint64_t kMinNoFile = std::max(1U << 13, thread_.get_total_thread_count() * 16U);
206  if (nofile_limit.rlim_cur < kMinNoFile) {
207  *has_any_error = true;
208 
209  *details_out
210  << "[FOEDUS] ulimit -n is too small (" << nofile_limit.rlim_cur
211  << "). You must have at least " << kMinNoFile << std::endl;
212  }
213  // Record of a struggle: WTF,, no idea why, but I'm seeing an weird behavior only on Ubuntu.
214  // I did set limits.conf, and ulimit -n is saying 100000, but the above code returns "8192"
215  // on Ubuntu. As a tentative solution, reduced the min value to 8192.
216  // This happens only when I run the code as jenkins user from jenkins service.
217  // If I run it as myself, or "sudo su jenkins" then run it, it runs fine. WWWTTTTFFF.
218 
219  // 2015 Jun: Ahhh, I got it. It's because jenkins service is started by a daemon script:
220  // http://blog.mindfab.net/2013/12/changing-ulimits-for-jenkins-daemons.html
221  // "The important part is that you have to specify the ulimits, e.g., for the number
222  // of open files before start-stop-daemon is called. The reason is that
223  // **start-stop-daemon doesn't consider pam**
224  // and hence will not find the limits which have been specified in /etc/security/limits.conf."
225 
226  // Note that proc means threads in linux.
227  ::rlimit proc_limit;
228  ::getrlimit(RLIMIT_NPROC, &proc_limit);
229  const uint64_t kMinProc = std::max(1U << 12, thread_.get_total_thread_count() * 2U);
230  if (proc_limit.rlim_cur < kMinProc) {
231  *has_any_error = true;
232 
233  *details_out
234  << "[FOEDUS] ulimit -u is too small(" << proc_limit.rlim_cur
235  << "). You must have at least " << kMinProc << std::endl;
236  }
237 
238  // memlock
239  ::rlimit memlock_limit;
240  ::getrlimit(RLIMIT_MEMLOCK, &memlock_limit);
241  if (memlock_limit.rlim_cur * (1ULL << 10) < required_total_safe_bytes) {
242  *has_any_error = true;
243 
244  *details_out
245  << "[FOEDUS] ulimit -l is too small(" << memlock_limit.rlim_cur
246  << "). You must have at least "
247  << (required_total_safe_bytes >> 10) << std::endl;
248  }
249 
250  // Should also check: RLIMIT_AS, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_LOCKS
251  // but it's rarely an issue in typical setup.
252 }
thread::ThreadOptions thread_
ThreadId get_total_thread_count() const

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::EngineOptions::read_int_from_proc_fs ( const char *  path,
std::ostream *  details_out 
)
static

A utility method to read /proc/ value in linux.

Parameters
[in]pathfile path representing a config value, eg "/proc/sys/kernel/shmall"
[out]details_outif there is any concern, we output some message to this stream.
Returns
an integer value stored in /proc/...

Definition at line 254 of file engine_options.cpp.

Referenced by prescreen_sysctl().

254  {
255  // _sysctl() is now strongly discouraged, so let's simlpy read as a file.
256  std::ifstream file(path);
257  if (!file.is_open()) {
258  *details_out << "[FOEDUS] Fails to read " << path;
259  return 0;
260  }
261 
262  std::string line;
263  std::getline(file, line);
264  file.close();
265 
266  return std::stoull(line);
267 }

Here is the caller graph for this function:

ErrorStack foedus::EngineOptions::save ( tinyxml2::XMLElement *  element) const
overridevirtual

Writes the content of this object to the given XML element.

Parameters
[in]elementthe XML element that represents this object

Expect only out-of-memory error. We receive the XML element this object will represent, so this method does not determine the XML element name of itself. The parent object determines children's tag names because one parent object might have multiple child objects of the same type with different XML element name.

Implements foedus::externalize::Externalizable.

Definition at line 87 of file engine_options.cpp.

References foedus::externalize::Externalizable::add_child_element(), CHECK_ERROR, foedus::get_children(), foedus::externalize::Externalizable::insert_comment(), and foedus::kRetOk.

87  {
88  CHECK_ERROR(insert_comment(element, "Set of options given to the engine at start-up"));
89  for (const externalize::Externalizable* child : get_children(this)) {
90  CHECK_ERROR(add_child_element(element, child->get_tag_name(), "", *child));
91  }
92  return kRetOk;
93 }
std::vector< externalize::Externalizable * > get_children(EngineOptions *option)
static ErrorStack add_child_element(tinyxml2::XMLElement *parent, const std::string &tag, const std::string &comment, const Externalizable &child)
child Externalizable version
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.

Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const EngineOptions v 
)
friend

Definition at line 149 of file engine_options.hpp.

Member Data Documentation

debugging::DebuggingOptions foedus::EngineOptions::debugging_

Definition at line 137 of file engine_options.hpp.

proc::ProcOptions foedus::EngineOptions::proc_
restart::RestartOptions foedus::EngineOptions::restart_

Definition at line 141 of file engine_options.hpp.

savepoint::SavepointOptions foedus::EngineOptions::savepoint_
thread::ThreadOptions foedus::EngineOptions::thread_

Definition at line 146 of file engine_options.hpp.

Referenced by foedus::soc::NodeMemoryAnchors::allocate_arrays(), foedus::memory::NumaCoreMemory::calculate_local_small_memory_size(), foedus::soc::SharedMemoryRepo::calculate_node_memory_size(), calculate_required_memory(), foedus::storage::array::ArrayPartitioner::design_partition(), foedus::storage::sequential::SequentialStoragePimpl::drop(), foedus::storage::sequential::SequentialComposer::drop_volatiles(), foedus::memory::EngineMemory::dump_free_memory_stat(), foedus::storage::sequential::SequentialStoragePimpl::for_every_page(), foedus::storage::sequential::SequentialStoragePimpl::get_head_pointer(), foedus::Engine::get_soc_count(), foedus::storage::sequential::SequentialStoragePimpl::get_tail_pointer(), foedus::thread::ThreadPoolPimpl::impersonate(), foedus::thread::ThreadPoolPimpl::impersonate_on_numa_node(), foedus::storage::sequential::SequentialStoragePimpl::initialize_head_tail_pages(), foedus::soc::SocManagerPimpl::initialize_master(), foedus::thread::ThreadGroup::initialize_once(), foedus::thread::ThreadPoolPimpl::initialize_once(), foedus::cache::CacheManagerPimpl::initialize_once(), foedus::memory::EngineMemory::initialize_once(), foedus::memory::NumaCoreMemory::initialize_once(), foedus::EnginePimpl::initialize_once(), foedus::proc::ProcManagerPimpl::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), foedus::soc::SocManagerPimpl::launch_emulated_children(), foedus::soc::SocManagerPimpl::launch_forked_children(), foedus::soc::SocManagerPimpl::launch_spawned_children(), prescreen_ulimits(), foedus::thread::ThreadPimpl::set_thread_schedule(), foedus::thread::ThreadGroupRef::ThreadGroupRef(), foedus::savepoint::SavepointManagerPimpl::update_shared_savepoint(), foedus::soc::SocManagerPimpl::wait_for_child_attach(), foedus::soc::SocManagerPimpl::wait_for_child_terminate(), and foedus::soc::SocManagerPimpl::wait_for_children_module().


The documentation for this struct was generated from the following files: