libfoedus-core
FOEDUS Core Library
|
Pimpl object of CacheManager. More...
Pimpl object of CacheManager.
A private pimpl object for CacheManager. Do not include this header from a client program unless you know what you are doing.
Definition at line 44 of file cache_manager_pimpl.hpp.
#include <cache_manager_pimpl.hpp>
Public Member Functions | |
CacheManagerPimpl ()=delete | |
CacheManagerPimpl (Engine *engine) | |
ErrorStack | initialize_once () override |
ErrorStack | uninitialize_once () override |
std::string | describe () const |
void | handle_cleaner () |
Main routine of cleaner_. More... | |
void | handle_cleaner_evict_pages (uint64_t target_count) |
Evicts pages up to about target_count (maybe a bit more or less). More... | |
ErrorStack | stop_cleaner () |
![]() | |
DefaultInitializable () | |
virtual | ~DefaultInitializable () |
DefaultInitializable (const DefaultInitializable &)=delete | |
DefaultInitializable & | operator= (const DefaultInitializable &)=delete |
ErrorStack | initialize () override final |
Typical implementation of Initializable::initialize() that provides initialize-once semantics. More... | |
ErrorStack | uninitialize () override final |
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics. More... | |
bool | is_initialized () const override final |
Returns whether the object has been already initialized or not. More... | |
![]() | |
virtual | ~Initializable () |
Public Attributes | |
Engine *const | engine_ |
std::thread | cleaner_ |
The only cleaner thread in this SOC engine. More... | |
uint64_t | total_pages_ |
uint64_t | cleaner_threshold_ |
the number of allocated pages above which cleaner starts cleaning More... | |
uint64_t | urgent_threshold_ |
the number of allocated pages above which cleaner advances epoch to release pages More... | |
std::atomic< bool > | stop_requested_ |
to stop cleaner_ More... | |
memory::PagePool * | pool_ |
The SOC-local snapshot page pool in this SOC engine. More... | |
CacheHashtable * | hashtable_ |
The cache hashtable (SnapshotPageId -> offset in pool) on top of the page pool. More... | |
memory::PagePoolOffset * | reclaimed_pages_ |
This buffers pages being reclaimed. More... | |
memory::AlignedMemory | reclaimed_pages_memory_ |
The memory backing reclaimed_pages_. More... | |
uint64_t | reclaimed_pages_count_ |
Number of pages buffered so far. More... | |
|
delete |
|
explicit |
Definition at line 38 of file cache_manager_pimpl.cpp.
std::string foedus::cache::CacheManagerPimpl::describe | ( | ) | const |
Definition at line 213 of file cache_manager_pimpl.cpp.
References foedus::memory::PagePool::Stat::allocated_pages_, cleaner_threshold_, engine_, foedus::Engine::get_soc_id(), foedus::memory::PagePool::get_stat(), pool_, reclaimed_pages_count_, reclaimed_pages_memory_, foedus::memory::PagePool::Stat::total_pages_, and urgent_threshold_.
Referenced by foedus::cache::CacheManager::describe(), handle_cleaner(), and uninitialize_once().
void foedus::cache::CacheManagerPimpl::handle_cleaner | ( | ) |
Main routine of cleaner_.
Definition at line 119 of file cache_manager_pimpl.cpp.
References foedus::xct::XctManager::advance_current_global_epoch(), foedus::memory::PagePool::Stat::allocated_pages_, ASSERT_ND, cleaner_threshold_, describe(), foedus::debugging::StopWatch::elapsed_us(), engine_, foedus::xct::XctManager::get_current_global_epoch(), foedus::memory::PagePool::get_stat(), foedus::Engine::get_xct_manager(), handle_cleaner_evict_pages(), foedus::xct::XctManager::is_initialized(), foedus::assorted::memory_fence_acquire(), foedus::Epoch::one_more(), pool_, reclaimed_pages_, reclaimed_pages_count_, foedus::memory::PagePool::release(), foedus::debugging::StopWatch::stop(), stop_requested_, total_pages_, foedus::memory::PagePool::Stat::total_pages_, urgent_threshold_, and foedus::xct::XctManager::wait_for_current_global_epoch().
Referenced by initialize_once().
void foedus::cache::CacheManagerPimpl::handle_cleaner_evict_pages | ( | uint64_t | target_count | ) |
Evicts pages up to about target_count (maybe a bit more or less).
Results are written to reclaimed_pages_count_ and reclaimed_pages_.
Definition at line 190 of file cache_manager_pimpl.cpp.
References ASSERT_ND, foedus::cache::CacheHashtable::evict(), foedus::cache::CacheHashtable::EvictArgs::evicted_count_, hashtable_, reclaimed_pages_, and reclaimed_pages_count_.
Referenced by handle_cleaner().
|
overridevirtual |
Implements foedus::DefaultInitializable.
Definition at line 47 of file cache_manager_pimpl.cpp.
References foedus::memory::AlignedMemory::alloc(), ASSERT_ND, foedus::EngineOptions::cache_, cleaner_, cleaner_threshold_, engine_, ERROR_STACK, foedus::memory::AlignedMemory::get_block(), foedus::memory::EngineMemory::get_local_memory(), foedus::Engine::get_memory_manager(), foedus::Engine::get_options(), foedus::memory::NumaNodeMemory::get_snapshot_cache_table(), foedus::memory::NumaNodeMemory::get_snapshot_pool(), foedus::Engine::get_soc_id(), foedus::memory::PagePool::get_stat(), foedus::thread::ThreadOptions::get_total_thread_count(), handle_cleaner(), hashtable_, foedus::DefaultInitializable::is_initialized(), foedus::Engine::is_master(), foedus::kErrorCodeDepedentModuleUnavailableInit, foedus::memory::AlignedMemory::kNumaAllocOnnode, foedus::kRetOk, foedus::EngineOptions::memory_, pool_, foedus::memory::MemoryOptions::private_page_pool_initial_grab_, reclaimed_pages_, reclaimed_pages_count_, reclaimed_pages_memory_, foedus::cache::CacheOptions::snapshot_cache_eviction_threshold_, foedus::cache::CacheOptions::snapshot_cache_urgent_threshold_, stop_requested_, foedus::EngineOptions::thread_, total_pages_, foedus::memory::PagePool::Stat::total_pages_, and urgent_threshold_.
Referenced by foedus::cache::CacheManager::initialize_once().
ErrorStack foedus::cache::CacheManagerPimpl::stop_cleaner | ( | ) |
Definition at line 198 of file cache_manager_pimpl.cpp.
References cleaner_, foedus::kRetOk, and stop_requested_.
Referenced by foedus::cache::CacheManager::stop_cleaner(), and uninitialize_once().
|
overridevirtual |
Implements foedus::DefaultInitializable.
Definition at line 102 of file cache_manager_pimpl.cpp.
References CHECK_ERROR, describe(), engine_, hashtable_, foedus::Engine::is_master(), foedus::kRetOk, pool_, reclaimed_pages_, reclaimed_pages_count_, reclaimed_pages_memory_, foedus::memory::AlignedMemory::release_block(), and stop_cleaner().
Referenced by foedus::cache::CacheManager::uninitialize_once().
std::thread foedus::cache::CacheManagerPimpl::cleaner_ |
The only cleaner thread in this SOC engine.
In a master engine, this is not used.
Definition at line 70 of file cache_manager_pimpl.hpp.
Referenced by initialize_once(), and stop_cleaner().
uint64_t foedus::cache::CacheManagerPimpl::cleaner_threshold_ |
the number of allocated pages above which cleaner starts cleaning
Definition at line 73 of file cache_manager_pimpl.hpp.
Referenced by describe(), handle_cleaner(), and initialize_once().
Engine* const foedus::cache::CacheManagerPimpl::engine_ |
Definition at line 63 of file cache_manager_pimpl.hpp.
Referenced by describe(), handle_cleaner(), initialize_once(), and uninitialize_once().
CacheHashtable* foedus::cache::CacheManagerPimpl::hashtable_ |
The cache hashtable (SnapshotPageId -> offset in pool) on top of the page pool.
This cache manager keeps checking In a master engine, this is null.
Definition at line 93 of file cache_manager_pimpl.hpp.
Referenced by handle_cleaner_evict_pages(), initialize_once(), and uninitialize_once().
memory::PagePool* foedus::cache::CacheManagerPimpl::pool_ |
The SOC-local snapshot page pool in this SOC engine.
This passively (no thread by itself) holds used pages and free pages. In a master engine, this is null.
Definition at line 85 of file cache_manager_pimpl.hpp.
Referenced by describe(), handle_cleaner(), initialize_once(), and uninitialize_once().
memory::PagePoolOffset* foedus::cache::CacheManagerPimpl::reclaimed_pages_ |
This buffers pages being reclaimed.
We reclaim pages after a grace period, rather than immediately after collecting them from the hashtable. Because of this epoch-based grace-period, we don't have to worry about thread-safety. This is super benefitial for simplicity and scalability. Because snapshot pages are immutable, that's all we have to do. Whereas, traditional bufferpools have to take care of dirty pages and singularity of page, so they can't just do grace-period. So far, the grace period is one epoch.
Definition at line 106 of file cache_manager_pimpl.hpp.
Referenced by handle_cleaner(), handle_cleaner_evict_pages(), initialize_once(), and uninitialize_once().
uint64_t foedus::cache::CacheManagerPimpl::reclaimed_pages_count_ |
Number of pages buffered so far.
Definition at line 112 of file cache_manager_pimpl.hpp.
Referenced by describe(), handle_cleaner(), handle_cleaner_evict_pages(), initialize_once(), and uninitialize_once().
memory::AlignedMemory foedus::cache::CacheManagerPimpl::reclaimed_pages_memory_ |
The memory backing reclaimed_pages_.
Definition at line 109 of file cache_manager_pimpl.hpp.
Referenced by describe(), initialize_once(), and uninitialize_once().
std::atomic<bool> foedus::cache::CacheManagerPimpl::stop_requested_ |
to stop cleaner_
Definition at line 77 of file cache_manager_pimpl.hpp.
Referenced by handle_cleaner(), initialize_once(), and stop_cleaner().
uint64_t foedus::cache::CacheManagerPimpl::total_pages_ |
Definition at line 71 of file cache_manager_pimpl.hpp.
Referenced by handle_cleaner(), and initialize_once().
uint64_t foedus::cache::CacheManagerPimpl::urgent_threshold_ |
the number of allocated pages above which cleaner advances epoch to release pages
Definition at line 75 of file cache_manager_pimpl.hpp.
Referenced by describe(), handle_cleaner(), and initialize_once().