libfoedus-core
FOEDUS Core Library
foedus::storage::sequential::SequentialStorageControlBlock Struct Referencefinal

Shared data of this storage type. More...

Detailed Description

Shared data of this storage type.

Definition at line 49 of file sequential_storage_pimpl.hpp.

#include <sequential_storage_pimpl.hpp>

Collaboration diagram for foedus::storage::sequential::SequentialStorageControlBlock:

Public Member Functions

 SequentialStorageControlBlock ()=delete
 
 ~SequentialStorageControlBlock ()=delete
 
bool exists () const
 
ErrorCode optimistic_read_truncate_epoch (thread::Thread *context, Epoch *out) const
 

Public Attributes

soc::SharedMutex status_mutex_
 
StorageStatus status_
 Status of the storage. More...
 
DualPagePointer root_page_pointer_
 Points to the root page (or something equivalent). More...
 
SequentialMetadata meta_
 metadata of this storage. More...
 
xct::RwLockableXctId cur_truncate_epoch_tid_
 Protects accesses to cur_truncate_epoch_. More...
 
std::atomic< Epoch::EpochIntegercur_truncate_epoch_
 The min epoch value (truncate-epoch) for all valid records in this storage. More...
 
VolatilePagePointer head_pointer_pages_ [kPointerPageCount]
 Points to pages that store thread-private head pages to store thread-private volatile pages. More...
 
VolatilePagePointer tail_pointer_pages_ [kPointerPageCount]
 Same above, but for tail pointers. More...
 

Constructor & Destructor Documentation

foedus::storage::sequential::SequentialStorageControlBlock::SequentialStorageControlBlock ( )
delete
foedus::storage::sequential::SequentialStorageControlBlock::~SequentialStorageControlBlock ( )
delete

Member Function Documentation

bool foedus::storage::sequential::SequentialStorageControlBlock::exists ( ) const
inline

Definition at line 54 of file sequential_storage_pimpl.hpp.

References foedus::storage::kExists, foedus::storage::kMarkedForDeath, and status_.

54 { return status_ == kExists || status_ == kMarkedForDeath; }
The storage has been marked for drop and can't be used.
Definition: storage_id.hpp:164
The storage has been created and ready for use.
Definition: storage_id.hpp:158
ErrorCode foedus::storage::sequential::SequentialStorageControlBlock::optimistic_read_truncate_epoch ( thread::Thread context,
Epoch out 
) const

Definition at line 213 of file sequential_storage_pimpl.cpp.

References foedus::xct::Xct::add_to_lock_free_read_set(), CHECK_ERROR_CODE, cur_truncate_epoch_, cur_truncate_epoch_tid_, foedus::thread::Thread::get_current_xct(), foedus::storage::Metadata::id_, foedus::xct::Xct::is_active(), foedus::xct::XctId::is_being_written(), foedus::kErrorCodeOk, foedus::kErrorCodeXctNoXct, foedus::assorted::memory_fence_acquire(), meta_, and UNLIKELY.

215  {
216  xct::Xct& cur_xct = context->get_current_xct();
217  if (!cur_xct.is_active()) {
218  return kErrorCodeXctNoXct;
219  }
220 
221  auto* address = &cur_truncate_epoch_tid_;
222  xct::XctId observed = address->xct_id_;
223  while (UNLIKELY(observed.is_being_written())) {
225  observed = address->xct_id_;
226  }
227 
228  *out = Epoch(cur_truncate_epoch_.load()); // atomic!
229  CHECK_ERROR_CODE(cur_xct.add_to_lock_free_read_set(
230  meta_.id_,
231  observed,
232  const_cast< xct::RwLockableXctId* >(address))); // why it doesn't receive const? I forgot..
233  return kErrorCodeOk;
234 }
std::atomic< Epoch::EpochInteger > cur_truncate_epoch_
The min epoch value (truncate-epoch) for all valid records in this storage.
xct::RwLockableXctId cur_truncate_epoch_tid_
Protects accesses to cur_truncate_epoch_.
XctId xct_id_
the second 64bit: Persistent status part of TID.
Definition: xct_id.hpp:1137
0 means no-error.
Definition: error_code.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
0x0A04 : "XCTION : This thread is not running any transaction." .
Definition: error_code.hpp:199
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
StorageId id_
the unique ID of this storage.
Definition: metadata.hpp:103

Here is the call graph for this function:

Member Data Documentation

std::atomic< Epoch::EpochInteger > foedus::storage::sequential::SequentialStorageControlBlock::cur_truncate_epoch_

The min epoch value (truncate-epoch) for all valid records in this storage.

When a physical record or a page has an epoch value less than a truncate-epoch, they are logically non-existent. Truncate-epoch is always valid, starting from the system's lowest epoch.

Definition at line 77 of file sequential_storage_pimpl.hpp.

Referenced by optimistic_read_truncate_epoch().

xct::RwLockableXctId foedus::storage::sequential::SequentialStorageControlBlock::cur_truncate_epoch_tid_

Protects accesses to cur_truncate_epoch_.

  • Append-operations don't need to check it.
  • Scan-operations take this as a read-set.
  • Truncate-operation locks it and update cur_truncate_epoch_.

Definition at line 74 of file sequential_storage_pimpl.hpp.

Referenced by optimistic_read_truncate_epoch().

VolatilePagePointer foedus::storage::sequential::SequentialStorageControlBlock::head_pointer_pages_[kPointerPageCount]

Points to pages that store thread-private head pages to store thread-private volatile pages.

Each page can contain 2^10 pointers (as the node is implicit, PagePoolOffset suffices) and we can have at most 2^16 cores. Thus we have 2^6 pointers here. This means we can waste 64*2=128 volatile pages (=512kb) per one sequential storage.. shouldn't be a big issue.

Definition at line 86 of file sequential_storage_pimpl.hpp.

SequentialMetadata foedus::storage::sequential::SequentialStorageControlBlock::meta_

metadata of this storage.

Definition at line 63 of file sequential_storage_pimpl.hpp.

Referenced by optimistic_read_truncate_epoch().

DualPagePointer foedus::storage::sequential::SequentialStorageControlBlock::root_page_pointer_

Points to the root page (or something equivalent).

Definition at line 61 of file sequential_storage_pimpl.hpp.

StorageStatus foedus::storage::sequential::SequentialStorageControlBlock::status_

Status of the storage.

Definition at line 59 of file sequential_storage_pimpl.hpp.

Referenced by exists().

soc::SharedMutex foedus::storage::sequential::SequentialStorageControlBlock::status_mutex_

Definition at line 57 of file sequential_storage_pimpl.hpp.

VolatilePagePointer foedus::storage::sequential::SequentialStorageControlBlock::tail_pointer_pages_[kPointerPageCount]

Same above, but for tail pointers.

Definition at line 88 of file sequential_storage_pimpl.hpp.


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