libfoedus-core
FOEDUS Core Library
|
Lock-free list of records stored in the volatile part of sequential storage. More...
Lock-free list of records stored in the volatile part of sequential storage.
Volatile parts of sequential storages are completely separated from stable snapshot pages and maintained as a lock-free list of SequentialPage.
The append of record in page involves one atomic CAS, and append of a new page involves one atomic CAS too. Because this list is an append/scan only list, this is way simpler than typical lock-free lists.
In this volatile list, we assume the following things to simplify concurrency control:
With these assumptions, sequential storages don't require any locking for serializability. Thus, we separate write-sets of sequential storages from other write-sets in transaction objects.
Definition at line 139 of file sequential_storage_pimpl.hpp.
#include <sequential_storage_pimpl.hpp>
Classes | |
struct | PointerPage |
Public Member Functions | |
SequentialStoragePimpl ()=delete | |
SequentialStoragePimpl (SequentialStorage *storage) | |
SequentialStoragePimpl (Engine *engine, SequentialStorageControlBlock *control_block) | |
bool | exists () const |
StorageId | get_id () const |
const StorageName & | get_name () const |
ErrorStack | create (const SequentialMetadata &metadata) |
ErrorStack | load (const StorageControlBlock &snapshot_block) |
ErrorStack | initialize_head_tail_pages () |
ErrorStack | drop () |
ErrorStack | truncate (Epoch new_truncate_epoch, Epoch *commit_epoch) |
void | apply_truncate (const SequentialTruncateLogType &the_log) |
SequentialPage * | get_head (const memory::LocalPageResolver &resolver, thread::ThreadId thread_id) const |
SequentialPage * | get_tail (const memory::LocalPageResolver &resolver, thread::ThreadId thread_id) const |
memory::PagePoolOffset * | get_head_pointer (thread::ThreadId thread_id) const |
memory::PagePoolOffset * | get_tail_pointer (thread::ThreadId thread_id) const |
void | append_record (thread::Thread *context, xct::XctId owner_id, const void *payload, uint16_t payload_count) |
Appends an already-commited record to this volatile list. More... | |
template<typename HANDLER > | |
ErrorCode | for_every_page (HANDLER handler) const |
Traverse all pages and call back the handler for every page. More... | |
![]() | |
Attachable () | |
Attachable (Engine *engine) | |
Attachable (Engine *engine, SequentialStorageControlBlock *control_block) | |
Attachable (SequentialStorageControlBlock *control_block) | |
Attachable (const Attachable &other) | |
virtual | ~Attachable () |
Attachable & | operator= (const Attachable &other) |
virtual void | attach (SequentialStorageControlBlock *control_block) |
Attaches to the given shared memory. More... | |
bool | is_attached () const |
Returns whether the object has been already attached to some shared memory. More... | |
SequentialStorageControlBlock * | get_control_block () const |
Engine * | get_engine () const |
void | set_engine (Engine *engine) |
Additional Inherited Members | |
![]() | |
Engine * | engine_ |
Most attachable object stores an engine pointer (local engine), so we define it here. More... | |
SequentialStorageControlBlock * | control_block_ |
The shared data on shared memory that has been initialized in some SOC or master engine. More... | |
|
delete |
|
inlineexplicit |
Definition at line 145 of file sequential_storage_pimpl.hpp.
|
inline |
Definition at line 150 of file sequential_storage_pimpl.hpp.
void foedus::storage::sequential::SequentialStoragePimpl::append_record | ( | thread::Thread * | context, |
xct::XctId | owner_id, | ||
const void * | payload, | ||
uint16_t | payload_count | ||
) |
Appends an already-commited record to this volatile list.
This method is guaranteed to succeed, so it does not return error code, which is essential to be used after commit. Actually, there is one very rare case this method might fail: we need a new page and the page pool has zero free page. However, we can trivially avoid this case by checking if we have at least one free page in thread-local cache during pre-commit.
Definition at line 323 of file sequential_storage_pimpl.cpp.
References foedus::storage::sequential::SequentialPage::append_record_nosync(), ASSERT_ND, foedus::storage::sequential::SequentialPage::can_insert_record(), foedus::xct::XctId::get_epoch(), foedus::storage::sequential::SequentialPage::get_first_record_epoch(), get_head_pointer(), get_id(), foedus::thread::Thread::get_local_volatile_page_resolver(), foedus::thread::Thread::get_numa_node(), foedus::storage::sequential::SequentialPage::get_record_count(), get_tail_pointer(), foedus::thread::Thread::get_thread_id(), foedus::thread::Thread::get_thread_memory(), foedus::memory::NumaCoreMemory::grab_free_volatile_page(), foedus::storage::sequential::SequentialPage::initialize_volatile_page(), foedus::storage::sequential::SequentialPage::next_page(), foedus::memory::LocalPageResolver::resolve_offset(), foedus::memory::LocalPageResolver::resolve_offset_newpage(), foedus::storage::VolatilePagePointer::set(), UNLIKELY, and foedus::storage::DualPagePointer::volatile_pointer_.
Referenced by foedus::storage::sequential::SequentialStorage::apply_append_record().
void foedus::storage::sequential::SequentialStoragePimpl::apply_truncate | ( | const SequentialTruncateLogType & | the_log | ) |
Definition at line 313 of file sequential_storage_pimpl.cpp.
References ASSERT_ND, foedus::Attachable< SequentialStorageControlBlock >::control_block_, get_name(), foedus::log::BaseLogType::header_, foedus::storage::sequential::SequentialTruncateLogType::new_truncate_epoch_, foedus::Epoch::value(), and foedus::log::LogHeader::xct_id_.
Referenced by foedus::storage::sequential::SequentialStorage::apply_truncate().
ErrorStack foedus::storage::sequential::SequentialStoragePimpl::create | ( | const SequentialMetadata & | metadata | ) |
Definition at line 147 of file sequential_storage_pimpl.cpp.
References CHECK_ERROR, foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::Attachable< SequentialStorageControlBlock >::engine_, ERROR_STACK, exists(), foedus::Engine::get_earliest_epoch(), get_name(), initialize_head_tail_pages(), foedus::kErrorCodeStrAlreadyExists, foedus::storage::kExists, foedus::kRetOk, and foedus::Epoch::value().
Referenced by foedus::storage::sequential::SequentialStorage::create().
ErrorStack foedus::storage::sequential::SequentialStoragePimpl::drop | ( | ) |
Definition at line 86 of file sequential_storage_pimpl.cpp.
References ASSERT_ND, foedus::thread::compose_thread_id(), foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::Attachable< SequentialStorageControlBlock >::engine_, foedus::memory::PagePoolOffsetChunk::full(), get_head(), foedus::Engine::get_memory_manager(), get_name(), foedus::memory::EngineMemory::get_node_memory(), foedus::Engine::get_options(), foedus::memory::PagePool::get_resolver(), foedus::memory::NumaNodeMemoryRef::get_volatile_pool(), foedus::thread::ThreadOptions::group_count_, foedus::kRetOk, foedus::memory::PagePoolOffsetChunk::push_back(), foedus::memory::PagePool::release(), foedus::memory::PagePool::release_one(), foedus::memory::LocalPageResolver::resolve_offset(), foedus::memory::PagePoolOffsetChunk::size(), foedus::EngineOptions::thread_, foedus::thread::ThreadOptions::thread_count_per_group_, and foedus::storage::VolatilePagePointer::word.
Referenced by foedus::storage::sequential::SequentialStorage::drop().
|
inline |
Definition at line 154 of file sequential_storage_pimpl.hpp.
References foedus::Attachable< SequentialStorageControlBlock >::control_block_.
Referenced by create().
|
inline |
Traverse all pages and call back the handler for every page.
Handler must look like "ErrorCode func(SequentialPage* page) { ... } ".
Definition at line 196 of file sequential_storage_pimpl.hpp.
References ASSERT_ND, CHECK_ERROR_CODE, foedus::thread::compose_thread_id(), foedus::Attachable< SequentialStorageControlBlock >::engine_, get_head(), foedus::Engine::get_memory_manager(), foedus::memory::EngineMemory::get_node_memory(), foedus::storage::VolatilePagePointer::get_offset(), foedus::Engine::get_options(), foedus::memory::PagePool::get_resolver(), foedus::memory::NumaNodeMemoryRef::get_volatile_pool(), foedus::thread::ThreadOptions::group_count_, foedus::kErrorCodeOk, foedus::memory::LocalPageResolver::resolve_offset(), foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.
Referenced by foedus::storage::sequential::operator<<().
SequentialPage * foedus::storage::sequential::SequentialStoragePimpl::get_head | ( | const memory::LocalPageResolver & | resolver, |
thread::ThreadId | thread_id | ||
) | const |
Definition at line 407 of file sequential_storage_pimpl.cpp.
References get_head_pointer(), and foedus::memory::LocalPageResolver::resolve_offset().
Referenced by drop(), and for_every_page().
memory::PagePoolOffset * foedus::storage::sequential::SequentialStoragePimpl::get_head_pointer | ( | thread::ThreadId | thread_id | ) | const |
Definition at line 378 of file sequential_storage_pimpl.cpp.
References ASSERT_ND, foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::thread::decompose_numa_local_ordinal(), foedus::thread::decompose_numa_node(), foedus::Attachable< SequentialStorageControlBlock >::engine_, foedus::memory::EngineMemory::get_global_volatile_page_resolver(), foedus::Engine::get_memory_manager(), foedus::Engine::get_options(), foedus::storage::sequential::get_pointer_page_and_index(), foedus::thread::ThreadOptions::group_count_, foedus::storage::sequential::SequentialStoragePimpl::PointerPage::pointers_, foedus::memory::GlobalVolatilePageResolver::resolve_offset_newpage(), foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.
Referenced by append_record(), and get_head().
|
inline |
Definition at line 155 of file sequential_storage_pimpl.hpp.
References foedus::Attachable< SequentialStorageControlBlock >::control_block_.
Referenced by append_record(), and truncate().
|
inline |
Definition at line 156 of file sequential_storage_pimpl.hpp.
References foedus::Attachable< SequentialStorageControlBlock >::control_block_.
Referenced by apply_truncate(), create(), drop(), load(), and truncate().
SequentialPage * foedus::storage::sequential::SequentialStoragePimpl::get_tail | ( | const memory::LocalPageResolver & | resolver, |
thread::ThreadId | thread_id | ||
) | const |
Definition at line 417 of file sequential_storage_pimpl.cpp.
References get_tail_pointer(), and foedus::memory::LocalPageResolver::resolve_offset().
memory::PagePoolOffset * foedus::storage::sequential::SequentialStoragePimpl::get_tail_pointer | ( | thread::ThreadId | thread_id | ) | const |
Definition at line 392 of file sequential_storage_pimpl.cpp.
References ASSERT_ND, foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::thread::decompose_numa_local_ordinal(), foedus::thread::decompose_numa_node(), foedus::Attachable< SequentialStorageControlBlock >::engine_, foedus::memory::EngineMemory::get_global_volatile_page_resolver(), foedus::Engine::get_memory_manager(), foedus::Engine::get_options(), foedus::storage::sequential::get_pointer_page_and_index(), foedus::thread::ThreadOptions::group_count_, foedus::storage::sequential::SequentialStoragePimpl::PointerPage::pointers_, foedus::memory::GlobalVolatilePageResolver::resolve_offset_newpage(), foedus::EngineOptions::thread_, and foedus::thread::ThreadOptions::thread_count_per_group_.
Referenced by append_record(), and get_tail().
ErrorStack foedus::storage::sequential::SequentialStoragePimpl::initialize_head_tail_pages | ( | ) |
Definition at line 188 of file sequential_storage_pimpl.cpp.
References foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::Attachable< SequentialStorageControlBlock >::engine_, foedus::Engine::get_memory_manager(), foedus::memory::EngineMemory::get_node_memory(), foedus::Engine::get_options(), foedus::memory::PagePool::get_resolver(), foedus::memory::NumaNodeMemoryRef::get_volatile_pool(), foedus::memory::PagePool::grab_one(), foedus::thread::ThreadOptions::group_count_, foedus::storage::kPageSize, foedus::kRetOk, foedus::memory::LocalPageResolver::resolve_offset_newpage(), foedus::EngineOptions::thread_, and WRAP_ERROR_CODE.
Referenced by create(), and load().
ErrorStack foedus::storage::sequential::SequentialStoragePimpl::load | ( | const StorageControlBlock & | snapshot_block | ) |
Definition at line 166 of file sequential_storage_pimpl.cpp.
References ASSERT_ND, CHECK_ERROR, foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::Attachable< SequentialStorageControlBlock >::engine_, foedus::Engine::get_earliest_epoch(), get_name(), initialize_head_tail_pages(), foedus::Epoch::is_valid(), foedus::storage::kExists, foedus::kRetOk, foedus::storage::StorageControlBlock::meta_, and foedus::Epoch::value().
Referenced by foedus::storage::sequential::SequentialStorage::load().
ErrorStack foedus::storage::sequential::SequentialStoragePimpl::truncate | ( | Epoch | new_truncate_epoch, |
Epoch * | commit_epoch | ||
) |
Definition at line 236 of file sequential_storage_pimpl.cpp.
References foedus::log::MetaLogBuffer::commit(), foedus::Attachable< SequentialStorageControlBlock >::control_block_, foedus::Attachable< SequentialStorageControlBlock >::engine_, ERROR_STACK, foedus::Engine::get_current_global_epoch(), get_id(), foedus::Engine::get_log_manager(), foedus::log::LogManager::get_meta_buffer(), get_name(), foedus::log::BaseLogType::header_, foedus::Epoch::is_valid(), foedus::kErrorCodeInvalidParameter, foedus::kRetOk, foedus::log::LogHeader::log_length_, foedus::log::LogHeader::log_type_code_, foedus::assorted::memory_fence_acq_rel(), foedus::assorted::memory_fence_release(), foedus::storage::sequential::SequentialTruncateLogType::new_truncate_epoch_, foedus::xct::XctId::set(), foedus::log::LogHeader::storage_id_, and foedus::Epoch::value().
Referenced by foedus::storage::sequential::SequentialStorage::truncate().