18 #ifndef FOEDUS_XCT_XCT_HPP_
19 #define FOEDUS_XCT_XCT_HPP_
73 uint32_t* mcs_block_current,
74 uint32_t* mcs_rw_async_mapping_current);
82 enable_rll_for_this_xct_ = default_rll_for_this_xct_;
83 hot_threshold_for_this_xct_ = default_hot_threshold_for_this_xct_;
84 rll_threshold_for_this_xct_ = default_rll_threshold_for_this_xct_;
85 isolation_level_ = isolation_level;
86 pointer_set_size_ = 0;
87 page_version_set_size_ = 0;
90 lock_free_read_set_size_ = 0;
91 lock_free_write_set_size_ = 0;
92 *mcs_block_current_ = 0;
93 *mcs_rw_async_mapping_current_ = 0;
94 local_work_memory_cur_ = 0;
96 if (!retrospective_lock_list_.
is_empty()) {
112 *mcs_block_current_ = 0;
113 *mcs_rw_async_mapping_current_ = 0;
131 return default_hot_threshold_for_this_xct_ ; }
133 default_hot_threshold_for_this_xct_ = value; }
138 return default_rll_threshold_for_this_xct_ ; }
140 default_rll_threshold_for_this_xct_ = value; }
146 return write_set_size_ == 0 && lock_free_write_set_size_ == 0;
279 bool intended_for_write,
283 bool no_readset_if_moved =
false,
284 bool no_readset_if_next_layer =
false);
287 bool intended_for_write,
289 bool no_readset_if_moved =
false,
290 bool no_readset_if_next_layer =
false) {
298 no_readset_if_moved ,
299 no_readset_if_next_layer);
305 bool intended_for_write,
320 char* payload_address,
331 XctId observed_owner_id,
337 XctId observed_owner_id,
348 char* payload_address,
366 XctId observed_owner_id,
368 char* payload_address,
376 XctId observed_owner_id,
398 if (size % alignment != 0) {
399 size = ((size / alignment) + 1U) * alignment;
401 uint64_t begin = local_work_memory_cur_;
402 if (begin % alignment != 0) {
403 begin = ((begin / alignment) + 1U) * alignment;
405 if (
UNLIKELY(size + begin > local_work_memory_size_)) {
408 local_work_memory_cur_ = size + begin;
409 *out =
reinterpret_cast<char*
>(local_work_memory_) + begin;
416 return &retrospective_lock_list_;
426 friend
std::ostream& operator<<(
std::ostream& o, const
Xct& v);
433 thread::Thread* const context_;
463 bool enable_rll_for_this_xct_;
470 bool default_rll_for_this_xct_;
474 uint16_t hot_threshold_for_this_xct_;
475 uint16_t default_hot_threshold_for_this_xct_;
479 uint16_t rll_threshold_for_this_xct_;
480 uint16_t default_rll_threshold_for_this_xct_;
494 uint32_t* mcs_block_current_;
496 uint32_t* mcs_rw_async_mapping_current_;
499 uint32_t read_set_size_;
500 uint32_t max_read_set_size_;
503 uint32_t write_set_size_;
504 uint32_t max_write_set_size_;
507 uint32_t lock_free_read_set_size_;
508 uint32_t max_lock_free_read_set_size_;
511 uint32_t lock_free_write_set_size_;
512 uint32_t max_lock_free_write_set_size_;
515 uint32_t pointer_set_size_;
518 uint32_t page_version_set_size_;
532 void* local_work_memory_;
533 uint64_t local_work_memory_size_;
535 uint64_t local_work_memory_cur_;
540 for (uint32_t i = 0; i < write_set_size_; ++i) {
551 for (uint32_t i = 0; i < read_set_size_; ++i) {
571 #endif // FOEDUS_XCT_XCT_HPP_
void set_default_rll_for_this_xct(bool value)
ReadXctAccess * related_read_
void issue_next_id(XctId max_xct_id, Epoch *epoch)
Called while a successful commit of xct to issue a new xct id.
uint32_t get_mcs_block_current() const
Represents a record of special read-access during a transaction without any need for locking...
uint16_t get_default_rll_threshold_for_this_xct() const
Represents one record in our key-value store.
ErrorCode add_to_write_set(storage::StorageId storage_id, storage::Record *record, log::RecordLogType *log_entry)
Add the given record to the write set of this transaction.
void set_enable_rll_for_this_xct(bool value)
ErrorCode add_to_read_set(storage::StorageId storage_id, XctId observed_owner_id, RwLockableXctId *owner_id_address, ReadXctAccess **read_set_address)
Add the given record to the read set of this transaction.
xct::CurrentLockList * get_current_lock_list()
void set_default_hot_threshold_for_this_xct(uint16_t value)
bool assert_related_read_write() const __attribute__((always_inline))
This debug method checks whether the related_read_ and related_write_ fileds in read/write sets are c...
const PointerAccess * get_pointer_set() const
uint32_t StorageId
Unique ID for storage.
uint32_t get_write_set_size() const
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Represents a record of write-access during a transaction.
Represents one thread running on one NUMA core.
ErrorCode on_record_read(bool intended_for_write, RwLockableXctId *tid_address, XctId *observed_xid, ReadXctAccess **read_set_address, bool no_readset_if_moved=false, bool no_readset_if_next_layer=false)
The general logic invoked for every record read.
Typedefs of ID types used in thread package.
void deactivate()
Closes the transaction.
Forward declarations of classes in transaction package.
const XctId & get_id() const
Returns the ID of this transaction, but note that it is not issued until commit time! ...
void set_hot_threshold_for_this_xct(uint16_t value)
Represents a pointer to a volatile page with modification count for preventing ABA.
bool before(const XctId &other) const __attribute__((always_inline))
Returns if this XctId is before other in serialization order, meaning this is either an invalid (unus...
Represents a user transaction.
Just a synonym of XctId to be used as a page lock mechanism.
Forward declarations of classes in root package.
Persistent status part of Transaction ID.
Represents a record of read-access during a transaction.
bool is_active() const
Returns whether the object is an active transaction.
ErrorCode add_to_write_set(storage::StorageId storage_id, RwLockableXctId *owner_id_address, char *payload_address, log::RecordLogType *log_entry)
Add the given record to the write set of this transaction.
ErrorCode on_record_read(bool intended_for_write, RwLockableXctId *tid_address, bool no_readset_if_moved=false, bool no_readset_if_next_layer=false)
Shortcut for a case when you don't need observed_xid/read_set_address back.
void prepopulate_for_retrospective_lock_list(const RetrospectiveLockList &rll)
Another batch-insert method used at the beginning of a transaction.
Declares common log types used in all packages.
ReadXctAccess * get_read_set()
ErrorCode add_to_read_and_write_set(storage::StorageId storage_id, XctId observed_owner_id, RwLockableXctId *owner_id_address, char *payload_address, log::RecordLogType *log_entry)
Add a pair of read and write set of this transaction.
thread::ThreadId get_thread_id() const
ErrorCode add_to_lock_free_read_set(storage::StorageId storage_id, XctId observed_owner_id, RwLockableXctId *owner_id_address)
Add the given record to the special read-set that is not placed in usual data pages.
Represents a record of special write-access during a transaction without any need for locking...
Repository of memories dynamically acquired within one CPU core (thread).
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
uint32_t increment_mcs_block_current()
The MCS reader-writer lock variant of LockableXctId.
void set_rll_threshold_for_this_xct(uint16_t value)
void decrement_mcs_block_current()
bool is_default_rll_for_this_xct() const
void remember_previous_xct_id(XctId new_id)
Forward declarations of classes in storage package.
char payload_[8]
Arbitrary payload given by the user.
Definitions of IDs in this package and a few related constant values.
uint32_t get_read_set_size() const
ErrorCode add_related_write_set(ReadXctAccess *related_read_set, RwLockableXctId *tid_address, char *payload_address, log::RecordLogType *log_entry)
Registers a write-set related to an existing read-set.
ErrorCode add_to_lock_free_write_set(storage::StorageId storage_id, log::RecordLogType *log_entry)
Add the given log to the lock-free write set of this transaction.
uint16_t get_default_hot_threshold_for_this_xct() const
RwLockableXctId * owner_id_address_
Pointer to the accessed record.
uint16_t get_hot_threshold_for_this_xct() const
bool is_read_only() const
Returns if this transaction makes no writes.
const xct::CurrentLockList * get_current_lock_list() const
Database engine object that holds all resources and provides APIs.
uint32_t get_page_version_set_size() const
Just a marker to denote that the memory region represents a data page.
SysxctWorkspace * get_sysxct_workspace() const
void on_record_read_take_locks_if_needed(bool intended_for_write, const storage::Page *page_address, UniversalLockId lock_id, RwLockableXctId *tid_address)
subroutine of on_record_read() to take lock(s).
WriteXctAccess * related_write_
An optional member that points to a write access related to this read.
xct::RetrospectiveLockList * get_retrospective_lock_list()
Xct & operator=(const Xct &other)=delete
Forward declarations of classes in memory package.
uint32_t get_pointer_set_size() const
WriteXctAccess * get_write_set()
IsolationLevel
Specifies the level of isolation during transaction processing.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
uint32_t get_lock_free_read_set_size() const
IsolationLevel get_isolation_level() const
Returns the level of isolation for this transaction.
void activate(IsolationLevel isolation_level)
Begins the transaction.
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes.
thread::Thread * get_thread_context()
uint16_t get_rll_threshold_for_this_xct() const
void set_default_rll_threshold_for_this_xct(uint16_t value)
ErrorCode add_to_page_version_set(const storage::PageVersion *version_address, storage::PageVersionStatus observed)
Add the given page version to the page version set of this transaction.
Sorted list of all locks, either read-lock or write-lock, taken in the current run.
bool is_enable_rll_for_this_xct() const
ErrorCode acquire_local_work_memory(uint32_t size, void **out, uint32_t alignment=8)
Get a tentative work memory of the specified size from pre-allocated thread-private memory...
Base class for log type of record-wise operation.
#define UNLIKELY(x)
Hints that x is highly likely false.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Represents a record of following a page pointer during a transaction.
const PageVersionAccess * get_page_version_set() const
LockFreeWriteXctAccess * get_lock_free_write_set()
Forward declarations of classes in thread package.
uint32_t get_lock_free_write_set_size() const
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
Represents a record of reading a page during a transaction.
void overwrite_to_pointer_set(const storage::VolatilePagePointer *pointer_address, storage::VolatilePagePointer observed)
The transaction that has updated the volatile pointer should not abort itself.
ErrorCode add_to_pointer_set(const storage::VolatilePagePointer *pointer_address, storage::VolatilePagePointer observed)
Add the given page pointer to the pointer set of this transaction.
0x0A09 : "XCTION : Out of local work memory for the current transaction. Adjust XctOptions::local_wor...
ErrorCode
Enum of error codes defined in error_code.xmacro.
xct::RwLockableXctId owner_id_
This indicates the transaction that most recently modified this record.
Per-thread reused work memory for system transactions.
Xct(Engine *engine, thread::Thread *context, thread::ThreadId thread_id)
void initialize(memory::NumaCoreMemory *core_memory, uint32_t *mcs_block_current, uint32_t *mcs_rw_async_mapping_current)
LockFreeReadXctAccess * get_lock_free_read_set()