libfoedus-core
FOEDUS Core Library
foedus::memory::MemoryOptions Struct Referencefinal

Set of options for memory manager. More...

Detailed Description

Set of options for memory manager.

This is a POD struct. Default destructor/copy-constructor/assignment operator work fine.

Definition at line 32 of file memory_options.hpp.

#include <memory_options.hpp>

Inheritance diagram for foedus::memory::MemoryOptions:
Collaboration diagram for foedus::memory::MemoryOptions:

Public Types

enum  Constants { kDefaultPagePoolSizeMbPerNode = 1 << 10 }
 Constant values. More...
 

Public Member Functions

 MemoryOptions ()
 Constructs option values with default 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...
 

Public Attributes

bool suppress_memory_prescreening_
 Whether to tolerate insufficient hugepages etc in the prescreen check. More...
 
bool use_numa_alloc_
 Whether to use numa_alloc_interleaved()/numa_alloc_onnode() to allocate memories in NumaCoreMemory and NumaNodeMemory. More...
 
bool interleave_numa_alloc_
 Whether to use numa_alloc_interleaved() instead of numa_alloc_onnode(). More...
 
bool use_mmap_hugepages_
 Whether to use non-transparent hugepages for big memories (1GB huge pages). More...
 
bool rigorous_memory_boundary_check_
 Whether to use mprotect() for memory boundaries to detect bogus memory accesses. More...
 
bool rigorous_page_boundary_check_
 Whether to use mprotect() for page boundaries to detect bogus memory accesses. More...
 
uint32_t page_pool_size_mb_per_node_
 Size of the page pool in MB per each NUMA node. More...
 
uint32_t private_page_pool_initial_grab_
 How many pages each NumaCoreMemory initially grabs when it is initialized. More...
 

Friends

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

Additional Inherited Members

- 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...
 

Member Enumeration Documentation

Constant values.

Enumerator
kDefaultPagePoolSizeMbPerNode 

Default value for page_pool_size_mb_per_node_.

Definition at line 34 of file memory_options.hpp.

34  {
37  };
Default value for page_pool_size_mb_per_node_.

Constructor & Destructor Documentation

foedus::memory::MemoryOptions::MemoryOptions ( )

Constructs option values with default values.

Definition at line 25 of file memory_options.cpp.

References interleave_numa_alloc_, kDefaultPagePoolSizeMbPerNode, foedus::memory::PagePoolOffsetChunk::kMaxSize, page_pool_size_mb_per_node_, private_page_pool_initial_grab_, rigorous_memory_boundary_check_, rigorous_page_boundary_check_, suppress_memory_prescreening_, use_mmap_hugepages_, and use_numa_alloc_.

25  {
27  use_numa_alloc_ = true;
28  interleave_numa_alloc_ = false;
29  use_mmap_hugepages_ = false;
34 }
uint32_t private_page_pool_initial_grab_
How many pages each NumaCoreMemory initially grabs when it is initialized.
Max number of pointers to pack.
Definition: page_pool.hpp:54
bool rigorous_memory_boundary_check_
Whether to use mprotect() for memory boundaries to detect bogus memory accesses.
bool use_mmap_hugepages_
Whether to use non-transparent hugepages for big memories (1GB huge pages).
uint32_t page_pool_size_mb_per_node_
Size of the page pool in MB per each NUMA node.
bool interleave_numa_alloc_
Whether to use numa_alloc_interleaved() instead of numa_alloc_onnode().
Default value for page_pool_size_mb_per_node_.
bool suppress_memory_prescreening_
Whether to tolerate insufficient hugepages etc in the prescreen check.
bool rigorous_page_boundary_check_
Whether to use mprotect() for page boundaries to detect bogus memory accesses.
bool use_numa_alloc_
Whether to use numa_alloc_interleaved()/numa_alloc_onnode() to allocate memories in NumaCoreMemory an...

Member Function Documentation

void foedus::memory::MemoryOptions::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 133 of file memory_options.hpp.

const char* foedus::memory::MemoryOptions::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 133 of file memory_options.hpp.

ErrorStack foedus::memory::MemoryOptions::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 36 of file memory_options.cpp.

References EXTERNALIZE_LOAD_ELEMENT, interleave_numa_alloc_, foedus::kRetOk, page_pool_size_mb_per_node_, private_page_pool_initial_grab_, rigorous_memory_boundary_check_, rigorous_page_boundary_check_, suppress_memory_prescreening_, use_mmap_hugepages_, and use_numa_alloc_.

36  {
45  return kRetOk;
46 }
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
uint32_t private_page_pool_initial_grab_
How many pages each NumaCoreMemory initially grabs when it is initialized.
bool rigorous_memory_boundary_check_
Whether to use mprotect() for memory boundaries to detect bogus memory accesses.
bool use_mmap_hugepages_
Whether to use non-transparent hugepages for big memories (1GB huge pages).
uint32_t page_pool_size_mb_per_node_
Size of the page pool in MB per each NUMA node.
bool interleave_numa_alloc_
Whether to use numa_alloc_interleaved() instead of numa_alloc_onnode().
const ErrorStack kRetOk
Normal return value for no-error case.
bool suppress_memory_prescreening_
Whether to tolerate insufficient hugepages etc in the prescreen check.
bool rigorous_page_boundary_check_
Whether to use mprotect() for page boundaries to detect bogus memory accesses.
bool use_numa_alloc_
Whether to use numa_alloc_interleaved()/numa_alloc_onnode() to allocate memories in NumaCoreMemory an...
ErrorStack foedus::memory::MemoryOptions::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 48 of file memory_options.cpp.

References CHECK_ERROR, EXTERNALIZE_SAVE_ELEMENT, foedus::externalize::Externalizable::insert_comment(), interleave_numa_alloc_, foedus::kRetOk, page_pool_size_mb_per_node_, private_page_pool_initial_grab_, rigorous_memory_boundary_check_, rigorous_page_boundary_check_, suppress_memory_prescreening_, use_mmap_hugepages_, and use_numa_alloc_.

48  {
49  CHECK_ERROR(insert_comment(element, "Set of options for memory manager"));
50 
52  "Whether to tolerate insufficient hugepages etc in the prescreen check.");
54  "Whether to use ::numa_alloc_interleaved()/::numa_alloc_onnode() to allocate memories"
55  " in NumaCoreMemory and NumaNodeMemory.\n"
56  " If false, we use usual posix_memalign() instead.\n"
57  " If everything works correctly, ::numa_alloc_interleaved()/::numa_alloc_onnode()\n"
58  " should result in much better performance because each thread should access only\n"
59  " the memories allocated for the NUMA node. Default is true..");
61  "Whether to use ::numa_alloc_interleaved() instead of ::numa_alloc_onnode()\n"
62  " If everything works correctly, numa_alloc_onnode() should result in much better\n"
63  " performance because interleaving just wastes memory if it is very rare to access other\n"
64  " node's memory. Default is false.\n"
65  " If use_numa_alloc_ is false, this configuration has no meaning.");
67  "Whether to use non-transparent hugepages for big memories (1GB huge pages)\n"
68  " To use this, you have to set up non-transparent hugepages that requires a reboot.\n"
69  " See the readme fore more details.");
71  "Whether to use mprotect() for memory boundaries to detect bogus memory accesses.");
73  "Whether to use mprotect() for page boundaries to detect bogus memory accesses.");
75  "Size of the page pool in MB per each NUMA node. Must be multiply of 2MB.");
77  "How many pages each NumaCoreMemory initially grabs when it is initialized."
78  " Default is 50% of PagePoolOffsetChunk::kMaxSize\n"
79  " Obviously, private_page_pool_initial_grab_ * kPageSize * number-of-threads must be"
80  " within page_pool_size_mb_per_node_ to start up the engine.");
81  return kRetOk;
82 }
uint32_t private_page_pool_initial_grab_
How many pages each NumaCoreMemory initially grabs when it is initialized.
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
bool rigorous_memory_boundary_check_
Whether to use mprotect() for memory boundaries to detect bogus memory accesses.
bool use_mmap_hugepages_
Whether to use non-transparent hugepages for big memories (1GB huge pages).
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
uint32_t page_pool_size_mb_per_node_
Size of the page pool in MB per each NUMA node.
bool interleave_numa_alloc_
Whether to use numa_alloc_interleaved() instead of numa_alloc_onnode().
const ErrorStack kRetOk
Normal return value for no-error case.
bool suppress_memory_prescreening_
Whether to tolerate insufficient hugepages etc in the prescreen check.
#define EXTERNALIZE_SAVE_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
bool rigorous_page_boundary_check_
Whether to use mprotect() for page boundaries to detect bogus memory accesses.
bool use_numa_alloc_
Whether to use numa_alloc_interleaved()/numa_alloc_onnode() to allocate memories in NumaCoreMemory an...

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 133 of file memory_options.hpp.

Member Data Documentation

bool foedus::memory::MemoryOptions::interleave_numa_alloc_

Whether to use numa_alloc_interleaved() instead of numa_alloc_onnode().

If everything works correctly, numa_alloc_onnode() should result in much better performance because interleaving just wastes memory if it is very rare to access other node's memory. Default is false. If use_numa_alloc_ is false, this configuration has no meaning.

Definition at line 77 of file memory_options.hpp.

Referenced by load(), MemoryOptions(), and save().

uint32_t foedus::memory::MemoryOptions::page_pool_size_mb_per_node_

Size of the page pool in MB per each NUMA node.

Must be multiply of 2MB. Default is 1GB. The total amount of memory is page_pool_size_mb_per_node_ *

Definition at line 122 of file memory_options.hpp.

Referenced by foedus::soc::SharedMemoryRepo::calculate_node_memory_size(), foedus::EngineOptions::calculate_required_memory(), foedus::memory::NumaNodeMemory::initialize_once(), load(), MemoryOptions(), foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef(), and save().

uint32_t foedus::memory::MemoryOptions::private_page_pool_initial_grab_

How many pages each NumaCoreMemory initially grabs when it is initialized.

Default is 50% of PagePoolOffsetChunk::MAX_SIZE. Obviously, private_page_pool_initial_grab_ * kPageSize * number-of-threads-per-node must be within page_pool_size_mb_per_node_ to start up the engine.

Definition at line 131 of file memory_options.hpp.

Referenced by foedus::cache::CacheManagerPimpl::initialize_once(), foedus::memory::NumaCoreMemory::initialize_once(), load(), MemoryOptions(), and save().

bool foedus::memory::MemoryOptions::rigorous_memory_boundary_check_

Whether to use mprotect() for memory boundaries to detect bogus memory accesses.

When true, we put a dummy mprotect-ed pages between chunks of shared memories. Using this might cause performance degradation, but it helps debugging. Default is false.

Definition at line 94 of file memory_options.hpp.

Referenced by foedus::soc::SharedMemoryRepo::allocate_shared_memories(), foedus::soc::SharedMemoryRepo::attach_shared_memories(), load(), MemoryOptions(), and save().

bool foedus::memory::MemoryOptions::rigorous_page_boundary_check_

Whether to use mprotect() for page boundaries to detect bogus memory accesses.

Similar to rigorous_memory_boundary_check_, but this one is about page pools. When true, we waste a half of volatile/snapshot page pool, putting mprotect in odd-numbered page indexes. The threads receive only the even-numbered indexes, so if any read/write overruns a page, a signal is fired. This makes the execution quite slower and wastes half of memory, so use it just for debugging. This flag also disables hugepages used for snapshot page pool for mprotect to work, so makes it really SLOW. Default is false.

Attention
To use this feature with large page pool sizes, you must increase max_map_count. sudo sysctl -w vm.max_map_count=2147483647 Otherwise you will get out-of-memory crashes. Linux's default value is only 65530.
Note
When FOEDUS is running on a valgrind process, you shouldn't turn this on because valgrind uses a hard-coded limit VG_N_SEGMENTS rather than vm.max_map_count. However, if you are sure the number of mprotect-ed pages are less than 64k, you can.
See also
foedus::assorted::ProtectedBoundary

Definition at line 114 of file memory_options.hpp.

Referenced by foedus::soc::SharedMemoryRepo::allocate_shared_memories(), foedus::memory::NumaNodeMemory::initialize_once(), load(), MemoryOptions(), foedus::EngineOptions::prescreen(), and save().

bool foedus::memory::MemoryOptions::suppress_memory_prescreening_

Whether to tolerate insufficient hugepages etc in the prescreen check.

The default is false. When true, we don't throw an error at the startup prescreening, which might be too conservatively estimating available memories in the environment. Even in the case, we still output the warning messages to the log. In general we do recommend leaving it to false because the user should be aware of a chance of insufficient memories before costly initializations. It's always a good idea to have margins in available memory.

Definition at line 55 of file memory_options.hpp.

Referenced by load(), MemoryOptions(), foedus::EngineOptions::prescreen(), and save().

bool foedus::memory::MemoryOptions::use_mmap_hugepages_

Whether to use non-transparent hugepages for big memories (1GB huge pages).

To use this, you have to set up non-transparent hugepages that requires a reboot. See the readme fore more details.

Definition at line 85 of file memory_options.hpp.

Referenced by foedus::memory::NumaNodeMemory::allocate_numa_memory_general(), load(), MemoryOptions(), and save().

bool foedus::memory::MemoryOptions::use_numa_alloc_

Whether to use numa_alloc_interleaved()/numa_alloc_onnode() to allocate memories in NumaCoreMemory and NumaNodeMemory.

If false, we use usual posix_memalign() instead. If everything works correctly, numa_alloc_interleaved()/numa_alloc_onnode() should result in much better performance because each thread should access only the memories allocated for the NUMA node. Default is true.

Definition at line 67 of file memory_options.hpp.

Referenced by load(), MemoryOptions(), and save().


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