libfoedus-core
FOEDUS Core Library
|
Repository of all shared memory in one FOEDUS instance. More...
Repository of all shared memory in one FOEDUS instance.
These are the memories shared across SOCs, which are allocated at initialization. Be super careful on objects placed in these shared memories. You can't put objects with heap-allocated contents, such as std::string.
Definition at line 463 of file shared_memory_repo.hpp.
#include <shared_memory_repo.hpp>
Static Public Member Functions | |
static uint64_t | calculate_global_memory_size (uint64_t xml_size, const EngineOptions &options) |
static uint64_t | calculate_node_memory_size (const EngineOptions &options) |
|
inline |
Definition at line 465 of file shared_memory_repo.hpp.
|
inline |
Definition at line 470 of file shared_memory_repo.hpp.
References deallocate_shared_memories().
|
delete |
ErrorStack foedus::soc::SharedMemoryRepo::allocate_shared_memories | ( | uint64_t | upid, |
Eid | eid, | ||
const EngineOptions & | options | ||
) |
Master process creates shared memories by calling this method.
Definition at line 96 of file shared_memory_repo.cpp.
References foedus::soc::align_2mb(), foedus::memory::SharedMemory::alloc(), calculate_global_memory_size(), calculate_node_memory_size(), CHECK_ERROR, deallocate_shared_memories(), foedus::memory::SharedMemory::get_block(), foedus::soc::get_self_path(), foedus::soc::MasterEngineStatus::kInitial, foedus::soc::kMaxSocs, foedus::kRetOk, foedus::soc::GlobalMemoryAnchors::master_status_memory_, foedus::EngineOptions::memory_, foedus::memory::MemoryOptions::rigorous_memory_boundary_check_, foedus::memory::MemoryOptions::rigorous_page_boundary_check_, foedus::externalize::Externalizable::save_to_stream(), and foedus::soc::MasterEngineStatus::status_code_.
Referenced by foedus::soc::SocManagerPimpl::initialize_master().
ErrorStack foedus::soc::SharedMemoryRepo::attach_shared_memories | ( | uint64_t | master_upid, |
Eid | master_eid, | ||
SocId | my_soc_id, | ||
EngineOptions * | options | ||
) |
Child processes (emulated or not) set a reference to shared memory and receive the EngnieOption value by calling this method.
[in] | master_upid | Universal (or Unique) ID of the master process. This is the parameter that has to be passed from the master process to child processes. |
[in] | master_eid | Engine ID of the master process. This is another parameter that has to be passed from the master process to child processes. |
[in] | my_soc_id | SOC ID of this node. |
[out] | options | One of the shared memory contains the EngineOption values. This method also retrieves them from the shared memory. |
Definition at line 165 of file shared_memory_repo.cpp.
References ASSERT_ND, foedus::memory::SharedMemory::attach(), change_child_status(), CHECK_ERROR, deallocate_shared_memories(), ERROR_STACK, foedus::memory::SharedMemory::get_block(), foedus::soc::get_master_path(), foedus::memory::SharedMemory::is_null(), foedus::kErrorCodeSocShmAttachFailed, foedus::soc::ChildEngineStatus::kFatalError, foedus::kRetOk, foedus::externalize::Externalizable::load_from_string(), foedus::EngineOptions::memory_, and foedus::memory::MemoryOptions::rigorous_memory_boundary_check_.
Referenced by foedus::soc::SocManagerPimpl::initialize_child().
|
static |
Definition at line 365 of file shared_memory_repo.cpp.
References foedus::soc::align_4kb(), foedus::soc::GlobalMemoryAnchors::kLogManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kMasterStatusMemorySize, foedus::soc::GlobalMemoryAnchors::kMetaLoggerSize, foedus::soc::GlobalMemoryAnchors::kRestartManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kSavepointManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kSnapshotManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kStorageManagerMemorySize, foedus::soc::GlobalMemoryAnchors::kStorageMemorySize, foedus::soc::GlobalMemoryAnchors::kXctManagerMemorySize, foedus::storage::StorageOptions::max_storages_, foedus::storage::StorageOptions::partitioner_data_memory_mb_, foedus::soc::SocOptions::shared_user_memory_size_kb_, foedus::EngineOptions::soc_, and foedus::EngineOptions::storage_.
Referenced by allocate_shared_memories(), and foedus::EngineOptions::calculate_required_memory().
|
static |
Definition at line 505 of file shared_memory_repo.cpp.
References foedus::soc::align_4kb(), foedus::soc::NodeMemoryAnchors::kChildStatusMemorySize, foedus::soc::NodeMemoryAnchors::kLoggerMemorySize, foedus::soc::NodeMemoryAnchors::kLogReducerMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsRwAsyncMappingMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsRwLockMemorySize, foedus::soc::ThreadMemoryAnchors::kMcsWwLockMemorySize, foedus::soc::NodeMemoryAnchors::kPagePoolMemorySize, foedus::soc::NodeMemoryAnchors::kProcManagerMemorySize, foedus::soc::ThreadMemoryAnchors::kTaskInputMemorySize, foedus::soc::ThreadMemoryAnchors::kTaskOutputMemorySize, foedus::soc::ThreadMemoryAnchors::kThreadMemorySize, foedus::EngineOptions::log_, foedus::snapshot::SnapshotOptions::log_reducer_buffer_mb_, foedus::log::LogOptions::loggers_per_node_, foedus::proc::ProcOptions::max_proc_count_, foedus::storage::StorageOptions::max_storages_, foedus::EngineOptions::memory_, foedus::memory::MemoryOptions::page_pool_size_mb_per_node_, foedus::EngineOptions::proc_, foedus::EngineOptions::snapshot_, foedus::EngineOptions::storage_, foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.
Referenced by allocate_shared_memories(), and foedus::EngineOptions::calculate_required_memory().
void foedus::soc::SharedMemoryRepo::change_child_status | ( | SocId | node, |
ChildEngineStatus::StatusCode | new_status | ||
) |
Definition at line 547 of file shared_memory_repo.cpp.
References foedus::soc::ChildEngineStatus::change_status_atomic(), and foedus::soc::NodeMemoryAnchors::child_status_memory_.
Referenced by attach_shared_memories(), foedus::soc::SocManagerPimpl::child_main_common(), and foedus::soc::SocManagerPimpl::initialize_child().
void foedus::soc::SharedMemoryRepo::change_master_status | ( | MasterEngineStatus::StatusCode | new_status | ) |
Definition at line 539 of file shared_memory_repo.cpp.
References foedus::soc::MasterEngineStatus::change_status_atomic(), and foedus::soc::GlobalMemoryAnchors::master_status_memory_.
Referenced by foedus::EnginePimpl::initialize_once(), foedus::soc::SocManagerPimpl::launch_forked_children(), foedus::soc::SocManagerPimpl::launch_spawned_children(), foedus::soc::SocManagerPimpl::uninitialize_once(), foedus::EnginePimpl::uninitialize_once(), foedus::soc::SocManagerPimpl::wait_for_child_attach(), and foedus::soc::SocManagerPimpl::wait_for_child_terminate().
void foedus::soc::SharedMemoryRepo::deallocate_shared_memories | ( | ) |
Detaches and releases the shared memories.
In child processes, this just detaches.
Definition at line 223 of file shared_memory_repo.cpp.
References foedus::assorted::ProtectedBoundary::assert_boundary(), foedus::soc::GlobalMemoryAnchors::clear(), foedus::memory::SharedMemory::is_null(), mark_for_release(), foedus::soc::GlobalMemoryAnchors::protected_boundaries_, foedus::soc::NodeMemoryAnchors::protected_boundaries_, foedus::soc::GlobalMemoryAnchors::protected_boundaries_count_, foedus::soc::NodeMemoryAnchors::protected_boundaries_count_, foedus::soc::GlobalMemoryAnchors::protected_boundaries_needs_release_, foedus::memory::SharedMemory::release_block(), and foedus::assorted::ProtectedBoundary::release_protect().
Referenced by allocate_shared_memories(), attach_shared_memories(), foedus::soc::SocManagerPimpl::initialize_master(), foedus::soc::SocManagerPimpl::launch_forked_children(), foedus::soc::SocManagerPimpl::launch_spawned_children(), foedus::soc::SocManagerPimpl::uninitialize_once(), foedus::soc::SocManagerPimpl::wait_for_child_attach(), and ~SharedMemoryRepo().
ChildEngineStatus::StatusCode foedus::soc::SharedMemoryRepo::get_child_status | ( | SocId | node | ) | const |
Definition at line 551 of file shared_memory_repo.cpp.
References foedus::soc::NodeMemoryAnchors::child_status_memory_, and foedus::soc::ChildEngineStatus::read_status_atomic().
Referenced by foedus::soc::SocManagerPimpl::wait_for_child_attach(), and foedus::soc::SocManagerPimpl::wait_for_child_terminate().
|
inline |
Definition at line 513 of file shared_memory_repo.hpp.
References foedus::memory::SharedMemory::get_block().
Referenced by foedus::soc::SocManagerPimpl::uninitialize_once().
|
inline |
Definition at line 514 of file shared_memory_repo.hpp.
Referenced by foedus::snapshot::LogGleaner::execute(), foedus::snapshot::LogReducerRef::get_cur_snapshot(), foedus::storage::PartitionerMetadata::get_index0_metadata(), foedus::storage::PartitionerMetadata::get_metadata(), foedus::soc::SocManagerPimpl::initialize_master(), foedus::log::MetaLogger::initialize_once(), foedus::storage::StorageManagerPimpl::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::xct::XctManagerPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), foedus::storage::PartitionerMetadata::locate_data(), foedus::snapshot::LogGleanerRef::LogGleanerRef(), foedus::EnginePimpl::on_module_initialized(), foedus::EnginePimpl::on_module_uninitialized(), foedus::soc::SocManagerPimpl::report_engine_fatal_error(), foedus::savepoint::SavepointManagerPimpl::savepoint_main(), foedus::snapshot::SnapshotManagerPimpl::uninitialize_once(), and foedus::soc::SocManagerPimpl::wait_for_master_module().
|
inline |
Definition at line 515 of file shared_memory_repo.hpp.
References foedus::soc::GlobalMemoryAnchors::user_memory_.
Referenced by foedus::soc::SocManager::get_shared_user_memory().
MasterEngineStatus::StatusCode foedus::soc::SharedMemoryRepo::get_master_status | ( | ) | const |
Definition at line 543 of file shared_memory_repo.cpp.
References foedus::soc::GlobalMemoryAnchors::master_status_memory_, and foedus::soc::MasterEngineStatus::read_status_atomic().
Referenced by foedus::soc::SocManagerPimpl::wait_for_master_status().
|
inline |
Definition at line 520 of file shared_memory_repo.hpp.
References foedus::memory::SharedMemory::get_block().
|
inline |
Definition at line 521 of file shared_memory_repo.hpp.
Referenced by foedus::snapshot::LogReducerRef::get_buffer(), foedus::soc::SocManagerPimpl::initialize_master(), foedus::memory::NumaNodeMemory::initialize_once(), foedus::EnginePimpl::initialize_once(), foedus::proc::ProcManagerPimpl::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::snapshot::LogReducerRef::LogReducerRef(), foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef(), foedus::EnginePimpl::on_module_initialized(), foedus::EnginePimpl::on_module_uninitialized(), foedus::soc::SocManagerPimpl::report_engine_fatal_error(), and foedus::soc::SocManagerPimpl::wait_for_children_module().
|
inline |
Definition at line 526 of file shared_memory_repo.hpp.
References foedus::thread::decompose_numa_local_ordinal(), foedus::thread::decompose_numa_node(), and foedus::soc::NodeMemoryAnchors::thread_anchors_.
Referenced by foedus::thread::ThreadPimpl::initialize_once(), and foedus::thread::ThreadRef::ThreadRef().
|
inline |
Definition at line 532 of file shared_memory_repo.hpp.
References foedus::soc::NodeMemoryAnchors::volatile_page_pool_.
Referenced by foedus::memory::NumaNodeMemory::initialize_once(), and foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef().
void foedus::soc::SharedMemoryRepo::mark_for_release | ( | ) |
Marks shared memories as being removed so that it will be reclaimed when all processes detach it.
This is part of deallocation of shared memory in master process. After calling this method, no process can attach this shared memory. So, do not call this too early. However, on the other hand, do not call this too late. If the master process dies for an unexpected reason, the shared memory remains until next reboot. Call it as soon as child processes ack-ed that they have attached the memory or that there are some issues the master process should exit. This method is idempotent, meaning you can safely call this many times.
Definition at line 214 of file shared_memory_repo.cpp.
References foedus::memory::SharedMemory::mark_for_release().
Referenced by deallocate_shared_memories(), and foedus::soc::SocManagerPimpl::wait_for_child_attach().
|
delete |