libfoedus-core
FOEDUS Core Library
foedus::memory::DivvyupPageGrabBatch Class Referencefinal

A helper class to grab a bunch of pages from multiple nodes in arbitrary fashion. More...

Detailed Description

A helper class to grab a bunch of pages from multiple nodes in arbitrary fashion.

Similar to RoundRobinPageGrabBatch. This class doesn't specify how nodes divvy up pages. The caller has the control. Or, this class provides a method for each policy.

Definition at line 375 of file page_pool.hpp.

#include <page_pool.hpp>

Public Member Functions

 DivvyupPageGrabBatch (Engine *engine)
 
 ~DivvyupPageGrabBatch ()
 
 DivvyupPageGrabBatch ()=delete
 
 DivvyupPageGrabBatch (const DivvyupPageGrabBatch &)=delete
 
DivvyupPageGrabBatchoperator= (const DivvyupPageGrabBatch &)=delete
 
storage::VolatilePagePointer grab (thread::ThreadGroupId node)
 Grabs an in-memory page in specified NUMA node. More...
 
storage::VolatilePagePointer grab_evenly (uint64_t cur, uint64_t total)
 Grabs an in-memory page evenly and contiguously from each NUMA node. More...
 
void release_all ()
 Called at the end to return all remaining pages to their pools. More...
 

Constructor & Destructor Documentation

foedus::memory::DivvyupPageGrabBatch::DivvyupPageGrabBatch ( Engine engine)
explicit

Definition at line 252 of file page_pool.cpp.

References ASSERT_ND.

253 : engine_(engine), node_count_(engine->get_options().thread_.group_count_) {
254  chunks_ = new PagePoolOffsetChunk[node_count_];
255  for (uint16_t node = 0; node < node_count_; ++node) {
256  ASSERT_ND(chunks_[node].empty());
257  }
258 }
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
foedus::memory::DivvyupPageGrabBatch::~DivvyupPageGrabBatch ( )

Definition at line 260 of file page_pool.cpp.

References release_all().

260  {
261  release_all();
262  delete[] chunks_;
263  chunks_ = nullptr;
264 }
void release_all()
Called at the end to return all remaining pages to their pools.
Definition: page_pool.cpp:298

Here is the call graph for this function:

foedus::memory::DivvyupPageGrabBatch::DivvyupPageGrabBatch ( )
delete
foedus::memory::DivvyupPageGrabBatch::DivvyupPageGrabBatch ( const DivvyupPageGrabBatch )
delete

Member Function Documentation

storage::VolatilePagePointer foedus::memory::DivvyupPageGrabBatch::grab ( thread::ThreadGroupId  node)

Grabs an in-memory page in specified NUMA node.

Parameters
[in]nodespecify NUMA node
Precondition
node < node_count_

Definition at line 267 of file page_pool.cpp.

References ASSERT_ND, foedus::memory::PagePoolOffsetChunk::capacity(), foedus::get_error_name(), foedus::Engine::get_memory_manager(), foedus::memory::EngineMemory::get_node_memory(), foedus::memory::PagePool::get_recommended_pages_per_grab(), foedus::memory::NumaNodeMemoryRef::get_volatile_pool(), foedus::memory::PagePool::grab(), foedus::kErrorCodeMemoryNoFreePages, foedus::kErrorCodeOk, and foedus::storage::VolatilePagePointer::set().

Referenced by grab_evenly().

267  {
268  ASSERT_ND(node < node_count_);
269  if (chunks_[node].empty()) {
270  PagePool* pool = engine_->get_memory_manager()->get_node_memory(node)->get_volatile_pool();
271  uint32_t grab_count = std::min<uint32_t>(
272  chunks_[node].capacity(),
273  pool->get_recommended_pages_per_grab());
274  ErrorCode code = pool->grab(grab_count, chunks_ + node);
275  if (code == kErrorCodeMemoryNoFreePages) {
276  LOG(FATAL) << "NUMA node " << static_cast<int>(node) << " has no free pages. This situation "
277  " is so far not handled in DivvyupPageGrabBatch. Aborting";
278  } else if (code != kErrorCodeOk) {
279  LOG(FATAL) << "Unexpected error code.. wtf error="
280  << code << "(" << get_error_name(code) << ")";
281  }
282  }
283  storage::VolatilePagePointer ret;
284  ret.set(node, chunks_[node].pop_back());
285  return ret;
286 }
const char * get_error_name(ErrorCode code)
Returns the names of ErrorCode enum defined in error_code.xmacro.
Definition: error_code.hpp:108
0 means no-error.
Definition: error_code.hpp:87
NumaNodeMemoryRef * get_node_memory(foedus::thread::ThreadGroupId group) const
0x0301 : "MEMORY : Not enough free volatile pages. Check the config of MemoryOptions" ...
Definition: error_code.hpp:142
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
memory::EngineMemory * get_memory_manager() const
See Memory Manager.
Definition: engine.cpp:50
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85

Here is the call graph for this function:

Here is the caller graph for this function:

storage::VolatilePagePointer foedus::memory::DivvyupPageGrabBatch::grab_evenly ( uint64_t  cur,
uint64_t  total 
)

Grabs an in-memory page evenly and contiguously from each NUMA node.

Parameters
[in]curpage index out of total.
[in]totaltotal pages to be allocated.

For example, if total=6 and there are 2 numa nodes, cur=0,1,2 get pages from NUMA node 0, cur=3,4,5 get pages from NUMA node 1. This is the most simple policy.

Definition at line 288 of file page_pool.cpp.

References grab().

288  {
290  if (node_count_ == 1U) {
291  node = 0;
292  } else {
293  node = cur * node_count_ / total;
294  }
295  return grab(node);
296 }
storage::VolatilePagePointer grab(thread::ThreadGroupId node)
Grabs an in-memory page in specified NUMA node.
Definition: page_pool.cpp:267
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
Definition: thread_id.hpp:38

Here is the call graph for this function:

DivvyupPageGrabBatch& foedus::memory::DivvyupPageGrabBatch::operator= ( const DivvyupPageGrabBatch )
delete
void foedus::memory::DivvyupPageGrabBatch::release_all ( )

Called at the end to return all remaining pages to their pools.

The grabbed pages are not returned, of course.

Definition at line 298 of file page_pool.cpp.

References ASSERT_ND, foedus::Engine::get_memory_manager(), foedus::memory::EngineMemory::get_node_memory(), foedus::memory::NumaNodeMemoryRef::get_volatile_pool(), and foedus::memory::PagePool::release().

Referenced by ~DivvyupPageGrabBatch().

298  {
299  for (uint16_t node = 0; node < node_count_; ++node) {
300  if (chunks_[node].empty()) {
301  continue;
302  }
304  chunks_[node].size(), chunks_ + node);
305  ASSERT_ND(chunks_[node].empty());
306  }
307 }
NumaNodeMemoryRef * get_node_memory(foedus::thread::ThreadGroupId group) const
void release(uint32_t desired_release_count, PagePoolOffsetChunk *chunk)
Returns the specified number of free pages from the chunk.
Definition: page_pool.cpp:134
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
memory::EngineMemory * get_memory_manager() const
See Memory Manager.
Definition: engine.cpp:50

Here is the call graph for this function:

Here is the caller graph for this function:


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