libfoedus-core
FOEDUS Core Library
foedus::thread::ThreadOptions Struct Referencefinal

Set of options about threads and thread-groups. More...

Detailed Description

Set of options about threads and thread-groups.

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

Definition at line 31 of file thread_options.hpp.

#include <thread_options.hpp>

Inheritance diagram for foedus::thread::ThreadOptions:
Collaboration diagram for foedus::thread::ThreadOptions:

Public Member Functions

 ThreadOptions ()
 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...
 
ThreadId get_total_thread_count () const
 
- 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

uint16_t group_count_
 Number of ThreadGroup in the engine. More...
 
ThreadLocalOrdinal thread_count_per_group_
 Number of Thread in each ThreadGroup. More...
 
bool overwrite_thread_schedule_
 Whether to overwrite policy/priority of worker threads. More...
 
ThreadPolicy thread_policy_
 Thread policy for worker threads. More...
 
ThreadPriority thread_priority_
 Thread priority for worker threads. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const ThreadOptions &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...
 

Constructor & Destructor Documentation

foedus::thread::ThreadOptions::ThreadOptions ( )

Constructs option values with default values.

Definition at line 28 of file thread_options.cpp.

References group_count_, foedus::thread::kPriorityDefault, foedus::thread::kScheduleFifo, numa_available(), numa_num_configured_cpus(), numa_num_configured_nodes(), overwrite_thread_schedule_, thread_count_per_group_, thread_policy_, and thread_priority_.

28  {
29  int total_cores;
30  if (::numa_available() < 0) {
31  group_count_ = 1;
32  total_cores = std::thread::hardware_concurrency(); // seems to use pthread_num_processors_np?
33  } else {
35  if (group_count_ == 0) {
36  group_count_ = 1;
37  }
38 
39  total_cores = ::numa_num_configured_cpus();
40  if (total_cores == 0) {
41  total_cores = 1;
42  }
43  }
44  thread_count_per_group_ = total_cores / group_count_;
48 }
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup.
bool overwrite_thread_schedule_
Whether to overwrite policy/priority of worker threads.
int numa_num_configured_nodes()
int numa_num_configured_cpus()
int numa_available(void)
ThreadPriority thread_priority_
Thread priority for worker threads.
uint16_t group_count_
Number of ThreadGroup in the engine.
ThreadPolicy thread_policy_
Thread policy for worker threads.

Here is the call graph for this function:

Member Function Documentation

void foedus::thread::ThreadOptions::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 60 of file thread_options.hpp.

62 {
const char* foedus::thread::ThreadOptions::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 60 of file thread_options.hpp.

62 {
ThreadId foedus::thread::ThreadOptions::get_total_thread_count ( ) const
inline

Definition at line 62 of file thread_options.hpp.

References thread_count_per_group_.

Referenced by foedus::EngineOptions::calculate_required_memory(), foedus::cache::CacheManagerPimpl::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), and foedus::EngineOptions::prescreen_ulimits().

62  {
64  }
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup.
uint16_t group_count_
Number of ThreadGroup in the engine.

Here is the caller graph for this function:

ErrorStack foedus::thread::ThreadOptions::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 50 of file thread_options.cpp.

References EXTERNALIZE_LOAD_ELEMENT, EXTERNALIZE_LOAD_ENUM_ELEMENT, group_count_, foedus::kRetOk, overwrite_thread_schedule_, thread_count_per_group_, thread_policy_, and thread_priority_.

50  {
56  return kRetOk;
57 }
#define EXTERNALIZE_LOAD_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup.
bool overwrite_thread_schedule_
Whether to overwrite policy/priority of worker threads.
#define EXTERNALIZE_LOAD_ENUM_ELEMENT(element, attribute)
Reads a child xml element to load a member variable of this object.
ThreadPriority thread_priority_
Thread priority for worker threads.
uint16_t group_count_
Number of ThreadGroup in the engine.
const ErrorStack kRetOk
Normal return value for no-error case.
ThreadPolicy thread_policy_
Thread policy for worker threads.
ErrorStack foedus::thread::ThreadOptions::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 59 of file thread_options.cpp.

References CHECK_ERROR, EXTERNALIZE_SAVE_ELEMENT, EXTERNALIZE_SAVE_ENUM_ELEMENT, group_count_, foedus::externalize::Externalizable::insert_comment(), foedus::kRetOk, overwrite_thread_schedule_, thread_count_per_group_, thread_policy_, and thread_priority_.

59  {
60  CHECK_ERROR(insert_comment(element, "Set of options about threads and thread-groups"));
61 
63  "Number of ThreadGroup in the engine.\n"
64  " Default value is hardware NUMA node count (::numa_num_configured_nodes()).");
66  "Number of Thread in each ThreadGroup. Default value is hardware NUMA core count;\n"
67  " ::numa_num_configured_cpus() / ::numa_num_configured_nodes()");
69  "Whether to overwrite policy/priority of worker threads.");
71  "Thread policy for worker threads. ignored if overwrite_thread_schedule_==false\n"
72  "The values are compatible with pthread's values.");
74  "Thread priority for worker threads. ignored if overwrite_thread_schedule_==false\n"
75  "The values are compatible with pthread's values.");
76  return kRetOk;
77 }
static ErrorStack insert_comment(tinyxml2::XMLElement *element, const std::string &comment)
#define EXTERNALIZE_SAVE_ENUM_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup.
bool overwrite_thread_schedule_
Whether to overwrite policy/priority of worker threads.
ThreadPriority thread_priority_
Thread priority for worker threads.
uint16_t group_count_
Number of ThreadGroup in the engine.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ThreadPolicy thread_policy_
Thread policy for worker threads.
#define EXTERNALIZE_SAVE_ELEMENT(element, attribute, comment)
Adds an xml element to represent a member variable of this object.

Here is the call graph for this function:

Friends And Related Function Documentation

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

Definition at line 60 of file thread_options.hpp.

62 {

Member Data Documentation

uint16_t foedus::thread::ThreadOptions::group_count_

Number of ThreadGroup in the engine.

Default value is hardware NUMA node count (numa_num_configured_nodes()). Note that the type of this value is NOT ThreadGroupId so that we can handle 256 NUMA nodes. Otherwise 256 becomes 0.

Definition at line 43 of file thread_options.hpp.

Referenced by foedus::memory::NumaCoreMemory::calculate_local_small_memory_size(), foedus::EngineOptions::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::storage::sequential::SequentialStoragePimpl::initialize_head_tail_pages(), foedus::soc::SocManagerPimpl::initialize_master(), 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(), load(), save(), ThreadOptions(), 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().

bool foedus::thread::ThreadOptions::overwrite_thread_schedule_

Whether to overwrite policy/priority of worker threads.

default false.

Definition at line 53 of file thread_options.hpp.

Referenced by load(), save(), foedus::thread::ThreadPimpl::set_thread_schedule(), and ThreadOptions().

ThreadPolicy foedus::thread::ThreadOptions::thread_policy_

Thread policy for worker threads.

ignored if overwrite_thread_schedule_==false

Definition at line 56 of file thread_options.hpp.

Referenced by load(), save(), foedus::thread::ThreadPimpl::set_thread_schedule(), and ThreadOptions().

ThreadPriority foedus::thread::ThreadOptions::thread_priority_

Thread priority for worker threads.

ignored if overwrite_thread_schedule_==false

Definition at line 58 of file thread_options.hpp.

Referenced by load(), save(), foedus::thread::ThreadPimpl::set_thread_schedule(), and ThreadOptions().


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