18 #ifndef FOEDUS_THREAD_THREAD_PIMPL_HPP_
19 #define FOEDUS_THREAD_THREAD_PIMPL_HPP_
186 storage::Page** out);
191 storage::Page** out);
201 storage::Page* buffer) ALWAYS_INLINE;
205 storage::DualPagePointer* pointer,
206 storage::Page** installed_page);
211 bool tolerate_null_pointer,
213 bool take_ptr_set_snapshot,
214 storage::DualPagePointer* pointer,
215 storage::Page** page,
216 const storage::Page* parent,
217 uint16_t index_in_parent);
222 bool tolerate_null_pointer,
223 bool take_ptr_set_snapshot,
224 storage::DualPagePointer** pointers,
225 storage::Page** parents,
226 const uint16_t* index_in_parents,
227 bool* followed_snapshots,
228 storage::Page** out);
233 storage::DualPagePointer** pointers,
234 storage::Page** parents,
235 const uint16_t* index_in_parents,
236 storage::Page** out);
253 storage::DualPagePointer* pointer);
267 memory::PagePoolOffsetAndEpochChunk* chunk);
280 template<typename FUNC>
403 template<
typename RW_BLOCK>
428 ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
434 ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
466 tail_tmp.
tail_ = tail_int;
484 ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
526 #endif // FOEDUS_THREAD_THREAD_PIMPL_HPP_
void initialize(ThreadId my_thread_id)
void collect_retired_volatile_page(storage::VolatilePagePointer ptr)
Keeps the specified volatile page as retired as of the current epoch.
ErrorCode sysxct_page_lock(xct::SysxctWorkspace *sysxct_workspace, storage::Page *page)
void * task_input_memory_
ErrorCode install_a_volatile_page(storage::DualPagePointer *pointer, storage::Page **installed_page)
Installs a volatile page to the given dual pointer as a copy of the snapshot page.
ThreadId my_thread_id_
Used only for sanity check.
Implements McsAdaptorConcept over ThreadPimpl.
cache::SnapshotFileSet snapshot_file_set_
Each threads maintains a private set of snapshot file descriptors.
void cll_release_all_locks()
ErrorStack uninitialize_once() override final
ThreadTicket current_ticket_
The most recently issued impersonation ticket.
Definitions of IDs in this package and a few related constant values.
ErrorCode read_page(storage::SnapshotPagePointer page_id, void *out)
A thread-local log buffer.
ThreadGroupId get_my_numa_node() const
ThreadStatus
Impersonation status of each worker thread.
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
void set_thread_schedule()
initializes the thread's policy/priority
ErrorCode cll_try_or_acquire_multiple_locks(xct::LockListPosition upto_pos)
uint64_t stat_snapshot_cache_hits_
uint32_t input_len_
Byte size of input given to the procedure.
bool is_simple_mcs_rw() const
Page pool for volatile read/write store (VolatilePage) and the read-only bufferpool (SnapshotPage)...
void initialize(bool recursive=false)
std::atomic< bool > mcs_waiting_
Whether this thread is waiting for some MCS lock.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
memory::NumaNodeMemory * node_memory_
same above
Represents one thread running on one NUMA core.
uint32_t PagePoolOffset
Offset in PagePool that compactly represents the page address (unlike 8 bytes pointer).
memory::GlobalVolatilePageResolver global_volatile_page_resolver_
Page resolver to convert all page ID to page pointer.
Typedefs of ID types used in thread package.
std::thread raw_thread_
Encapsulates raw thread object.
xct::McsRwAsyncMapping * get_mcs_rw_async_mapping(xct::UniversalLockId lock_id)
Shared data of ThreadPimpl.
soc::SharedPolling task_complete_cond_
When the current task has been completed, the thread signals this.
Forward declarations of classes in transaction package.
ThreadId get_my_id() const
Represents a pointer to a volatile page with modification count for preventing ABA.
Represents a user transaction.
ErrorCode read_a_snapshot_page(storage::SnapshotPagePointer page_id, storage::Page *buffer) __attribute__((always_inline))
Read a snapshot page using the thread-local file descriptor set.
const ThreadGlobalOrdinal global_ordinal_
globally and contiguously numbered ID of thread
memory::PagePool * snapshot_page_pool_
shorthand for node_memory_->get_snapshot_pool()
void cll_giveup_all_locks_after(xct::UniversalLockId address)
Brings error stacktrace information as return value of functions.
soc::SharedMutex task_mutex_
The following variables are protected by this mutex.
Reader-writer (RW) MCS lock classes.
void switch_mcs_impl(FUNC func)
MCS locks methods.
A polling-wait mechanism that can be placed in shared memory and used from multiple processes...
Typical implementation of Initializable as a skeleton base class.
Holds a set of read-only file objects for snapshot files.
xct::McsBlockIndex get_other_cur_block(ThreadId id)
Forward declarations of classes in cache package.
ErrorCode sysxct_batch_page_locks(xct::SysxctWorkspace *sysxct_workspace, uint32_t lock_count, storage::Page **pages)
McsBlockIndex get_tail_waiter_block() const
std::atomic< bool > raw_thread_set_
Just to make sure raw_thread_ is set.
RW_BLOCK * get_rw_other_block(ThreadId id, xct::McsBlockIndex index)
xct::McsBlockIndex issue_new_block()
Repository of memories dynamically acquired within one CPU core (thread).
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
xct::McsWwBlock * mcs_ww_blocks_
Pre-allocated MCS blocks.
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
A mutex that can be placed in shared memory and used from multiple processes.
void get_mcs_rw_blocks(xct::McsRwSimpleBlock **out) const
soc::SharedPolling wakeup_cond_
The thread sleeps on this conditional when it has no task.
std::atomic< bool > * other_waiting(ThreadId id)
The MCS reader-writer lock variant of LockableXctId.
xct::McsWwBlock * get_ww_my_block(xct::McsBlockIndex index)
bool is_volatile_page_retired(storage::VolatilePagePointer ptr)
Subroutine of collect_retired_volatile_page() just for assertion.
A functor representing the logic in a system transaction via virtual-function.
Forward declarations of classes in storage package.
ErrorCode find_or_read_snapshot_pages_batch(uint16_t batch_size, const storage::SnapshotPagePointer *page_ids, storage::Page **out)
Batched version of find_or_read_a_snapshot_page().
Pre-allocated MCS block for WW-locks.
Definitions of IDs in this package and a few related constant values.
const ThreadGroupId numa_node_
Node this thread belongs to.
void remove_rw_async_mapping(xct::McsRwLock *lock)
ErrorCode cll_try_or_acquire_single_lock(xct::LockListPosition pos)
void flush_retired_volatile_page(uint16_t node, Epoch current_epoch, memory::PagePoolOffsetAndEpochChunk *chunk)
Subroutine of collect_retired_volatile_page() in case the chunk becomes full.
Engine *const engine_
MCS locks methods.
ErrorCode sysxct_record_lock(xct::SysxctWorkspace *sysxct_workspace, storage::VolatilePagePointer page_id, xct::RwLockableXctId *lock)
uint32_t LockListPosition
Index in a lock-list, either RLL or CLL.
void cll_release_all_locks_after(xct::UniversalLockId address)
RW-locks.
uint64_t SnapshotPagePointer
Page ID of a snapshot page.
Pre-allocated MCS block for extended version of RW-locks.
Thread *const holder_
The public object that holds this pimpl object.
RW_BLOCK * get_rw_my_block(xct::McsBlockIndex index)
ThreadPimplMcsAdaptor(ThreadPimpl *pimpl)
ThreadControlBlock()=delete
Database engine object that holds all resources and provides APIs.
uint32_t mcs_rw_async_mapping_current_
How many async mappings for extended RW lock we have so far.
Repository of memories dynamically acquired and shared within one NUMA node (socket).
ErrorCode sysxct_batch_record_locks(xct::SysxctWorkspace *sysxct_workspace, storage::VolatilePagePointer page_id, uint32_t lock_count, xct::RwLockableXctId **locks)
Typedefs of ID types used in procedure package.
A view of Thread object for other SOCs and master engine.
ThreadControlBlock * get_control_block() const
log::ThreadLogBuffer log_buffer_
Thread-private log buffer.
Just a marker to denote that the memory region represents a data page.
A NUMA-local hashtable of cached snapshot pages.
Representation of ErrorStack that can be copied to other processes and even serialized to files...
xct::McsWwBlock * get_ww_other_block(ThreadId id, xct::McsBlockIndex index)
ErrorCode read_pages(storage::SnapshotPagePointer page_id_begin, uint32_t page_count, void *out)
Read contiguous pages in one shot.
ErrorCode follow_page_pointer(storage::VolatilePageInit page_initializer, bool tolerate_null_pointer, bool will_modify, bool take_ptr_set_snapshot, storage::DualPagePointer *pointer, storage::Page **page, const storage::Page *parent, uint16_t index_in_parent)
A general method to follow (read) a page pointer.
ErrorCode run_nested_sysxct(xct::SysxctFunctor *functor, uint32_t max_retries)
Sysxct-related.
memory::LocalPageResolver local_volatile_page_resolver_
Page resolver to convert only local page ID to page pointer.
void handle_tasks()
Main routine of the worker thread.
void add_rw_async_mapping(xct::McsRwLock *lock, xct::McsBlockIndex block_index)
proc::ProcName proc_name_
Name of the procedure to execute next.
xct::RwLockableXctId * canonical_address_
Forward declarations of classes in memory package.
xct::McsRwSimpleBlock * mcs_rw_simple_blocks_
ErrorStack initialize_once() override final
const ThreadId id_
Unique ID of this thread.
xct::Xct current_xct_
Current transaction this thread is conveying.
uint16_t ThreadGlobalOrdinal
Typedef for a globally and contiguously numbered ID of thread.
ErrorCode find_or_read_a_snapshot_page(storage::SnapshotPagePointer page_id, storage::Page **out)
Find the given page in snapshot cache, reading it if not found.
uint32_t McsBlockIndex
Index in thread-local MCS block.
const Epoch INVALID_EPOCH
A constant epoch object that represents an invalid epoch.
void get_mcs_rw_my_blocks(xct::McsRwExtendedBlock **out)
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
uint64_t stat_snapshot_cache_misses_
void get_mcs_rw_my_blocks(xct::McsRwSimpleBlock **out)
McsBlockIndex block_index_
ThreadStatus status_
Impersonation status of this thread.
xct::McsRwExtendedBlock * mcs_rw_extended_blocks_
storage::Page * place_a_new_volatile_page(memory::PagePoolOffset new_offset, storage::DualPagePointer *pointer)
Subroutine of install_a_volatile_page() and follow_page_pointer() to atomically place the given new v...
void(* VolatilePageInit)(const VolatilePageInitArguments &args)
A function pointer to initialize a volatile page.
ErrorCode follow_page_pointers_for_read_batch(uint16_t batch_size, storage::VolatilePageInit page_initializer, bool tolerate_null_pointer, bool take_ptr_set_snapshot, storage::DualPagePointer **pointers, storage::Page **parents, const uint16_t *index_in_parents, bool *followed_snapshots, storage::Page **out)
Batched version of follow_page_pointer with will_modify==false.
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
xct::McsRwAsyncMapping * mcs_rw_async_mappings_
void * task_output_memory_
void clear() noexcept
Clear string.
ThreadRef get_thread_ref(ThreadId id)
uint32_t output_len_
Byte size of output as the result of the procedure.
bool is_stop_requested() const
xct::UniversalLockId cll_get_max_locked_id() const
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
void cancel_new_block(xct::McsBlockIndex the_block)
FixedErrorStack proc_result_
Error code as the result of the procedure.
ErrorCode on_snapshot_cache_miss(storage::SnapshotPagePointer page_id, memory::PagePoolOffset *pool_offset)
Forward declarations of classes in thread package.
xct::McsRwExtendedBlock * get_rw_other_async_block(ThreadId id, xct::McsRwLock *lock)
memory::NumaCoreMemory * core_memory_
Private memory repository of this thread.
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
bool simple_mcs_rw_
shortcut for engine_->get_options().xct_.mcs_implementation_type_ == simple
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
xct::McsWwBlock * get_mcs_ww_blocks() const
std::atomic< bool > * me_waiting()
An MCS reader-writer lock data structure.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Per-thread reused work memory for system transactions.
ErrorCode read_snapshot_pages(storage::SnapshotPagePointer page_id_begin, uint32_t page_count, storage::Page *buffer) __attribute__((always_inline))
Read contiguous pages in one shot.
xct::McsBlockIndex get_cur_block() const
cache::CacheHashtable * snapshot_cache_hashtable_
same above
const UniversalLockId kNullUniversalLockId
This never points to a valid lock, and also evaluates less than any vaild alocks. ...
~ThreadControlBlock()=delete
RW_BLOCK * dereference_rw_tail_block(uint32_t tail_int)
ErrorCode follow_page_pointers_for_write_batch(uint16_t batch_size, storage::VolatilePageInit page_initializer, storage::DualPagePointer **pointers, storage::Page **parents, const uint16_t *index_in_parents, storage::Page **out)
Batched version of follow_page_pointer with will_modify==true and tolerate_null_pointer==true.
uint64_t ThreadTicket
Typedef for a monotonically increasing ticket for thread impersonation.
thread::ThreadId get_tail_waiter() const
ThreadControlBlock * control_block_