libfoedus-core
FOEDUS Core Library
|
Metadata part of ThreadLogBuffer, without the actual buffer which is way way larger. More...
Metadata part of ThreadLogBuffer, without the actual buffer which is way way larger.
Marker | Read by | Written by | Description |
---|---|---|---|
offset_head_ (H) | Thread | Thread, LogGleaner | This marks the position where log entries start. This private log buffer is a circular buffer where the head is eaten by log gleaner. However, log gleaner is okay to get behind, reading from log file instead (but slower). Thus, offset_head_ is advanced either by log gleaner or this thread. If the latter happens, log gleaner has to give up using in-memory logs and instead read from log files. |
offset_durable_ (D) | Thread, LogGleaner | Logger | This marks the position upto which the log writer durably wrote out to log files. Everything after this position must not be discarded because they are not yet durable. When the log writer reads log entries after here, writes them to log file, and calls fsync, this variable is advanced by the log writer. This variable is read by this thread to check the end of the circular buffer. |
offset_committed_ (C) | Thread, Logger | Thread | This marks the position upto which transaction logs are committed by the thread. Log writers can safely read log entries and write them to log files up to this place. When the transaction commits, this value is advanced by the thread. The only possible update pattern to this variable is advance by this thread. Thus, the log writer can safely read this variable without any fence or lock thanks to regular (either old value or new value, never garbage) read of 64-bit. |
offset_tail_ (T) | Thread | Thread | The current cursor to which next log will be written. This is the location the current transaction of this thread is writing to before commit. When the transaction commits, offset_committed_ catches up with this. When the transaction aborts, this value rolls back to offset_committed_. Only this thread reads/writes to this variable. No other threads access this. |
Definition at line 147 of file thread_log_buffer.hpp.
#include <thread_log_buffer.hpp>
Public Types | |
enum | Constants { kMaxNonDurableEpochs = 64 } |
Public Member Functions | |
ThreadLogBufferMeta () | |
void | assert_consistent () const |
Only for Debug-assertion. More... | |
Static Public Member Functions | |
static uint32_t | increment_mark_index (uint32_t index) |
Public Attributes | |
thread::ThreadId | thread_id_ |
uint16_t | padding1_ |
uint32_t | padding2_ |
uint64_t | buffer_size_ |
Size of the buffer assigned to this thread. More... | |
uint64_t | buffer_size_safe_ |
buffer_size_ - 64. More... | |
uint64_t | offset_head_ |
This marks the position where log entries start. More... | |
uint64_t | offset_durable_ |
This marks the position upto which the log writer durably wrote out to log files. More... | |
uint64_t | offset_committed_ |
This marks the position upto which transaction logs are committed by the thread. More... | |
uint64_t | offset_tail_ |
The current cursor to which next log will be written. More... | |
ThreadEpockMark | thread_epoch_marks_ [kMaxNonDurableEpochs] |
Circular array of epoch marks of a thread log buffer. More... | |
uint32_t | oldest_mark_index_ |
Array index in thread_epoch_marks_ that indicates the oldest epoch mark to be consumed by the logger. More... | |
uint32_t | current_mark_index_ |
Array index in thread_epoch_marks_ that indicates the current epoch being appended by the thread, so the logger must avoid touching the epoch. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const ThreadLogBufferMeta &v) |
Definition at line 148 of file thread_log_buffer.hpp.
foedus::log::ThreadLogBufferMeta::ThreadLogBufferMeta | ( | ) |
Definition at line 44 of file thread_log_buffer.cpp.
References buffer_size_, buffer_size_safe_, current_mark_index_, offset_committed_, offset_durable_, offset_head_, offset_tail_, oldest_mark_index_, thread_epoch_marks_, and thread_id_.
void foedus::log::ThreadLogBufferMeta::assert_consistent | ( | ) | const |
Only for Debug-assertion.
This method must be called by the worker thread itself. When logger calls it, it must make sure the worker is not modifying anything concurrently.
Definition at line 59 of file thread_log_buffer.cpp.
References ASSERT_ND, buffer_size_, current_mark_index_, increment_mark_index(), foedus::Epoch::is_valid(), kMaxNonDurableEpochs, foedus::log::ThreadEpockMark::new_epoch_, foedus::log::ThreadEpockMark::offset_begin_, offset_committed_, offset_durable_, foedus::log::ThreadEpockMark::offset_end_, offset_head_, offset_tail_, foedus::log::ThreadEpockMark::old_epoch_, oldest_mark_index_, and thread_epoch_marks_.
Referenced by foedus::log::ThreadLogBuffer::assert_consistent().
|
inlinestatic |
Definition at line 170 of file thread_log_buffer.hpp.
References kMaxNonDurableEpochs.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::on_log_written(), and foedus::log::operator<<().
|
friend |
Definition at line 335 of file thread_log_buffer.cpp.
uint64_t foedus::log::ThreadLogBufferMeta::buffer_size_ |
Size of the buffer assigned to this thread.
Definition at line 179 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::head_to_tail_distance(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::operator<<(), foedus::log::ThreadLogBuffer::reserve_new_log(), and ThreadLogBufferMeta().
uint64_t foedus::log::ThreadLogBufferMeta::buffer_size_safe_ |
buffer_size_ - 64.
We always leave some hole between offset_tail_ and offset_head_ to avoid the case offset_tail_ == offset_head_ (log empty? or log full?). One classic way to handle this case is to store count rather than offsets, but it makes synchronization between log writer and this thread expensive. Rather, we sacrifice a negligible space.
Definition at line 189 of file thread_log_buffer.hpp.
Referenced by foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::ThreadLogBuffer::reserve_new_log(), ThreadLogBufferMeta(), and foedus::log::ThreadLogBuffer::wait_for_space().
uint32_t foedus::log::ThreadLogBufferMeta::current_mark_index_ |
Array index in thread_epoch_marks_ that indicates the current epoch being appended by the thread, so the logger must avoid touching the epoch.
Definition at line 251 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_last_epoch(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::ThreadLogBuffer::on_log_written(), foedus::log::operator<<(), and ThreadLogBufferMeta().
uint64_t foedus::log::ThreadLogBufferMeta::offset_committed_ |
This marks the position upto which transaction logs are committed by the thread.
Log writers can safely read log entries and write them to log files up to this place. When the transaction commits, this value is advanced by the thread. The only possible update pattern to this variable is advance by this thread. Thus, the log writer can safely read this variable without any fence or lock thanks to regular (either old value or new value, never garbage) read of 64-bit.
Definition at line 221 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::discard_current_xct_log(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::get_offset_committed(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::operator<<(), foedus::log::ThreadLogBuffer::publish_committed_log(), ThreadLogBufferMeta(), and foedus::log::ThreadLogBuffer::wait_for_space().
uint64_t foedus::log::ThreadLogBufferMeta::offset_durable_ |
This marks the position upto which the log writer durably wrote out to log files.
Everything after this position must not be discarded because they are not yet durable. When the log writer reads log entries after here, writes them to log file, and calls fsync, this variable is advanced by the log writer. This variable is read by this thread to check the end of the circular buffer.
Definition at line 210 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::get_offset_durable(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::ThreadLogBuffer::on_log_written(), foedus::log::operator<<(), ThreadLogBufferMeta(), and foedus::log::ThreadLogBuffer::wait_for_space().
uint64_t foedus::log::ThreadLogBufferMeta::offset_head_ |
This marks the position where log entries start.
This private log buffer is a circular buffer where the head is eaten by log gleaner. However, log gleaner is okay to get behind, reading from log file instead (but slower). Thus, offset_head_ is advanced either by log gleaner or this thread. If the latter happens, log gleaner has to give up using in-memory logs and instead read from log files.
Definition at line 200 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_offset_head(), foedus::log::ThreadLogBuffer::head_to_tail_distance(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::operator<<(), ThreadLogBufferMeta(), and foedus::log::ThreadLogBuffer::wait_for_space().
uint64_t foedus::log::ThreadLogBufferMeta::offset_tail_ |
The current cursor to which next log will be written.
This is the location the current transaction of this thread is writing to before commit. When the transaction commits, offset_committed_ catches up with this. When the transaction aborts, this value rolls back to offset_committed_. Only this thread reads/writes to this variable. No other threads access this.
Definition at line 231 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::discard_current_xct_log(), foedus::log::ThreadLogBuffer::get_offset_tail(), foedus::log::ThreadLogBuffer::head_to_tail_distance(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::operator<<(), foedus::log::ThreadLogBuffer::publish_committed_log(), foedus::log::ThreadLogBuffer::reserve_new_log(), and ThreadLogBufferMeta().
uint32_t foedus::log::ThreadLogBufferMeta::oldest_mark_index_ |
Array index in thread_epoch_marks_ that indicates the oldest epoch mark to be consumed by the logger.
Definition at line 241 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::ThreadLogBuffer::on_log_written(), foedus::log::operator<<(), and ThreadLogBufferMeta().
uint16_t foedus::log::ThreadLogBufferMeta::padding1_ |
Definition at line 175 of file thread_log_buffer.hpp.
uint32_t foedus::log::ThreadLogBufferMeta::padding2_ |
Definition at line 176 of file thread_log_buffer.hpp.
ThreadEpockMark foedus::log::ThreadLogBufferMeta::thread_epoch_marks_[kMaxNonDurableEpochs] |
Circular array of epoch marks of a thread log buffer.
Definition at line 234 of file thread_log_buffer.hpp.
Referenced by assert_consistent(), foedus::log::ThreadLogBuffer::get_last_epoch(), foedus::log::ThreadLogBuffer::get_logs_to_write(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::ThreadLogBuffer::on_log_written(), foedus::log::operator<<(), and ThreadLogBufferMeta().
thread::ThreadId foedus::log::ThreadLogBufferMeta::thread_id_ |
Definition at line 174 of file thread_log_buffer.hpp.
Referenced by foedus::log::ThreadLogBuffer::get_thread_id(), foedus::log::ThreadLogBuffer::initialize_once(), foedus::log::operator<<(), foedus::log::ThreadLogBuffer::ThreadLogBuffer(), ThreadLogBufferMeta(), and foedus::log::ThreadLogBuffer::wait_for_space().