libfoedus-core
FOEDUS Core Library
|
Thread and Thread-Group, which abstracts NUMA-core/node and provides API to attach/detach tasks to pooled threads. More...
Thread and Thread-Group, which abstracts NUMA-core/node and provides API to attach/detach tasks to pooled threads.
This package is analogous to std::thread or boost::thread with a few additional features specific to our database engine. Among all, the main difference is that this package is fully aware of NUMA (Non Uniform Memory Access) architecture in hardware.
![]() |
Modules | |
Thread-Pool and Impersonation | |
APIs to pool and impersonate worker threads in libfoedus-core. | |
Files | |
file | fwd.hpp |
Forward declarations of classes in thread package. | |
file | thread_id.hpp |
Typedefs of ID types used in thread package. | |
Classes | |
struct | foedus::memory::NumaCoreMemory::SmallThreadLocalMemoryPieces |
Packs pointers to pieces of small_thread_local_memory_. More... | |
class | foedus::memory::NumaCoreMemory |
Repository of memories dynamically acquired within one CPU core (thread). More... | |
class | foedus::memory::NumaNodeMemory |
Repository of memories dynamically acquired and shared within one NUMA node (socket). More... | |
class | foedus::thread::ConditionVariable |
An analogue of pthread's condition variable and std::condition_variable to avoid glibc's bug in pthread_cond_broadcast/signal (thus in notify_all/one in turn). More... | |
struct | foedus::thread::NumaThreadScope |
Pin the current thread to the given NUMA node in this object's scope. More... | |
class | foedus::thread::Rendezvous |
The frequently appearing triplet of condition_varible, "signal" flag for spurious wakeup, and mutex for a one-time single-producer multiple-consumer event synchronization. More... | |
class | foedus::thread::StoppableThread |
The frequently appearing quartet of std::thread, condition_varible, stop-request flag, and mutex. More... | |
class | foedus::thread::Thread |
Represents one thread running on one NUMA core. More... | |
class | foedus::thread::ThreadGroup |
Represents a group of pre-allocated threads running in one NUMA node. More... | |
struct | foedus::thread::ThreadOptions |
Set of options about threads and thread-groups. More... | |
class | foedus::thread::ThreadPimpl |
Pimpl object of Thread. More... | |
class | foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK > |
Implements McsAdaptorConcept over ThreadPimpl. More... | |
class | foedus::thread::ThreadRef |
A view of Thread object for other SOCs and master engine. More... | |
class | foedus::thread::ThreadGroupRef |
A view of Thread group object for other SOCs and master engine. More... | |
Typedefs | |
typedef uint8_t | foedus::thread::ThreadGroupId |
Typedef for an ID of ThreadGroup (NUMA node). More... | |
typedef uint8_t | foedus::thread::ThreadLocalOrdinal |
Typedef for a local ID of Thread (core), which is NOT unique across NUMA nodes. More... | |
typedef uint16_t | foedus::thread::ThreadId |
Typedef for a global ID of Thread (core), which is unique across NUMA nodes. More... | |
typedef uint16_t | foedus::thread::ThreadGlobalOrdinal |
Typedef for a globally and contiguously numbered ID of thread. More... | |
typedef uint64_t | foedus::thread::ThreadTicket |
Typedef for a monotonically increasing ticket for thread impersonation. More... | |
Enumerations | |
enum | foedus::thread::ThreadPolicy { foedus::thread::kScheduleOther = 0, foedus::thread::kScheduleFifo = 1, foedus::thread::kScheduleRr = 2, foedus::thread::kScheduleBatch = 3, foedus::thread::kScheduleIdle = 5 } |
Thread policy for worker threads. More... | |
enum | foedus::thread::ThreadPriority { foedus::thread::kPriorityIdle = 0, foedus::thread::kPriorityLowest = 1, foedus::thread::kPriorityDefault = 50, foedus::thread::kPriorityHighest = 99 } |
Thread priority for worker threads. More... | |
enum | foedus::thread::ThreadStatus { foedus::thread::kNotInitialized = 0, foedus::thread::kWaitingForTask, foedus::thread::kWaitingForExecution, foedus::thread::kRunningTask, foedus::thread::kWaitingForClientRelease, foedus::thread::kWaitingForTerminate, foedus::thread::kTerminated } |
Impersonation status of each worker thread. More... | |
Functions | |
ThreadId | foedus::thread::compose_thread_id (ThreadGroupId node, ThreadLocalOrdinal local_core) |
Returns a globally unique ID of Thread (core) for the given node and ordinal in the node. More... | |
ThreadGroupId | foedus::thread::decompose_numa_node (ThreadId global_id) |
Extracts NUMA node ID from the given globally unique ID of Thread (core). More... | |
ThreadLocalOrdinal | foedus::thread::decompose_numa_local_ordinal (ThreadId global_id) |
Extracts local ordinal from the given globally unique ID of Thread (core). More... | |
ThreadGlobalOrdinal | foedus::thread::to_global_ordinal (ThreadId thread_id, uint8_t threads_per_nodes) |
Calculate ThreadGlobalOrdinal from ThreadId. More... | |
Variables | |
const ThreadGroupId | foedus::thread::kMaxThreadGroupId = 0xFF |
Maximum possible value of ThreadGroupId. More... | |
const ThreadLocalOrdinal | foedus::thread::kMaxThreadLocalOrdinal = 0xFF |
Maximum possible value of ThreadLocalOrdinal. More... | |
const ThreadId | foedus::thread::kMaxThreadId = 0xFFFF |
Maximum possible value of ThreadId. More... | |
struct foedus::memory::NumaCoreMemory::SmallThreadLocalMemoryPieces |
Packs pointers to pieces of small_thread_local_memory_.
Definition at line 49 of file numa_core_memory.hpp.
Typedef for a globally and contiguously numbered ID of thread.
ThreadId is not contiguous because its high byte is NUMA node, and that is what we use in most places. However, sometimes we need a contiguously numberd ID of thread, such as when we allocate an array of objects, one for each thread. This number is used in such cases. Be extra careful, both ThreadId and this are uint16_t, so compiler won't warn anything if we use them incorrectly.
Definition at line 98 of file thread_id.hpp.
Typedef for an ID of ThreadGroup (NUMA node).
Currently, we assume there are at most 256 NUMA nodes.
Definition at line 38 of file thread_id.hpp.
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
This is a composite of ThreadGroupId (high 1 byte) and ThreadLocalOrdinal (low 1 byte). For example, if there are 2 NUMA nodes and 8 cores each: thread-0=node-0 core-0, thread-1=node-0 core-1, ..., thread-256=node-1 core-0,...
Definition at line 80 of file thread_id.hpp.
Typedef for a local ID of Thread (core), which is NOT unique across NUMA nodes.
Currently, we assume there are at most 256 cores per NUMA node.
Definition at line 58 of file thread_id.hpp.
Typedef for a monotonically increasing ticket for thread impersonation.
For every impersonation, the thread increments this value in its control block. Each session receives the ticket and checks the ticket whenever it checks the status of the thread. This is required to avoid double-free and modifying input/output data of other sessions.
Definition at line 117 of file thread_id.hpp.
Thread policy for worker threads.
The values are compatible with pthread's values.
Enumerator | |
---|---|
kScheduleOther |
SCHED_OTHER. |
kScheduleFifo |
SCHED_FIFO. |
kScheduleRr |
SCHED_RR. |
kScheduleBatch |
SCHED_BATCH. |
kScheduleIdle |
SCHED_IDLE. |
Definition at line 166 of file thread_id.hpp.
Thread priority for worker threads.
The values are compatible with pthread's values. Depending on policy, the lowest-highest might be overwritten by what sched_get_priority_max()/min returns.
Enumerator | |
---|---|
kPriorityIdle | |
kPriorityLowest | |
kPriorityDefault | |
kPriorityHighest |
Definition at line 186 of file thread_id.hpp.
Impersonation status of each worker thread.
The transition is basically only to next one. Exceptions are:
Definition at line 203 of file thread_id.hpp.
|
inline |
Returns a globally unique ID of Thread (core) for the given node and ordinal in the node.
Definition at line 123 of file thread_id.hpp.
Referenced by foedus::storage::sequential::SequentialStoragePimpl::drop(), foedus::storage::sequential::SequentialComposer::drop_volatiles(), foedus::storage::sequential::SequentialStoragePimpl::for_every_page(), foedus::thread::ThreadGroup::initialize_once(), foedus::log::LogManagerPimpl::initialize_once(), foedus::memory::NumaCoreMemory::NumaCoreMemory(), and foedus::thread::ThreadGroupRef::ThreadGroupRef().
|
inline |
Extracts local ordinal from the given globally unique ID of Thread (core).
Definition at line 139 of file thread_id.hpp.
Referenced by foedus::memory::NumaNodeMemory::get_core_memory(), foedus::storage::sequential::SequentialStoragePimpl::get_head_pointer(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), foedus::storage::sequential::SequentialStoragePimpl::get_tail_pointer(), foedus::thread::ThreadPoolPimpl::get_thread(), foedus::soc::SharedMemoryRepo::get_thread_memory_anchors(), foedus::thread::ThreadPoolPimpl::get_thread_ref(), foedus::log::Logger::initialize_once(), and foedus::thread::to_global_ordinal().
|
inline |
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Definition at line 131 of file thread_id.hpp.
Referenced by foedus::storage::sequential::SequentialStoragePimpl::get_head_pointer(), foedus::thread::ThreadRef::get_numa_node(), foedus::thread::Thread::get_numa_node(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), foedus::storage::sequential::SequentialStoragePimpl::get_tail_pointer(), foedus::thread::ThreadPoolPimpl::get_thread(), foedus::soc::SharedMemoryRepo::get_thread_memory_anchors(), foedus::thread::ThreadPoolPimpl::get_thread_ref(), foedus::thread::ThreadPimpl::handle_tasks(), and foedus::thread::to_global_ordinal().
|
inline |
Calculate ThreadGlobalOrdinal from ThreadId.
Definition at line 147 of file thread_id.hpp.
References foedus::thread::decompose_numa_local_ordinal(), and foedus::thread::decompose_numa_node().
Referenced by foedus::thread::ThreadGroup::initialize_once().
foedus::thread::kMaxThreadGroupId = 0xFF |
Maximum possible value of ThreadGroupId.
Definition at line 49 of file thread_id.hpp.
foedus::thread::kMaxThreadId = 0xFFFF |
Maximum possible value of ThreadId.
Definition at line 105 of file thread_id.hpp.
foedus::thread::kMaxThreadLocalOrdinal = 0xFF |
Maximum possible value of ThreadLocalOrdinal.
Definition at line 69 of file thread_id.hpp.
Referenced by foedus::memory::NumaNodeMemory::get_core_memory_count().