libfoedus-core
FOEDUS Core Library
|
Page pool for volatile read/write store (VolatilePage) and the read-only bufferpool (SnapshotPage). More...
Page pool for volatile read/write store (VolatilePage) and the read-only bufferpool (SnapshotPage).
The engine maintains a few instances of this class; one for each NUMA node. Each page pool provides in-memory pages for both volatile pages and snapshot pages.
Definition at line 173 of file page_pool.hpp.
#include <page_pool.hpp>
Classes | |
struct | Stat |
Public Member Functions | |
PagePool () | |
~PagePool () | |
void | attach (PagePoolControlBlock *control_block, void *memory, uint64_t memory_size, bool owns, bool rigorous_page_boundary_check) |
PagePool (const PagePool &)=delete | |
PagePool & | operator= (const PagePool &)=delete |
ErrorStack | initialize () override |
Acquires resources in this object, usually called right after constructor. More... | |
bool | is_initialized () const override |
Returns whether the object has been already initialized or not. More... | |
ErrorStack | uninitialize () override |
An idempotent method to release all resources of this object, if any. More... | |
storage::Page * | get_base () const |
uint64_t | get_free_pool_capacity () const |
uint64_t | get_memory_size () const |
uint32_t | get_recommended_pages_per_grab () const |
Stat | get_stat () const |
std::string | get_debug_pool_name () const |
void | set_debug_pool_name (const std::string &name) |
Call this anytime after attach() More... | |
ErrorCode | grab (uint32_t desired_grab_count, PagePoolOffsetChunk *chunk) |
Adds the specified number of free pages to the chunk. More... | |
ErrorCode | grab_one (PagePoolOffset *offset) |
Grab only one page. More... | |
void | release (uint32_t desired_release_count, PagePoolOffsetChunk *chunk) |
Returns the specified number of free pages from the chunk. More... | |
void | release (uint32_t desired_release_count, PagePoolOffsetDynamicChunk *chunk) |
void | release (uint32_t desired_release_count, PagePoolOffsetAndEpochChunk *chunk) |
Overload for PagePoolOffsetAndEpochChunk. More... | |
void | release_one (PagePoolOffset offset) |
Returns only one page. More... | |
const LocalPageResolver & | get_resolver () const |
Gives an object to resolve an offset in this page pool (thus local) to an actual pointer and vice versa. More... | |
![]() | |
virtual | ~Initializable () |
Friends | |
std::ostream & | operator<< (std::ostream &o, const PagePool &v) |
foedus::memory::PagePool::PagePool | ( | ) |
Definition at line 98 of file page_pool.cpp.
foedus::memory::PagePool::~PagePool | ( | ) |
Definition at line 109 of file page_pool.cpp.
|
delete |
void foedus::memory::PagePool::attach | ( | PagePoolControlBlock * | control_block, |
void * | memory, | ||
uint64_t | memory_size, | ||
bool | owns, | ||
bool | rigorous_page_boundary_check | ||
) |
Definition at line 101 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::attach().
Referenced by foedus::memory::NumaNodeMemory::initialize_once(), and foedus::memory::NumaNodeMemoryRef::NumaNodeMemoryRef().
storage::Page * foedus::memory::PagePool::get_base | ( | ) | const |
Definition at line 119 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::pool_base_.
Referenced by foedus::thread::ThreadPimpl::find_or_read_a_snapshot_page(), foedus::thread::ThreadPimpl::find_or_read_snapshot_pages_batch(), foedus::memory::EngineMemory::initialize_once(), and foedus::thread::ThreadPimpl::on_snapshot_cache_miss().
std::string foedus::memory::PagePool::get_debug_pool_name | ( | ) | const |
Definition at line 121 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::get_debug_pool_name().
uint64_t foedus::memory::PagePool::get_free_pool_capacity | ( | ) | const |
Definition at line 120 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::get_free_pool_capacity().
Referenced by foedus::memory::NumaCoreMemory::initialize_once().
uint64_t foedus::memory::PagePool::get_memory_size | ( | ) | const |
Definition at line 117 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::memory_size_.
Referenced by foedus::memory::NumaNodeMemory::initialize_once().
uint32_t foedus::memory::PagePool::get_recommended_pages_per_grab | ( | ) | const |
Especially in testcases, grabbing chunk-full of pages (4k pages) at a time immediately runs out of free pages unless we allocate huge pools for each run, which would make test-time significantly longer. For example, if the pool has only 1024 pages, it doesn't make sense to grab 2000 pages at a time! As soon as one thread does it, all other threads will get out-of-memory error although the culprit probably needs only a few pages. To avoid that, we respect this value in most places.
Definition at line 124 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::free_pool_capacity_.
Referenced by foedus::memory::RoundRobinPageGrabBatch::grab(), foedus::memory::DivvyupPageGrabBatch::grab(), and foedus::memory::NumaCoreMemory::initialize_once().
const LocalPageResolver & foedus::memory::PagePool::get_resolver | ( | ) | const |
Gives an object to resolve an offset in this page pool (thus local) to an actual pointer and vice versa.
Definition at line 146 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::get_resolver().
Referenced by foedus::storage::hash::HashStoragePimpl::create(), foedus::storage::sequential::SequentialStoragePimpl::drop(), foedus::storage::sequential::SequentialComposer::drop_volatiles(), foedus::storage::sequential::SequentialStoragePimpl::for_every_page(), foedus::memory::EngineMemory::grab_one_volatile_page(), foedus::storage::sequential::SequentialStoragePimpl::initialize_head_tail_pages(), foedus::memory::EngineMemory::initialize_once(), foedus::thread::ThreadPimpl::initialize_once(), and foedus::storage::masstree::MasstreeStoragePimpl::load_empty().
PagePool::Stat foedus::memory::PagePool::get_stat | ( | ) | const |
Definition at line 118 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::get_stat().
Referenced by foedus::cache::CacheManagerPimpl::describe(), foedus::memory::NumaNodeMemory::dump_free_memory_stat(), foedus::memory::NumaNodeMemoryRef::dump_free_memory_stat(), foedus::cache::CacheManagerPimpl::handle_cleaner(), and foedus::cache::CacheManagerPimpl::initialize_once().
ErrorCode foedus::memory::PagePool::grab | ( | uint32_t | desired_grab_count, |
PagePoolOffsetChunk * | chunk | ||
) |
Adds the specified number of free pages to the chunk.
[in] | desired_grab_count | we grab this number of free pages at most |
[in,out] | chunk | we append the grabbed free pages to this chunk |
Callers usually maintain one PagePoolOffsetChunk for its private use and calls this method when the size() goes below some threshold (eg 10%) so as to get size() about 50%.
Definition at line 129 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::grab().
Referenced by foedus::memory::RoundRobinPageGrabBatch::grab(), foedus::memory::DivvyupPageGrabBatch::grab(), and foedus::memory::NumaCoreMemory::initialize_once().
ErrorCode foedus::memory::PagePool::grab_one | ( | PagePoolOffset * | offset | ) |
Grab only one page.
More expensive, but handy in some situation.
Definition at line 132 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::grab_one().
Referenced by foedus::storage::hash::HashStoragePimpl::create(), foedus::memory::EngineMemory::grab_one_volatile_page(), foedus::storage::sequential::SequentialStoragePimpl::initialize_head_tail_pages(), and foedus::storage::masstree::MasstreeStoragePimpl::load_empty().
|
overridevirtual |
Acquires resources in this object, usually called right after constructor.
If and only if the return value was not an error, is_initialized() will return TRUE. This method is usually not idempotent, but some implementation can choose to be. In that case, the implementation class should clarify that it's idempotent. This method is responsible for releasing all acquired resources when initialization fails. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 114 of file page_pool.cpp.
References foedus::DefaultInitializable::initialize().
Referenced by foedus::memory::NumaNodeMemory::initialize_once().
|
overridevirtual |
Returns whether the object has been already initialized or not.
Implements foedus::Initializable.
Definition at line 115 of file page_pool.cpp.
References foedus::DefaultInitializable::is_initialized().
Referenced by foedus::memory::NumaNodeMemory::initialize_once().
void foedus::memory::PagePool::release | ( | uint32_t | desired_release_count, |
PagePoolOffsetChunk * | chunk | ||
) |
Returns the specified number of free pages from the chunk.
[in] | desired_release_count | we release this number of free pages |
[in,out] | chunk | we release free pages from the tail of this chunk |
Callers usually maintain one PagePoolOffsetChunk for its private use and calls this method when the size() goes above some threshold (eg 90%) so as to get size() about 50%.
Definition at line 134 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::release().
Referenced by foedus::storage::sequential::SequentialStoragePimpl::drop(), foedus::storage::Composer::DropVolatilesArguments::drop(), foedus::snapshot::SnapshotManagerPimpl::drop_volatile_pages_parallel(), foedus::thread::ThreadPimpl::flush_retired_volatile_page(), foedus::cache::CacheManagerPimpl::handle_cleaner(), foedus::memory::RoundRobinPageGrabBatch::release_all(), foedus::memory::DivvyupPageGrabBatch::release_all(), foedus::memory::PageReleaseBatch::release_chunk(), foedus::memory::NumaCoreMemory::uninitialize_once(), and foedus::thread::ThreadPimpl::uninitialize_once().
void foedus::memory::PagePool::release | ( | uint32_t | desired_release_count, |
PagePoolOffsetDynamicChunk * | chunk | ||
) |
Definition at line 137 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::release().
void foedus::memory::PagePool::release | ( | uint32_t | desired_release_count, |
PagePoolOffsetAndEpochChunk * | chunk | ||
) |
Overload for PagePoolOffsetAndEpochChunk.
Definition at line 140 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::release().
void foedus::memory::PagePool::release_one | ( | PagePoolOffset | offset | ) |
Returns only one page.
More expensive, but handy in some situation.
Definition at line 144 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::release_one().
Referenced by foedus::storage::sequential::SequentialStoragePimpl::drop(), foedus::storage::hash::HashIntermediatePage::release_pages_recursive_parallel(), and foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive_parallel().
void foedus::memory::PagePool::set_debug_pool_name | ( | const std::string & | name | ) |
Call this anytime after attach()
Definition at line 122 of file page_pool.cpp.
References foedus::memory::PagePoolPimpl::set_debug_pool_name().
Referenced by foedus::memory::NumaNodeMemory::initialize_once().
|
overridevirtual |
An idempotent method to release all resources of this object, if any.
After this method, is_initialized() will return FALSE. Whether this method encounters an error or not, the implementation should make the best effort to release as many resources as possible. In other words, Do not leak all resources because of one issue. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 116 of file page_pool.cpp.
References foedus::DefaultInitializable::uninitialize().
Referenced by foedus::memory::NumaNodeMemory::uninitialize_once().
|
friend |
Definition at line 148 of file page_pool.cpp.