libfoedus-core
FOEDUS Core Library
|
Set of options for memory manager. More...
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>
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... | |
![]() | |
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 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... | |
Constant values.
Enumerator | |
---|---|
kDefaultPagePoolSizeMbPerNode |
Default value for page_pool_size_mb_per_node_. |
Definition at line 34 of file memory_options.hpp.
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_.
|
inlineoverridevirtual |
Polymorphic assign operator.
This should invoke operator= of the derived class.
[in] | other | assigned value. It must be dynamic-castable to the assignee class. |
Implements foedus::externalize::Externalizable.
Definition at line 133 of file memory_options.hpp.
|
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.
|
overridevirtual |
Reads the content of this object from the given XML element.
[in] | element | the 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_.
|
overridevirtual |
Writes the content of this object to the given XML element.
[in] | element | the 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_.
|
friend |
Definition at line 133 of file memory_options.hpp.
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.
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().