20 #include <glog/logging.h> 
   44     node_memory_(node_memory),
 
   48     free_volatile_pool_chunk_(nullptr),
 
   49     free_snapshot_pool_chunk_(nullptr),
 
   50     retired_volatile_pool_chunks_(nullptr),
 
   51     current_lock_list_memory_(nullptr),
 
   52     current_lock_list_capacity_(0),
 
   53     retrospective_lock_list_memory_(nullptr),
 
   54     retrospective_lock_list_capacity_(0),
 
   55     volatile_pool_(nullptr),
 
   56     snapshot_pool_(nullptr) {
 
   59                           core_local_ordinal_));
 
   63   uint64_t memory_size = 0;
 
   89   LOG(INFO) << 
"Initializing NumaCoreMemory for core " << core_id_;
 
  100   if (memory_size > (1U << 21)) {
 
  101     VLOG(1) << 
"mm, small_local_memory_size is more than 2MB(" << memory_size << 
")." 
  102       " not a big issue, but consumes one more TLB entry...";
 
  109   char* memory = 
reinterpret_cast<char*
>(small_thread_local_memory_.
get_block());
 
  112   memory += 
static_cast<uint64_t
>(core_local_ordinal_) << 12;
 
  130   const uint64_t total_access_sets = xct_opt.max_read_set_size_ + xct_opt.max_write_set_size_;
 
  131   current_lock_list_memory_ = 
reinterpret_cast<xct::LockEntry*
>(memory);
 
  132   current_lock_list_capacity_ = total_access_sets;
 
  134   retrospective_lock_list_memory_ = 
reinterpret_cast<xct::LockEntry*
>(memory);
 
  135   retrospective_lock_list_capacity_ = total_access_sets;
 
  138   memory += 
static_cast<uint64_t
>(thread_per_group - core_local_ordinal_) << 12;
 
  140     + memory_size == memory);
 
  142   for (uint16_t node = 0; node < nodes; ++node) {
 
  143     retired_volatile_pool_chunks_[node].
clear();
 
  147     xct_opt.local_work_memory_size_mb_ * (1ULL << 20),
 
  148     &local_work_memory_));
 
  153     uint32_t grab_count = std::min<uint32_t>(
 
  161     uint32_t grab_count = std::min<uint32_t>(
 
  171   LOG(INFO) << 
"Releasing NumaCoreMemory for core " << core_id_;
 
  174   if (retired_volatile_pool_chunks_) {
 
  177     for (uint16_t node = 0; node < engine_->
get_soc_count(); ++node) {
 
  181     retired_volatile_pool_chunks_ = 
nullptr;
 
  183   if (free_volatile_pool_chunk_) {
 
  184     volatile_pool_->
release(free_volatile_pool_chunk_->
size(), free_volatile_pool_chunk_);
 
  185     free_volatile_pool_chunk_ = 
nullptr;
 
  186     volatile_pool_ = 
nullptr;
 
  188   if (free_snapshot_pool_chunk_) {
 
  189     snapshot_pool_->
release(free_snapshot_pool_chunk_->
size(), free_snapshot_pool_chunk_);
 
  190     free_snapshot_pool_chunk_ = 
nullptr;
 
  191     snapshot_pool_ = 
nullptr;
 
  193   log_buffer_memory_.
clear();
 
  201     if (grab_free_pages_from_node(free_volatile_pool_chunk_, volatile_pool_) != 
kErrorCodeOk) {
 
  206   return free_volatile_pool_chunk_->
pop_back();
 
  215     release_free_pages_to_node(free_volatile_pool_chunk_, volatile_pool_);
 
  218   free_volatile_pool_chunk_->
push_back(offset);
 
  223     if (grab_free_pages_from_node(free_snapshot_pool_chunk_, snapshot_pool_) != 
kErrorCodeOk) {
 
  228   return free_snapshot_pool_chunk_->
pop_back();
 
  232     release_free_pages_to_node(free_snapshot_pool_chunk_, snapshot_pool_);
 
  235   free_snapshot_pool_chunk_->
push_back(offset);
 
  238 ErrorCode NumaCoreMemory::grab_free_pages_from_node(
 
  241   uint32_t desired = (free_chunk->
capacity() - free_chunk->
size()) / 2;
 
  243   return pool->
grab(desired, free_chunk);
 
  246 void NumaCoreMemory::release_free_pages_to_node(
 
  247   PagePoolOffsetChunk* free_chunk,
 
  249   uint32_t desired = free_chunk->size() / 2;
 
  250   pool->
release(desired, free_chunk);
 
  254   return retired_volatile_pool_chunks_ + node;
 
ErrorStack uninitialize_once() override
 
ErrorStack allocate_numa_memory(uint64_t size, AlignedMemory *out) const 
 
ErrorStack initialize_once() override
 
Represents a record of special read-access during a transaction without any need for locking...
 
void release_free_volatile_page(PagePoolOffset offset)
Returns one free volatile page to local page pool. 
 
PagePoolOffset grab_free_volatile_page()
Acquires one free volatile page from local page pool. 
 
uint32_t max_lock_free_read_set_size_
The maximum number of lock-free read-set one transaction can have. 
 
Page pool for volatile read/write store (VolatilePage) and the read-only bufferpool (SnapshotPage)...
 
uint32_t private_page_pool_initial_grab_
How many pages each NumaCoreMemory initially grabs when it is initialized. 
 
void release_block()
Releases the memory block. 
 
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services). 
 
PagePool * get_snapshot_pool()
 
Represents a record of write-access during a transaction. 
 
char * xct_write_access_memory_
 
uint32_t PagePoolOffset
Offset in PagePool that compactly represents the page address (unlike 8 bytes pointer). 
 
char * xct_lock_free_write_access_memory_
 
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core). 
 
Represents a pointer to a volatile page with modification count for preventing ABA. 
 
PagePoolOffsetChunk * get_volatile_offset_chunk_memory_piece(foedus::thread::ThreadLocalOrdinal core_ordinal)
 
Brings error stacktrace information as return value of functions. 
 
Represents a record of read-access during a transaction. 
 
An entry in CLL and RLL, representing a lock that is taken or will be taken. 
 
ErrorCode grab(uint32_t desired_grab_count, PagePoolOffsetChunk *chunk)
Adds the specified number of free pages to the chunk. 
 
char * xct_lock_free_read_access_memory_
 
uint32_t get_recommended_pages_per_grab() const 
 
storage::VolatilePagePointer grab_free_volatile_page_pointer()
Wrapper for grab_free_volatile_page(). 
 
Represents a record of special write-access during a transaction without any need for locking...
 
const EngineOptions & get_options() const 
 
ThreadLocalOrdinal thread_count_per_group_
Number of Thread in each ThreadGroup. 
 
soc::SocId get_soc_count() const 
Shorthand for get_options().thread_.group_count_. 
 
Set of options for xct manager. 
 
foedus::thread::ThreadGroupId get_numa_node() const 
 
Batches zero or more ErrorStack objects to represent in one ErrorStack. 
 
memory::MemoryOptions memory_
 
Definitions of IDs in this package and a few related constant values. 
 
uint32_t max_lock_free_write_set_size_
The maximum number of lock-free write-set one transaction can have. 
 
void release_free_snapshot_page(PagePoolOffset offset)
Same, except it's for snapshot page. 
 
Database engine object that holds all resources and provides APIs. 
 
Repository of memories dynamically acquired and shared within one NUMA node (socket). 
 
char * xct_pointer_access_memory_
 
char * sysxct_workspace_memory_
 
void set(uint8_t numa_node, memory::PagePoolOffset offset)
 
Set of option values given to the engine at start-up. 
 
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core). 
 
void * get_block() const 
Returns the memory block. 
 
uint16_t group_count_
Number of ThreadGroup in the engine. 
 
void release(uint32_t desired_release_count, PagePoolOffsetChunk *chunk)
Returns the specified number of free pages from the chunk. 
 
uint32_t max_write_set_size_
The maximum number of write-set one transaction can have. 
 
ThreadId compose_thread_id(ThreadGroupId node, ThreadLocalOrdinal local_core)
Returns a globally unique ID of Thread (core) for the given node and ordinal in the node...
 
#define SUMMARIZE_ERROR_BATCH(x)
This macro calls ErrorStackBatch::summarize() with automatically provided parameters. 
 
PagePoolOffsetAndEpochChunk * get_retired_volatile_pool_chunk(uint16_t node)
 
char * xct_read_access_memory_
 
PagePoolOffset pop_back()
 
PagePoolOffset grab_free_snapshot_page()
Same, except it's for snapshot page. 
 
void push_back(PagePoolOffset pointer)
 
thread::ThreadOptions thread_
 
static uint64_t calculate_local_small_memory_size(const EngineOptions &options)
 
To reduce the overhead of grabbing/releasing pages from pool, we pack this many pointers for each gra...
 
#define CHECK_ERROR(x)
This macro calls x and checks its returned value. 
 
uint16_t ThreadId
Typedef for a global ID of Thread (core), which is unique across NUMA nodes. 
 
const ErrorStack kRetOk
Normal return value for no-error case. 
 
PagePoolOffsetChunk * get_snapshot_offset_chunk_memory_piece(foedus::thread::ThreadLocalOrdinal core_ordinal)
 
Used to store an epoch value with each entry in PagePoolOffsetChunk. 
 
uint32_t capacity() const 
 
#define UNLIKELY(x)    
Hints that x is highly likely false. 
 
uint64_t get_free_pool_capacity() const 
 
#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. 
 
#define WRAP_ERROR_CODE(x)
Same as CHECK_ERROR(x) except it receives only an error code, thus more efficient. 
 
uint32_t max_read_set_size_
The maximum number of read-set one transaction can have. 
 
Represents a record of reading a page during a transaction. 
 
ErrorCode
Enum of error codes defined in error_code.xmacro. 
 
Per-thread reused work memory for system transactions. 
 
AlignedMemorySlice get_log_buffer_memory_piece(log::LoggerId logger)
 
PagePool * get_volatile_pool()
 
char * xct_page_version_memory_