|
Zero
0.1.0
|
Page evictioner for the buffer pool. More...
#include <page_evictioner.hpp>
Public Member Functions | |
| PageEvictioner (const BufferPool *bufferPool) | |
| Constructs an abstract page evictioner. More... | |
| PageEvictioner (const PageEvictioner &)=delete | |
| Explicitly deleted copy constructor of an abstract page evictioner. More... | |
| PageEvictioner & | operator= (const PageEvictioner &)=delete |
| Explicitly deleted assignment operator of an abstract page evictioner. More... | |
| virtual | ~PageEvictioner () |
| Destructs an abstract page evictioner. More... | |
| virtual bf_idx | pickVictim () noexcept=0 |
| Selects a page to be evicted from the buffer pool. More... | |
| virtual void | updateOnPageHit (bf_idx idx) noexcept=0 |
| Updates the eviction statistics on page hit. More... | |
| virtual void | updateOnPageUnfix (bf_idx idx) noexcept=0 |
| Updates the eviction statistics on page unfix. More... | |
| virtual void | updateOnPageMiss (bf_idx idx, PageID pid) noexcept=0 |
| Updates the eviction statistics on page miss. More... | |
| virtual void | updateOnPageFixed (bf_idx idx) noexcept=0 |
| Updates the eviction statistics of fixed (i.e. used) pages during eviction. More... | |
| virtual void | updateOnPageDirty (bf_idx idx) noexcept=0 |
| Updates the eviction statistics of dirty pages during eviction. More... | |
| virtual void | updateOnPageBlocked (bf_idx idx) noexcept=0 |
| Updates the eviction statistics of pages that cannot be evicted at all. More... | |
| virtual void | updateOnPageSwizzled (bf_idx idx) noexcept=0 |
| Updates the eviction statistics of pages containing swizzled pointers during eviction. More... | |
| virtual void | updateOnPageExplicitlyUnbuffered (bf_idx idx) noexcept=0 |
| Updates the eviction statistics on explicit unbuffer. More... | |
| virtual void | updateOnPointerSwizzling (bf_idx idx) noexcept=0 |
| Updates the eviction statistics of pages when its pointer got swizzled in its parent page. More... | |
| virtual void | releaseInternalLatches () noexcept=0 |
| Releases the internal latches. More... | |
| bool | evictOne (bf_idx &victim) |
| Evicts a page from the buffer pool. More... | |
Public Member Functions inherited from worker_thread_t | |
| worker_thread_t (int inverval_ms=-1) | |
| virtual | ~worker_thread_t () |
| void | wakeup (bool wait=false, int rounds_to_wait=-1) |
| void | stop () |
| void | wait_for_round (long round=0) |
| long | get_rounds_completed () const |
| bool | is_busy () const |
Public Member Functions inherited from thread_wrapper_t | |
| thread_wrapper_t () | |
| virtual | ~thread_wrapper_t () |
| virtual void | before_run () |
| virtual void | after_run () |
| void | spawn () |
| void | fork () |
| void | join () |
Protected Member Functions | |
| bool | _doEviction (bf_idx victim) noexcept |
| Evicts a page from the buffer pool. More... | |
Protected Member Functions inherited from worker_thread_t | |
| bool | should_exit () const |
| void | notify_one () |
| void | notify_all () |
| void | quit () |
Protected Attributes | |
| const bool | _maintainEMLSN |
| Maintain the page's EMLSNs on eviction. More... | |
| const bool | _flushDirty |
| Flush dirty pages. More... | |
| const bool | _logEvictions |
| Log page evictions. More... | |
| const uint_fast32_t | _evictionBatchSize |
| Target value of free buffer frames. More... | |
| const uint_fast32_t | _maxAttempts |
| Maximum number of unsuccessful picks of eviction victims. More... | |
| const uint_fast32_t | _wakeupCleanerAttempts = 42 |
| Number of unsuccessful picks of eviction victims before waking up the page cleaner. More... | |
Static Protected Attributes | |
| static constexpr bool | _enabledSwizzling = POINTER_SWIZZLER::usesPointerSwizzling |
| Pointer swizzling used in the buffer pool. More... | |
Private Member Functions | |
| bool | _unswizzleAndUpdateEMLSN (bf_idx victim) noexcept |
| Unswizzles the pointer in the parent page and updates the EMLSN of that page. More... | |
| void | _flushDirtyPage (const bf_tree_cb_t &victimControlBlock) noexcept |
| Flush the specified page. More... | |
| void | do_work () override |
| Function evicting pages in the eviction thread. More... | |
Page evictioner for the buffer pool.
This is the abstract class for page eviction which implements common functionality required for all page evictioners independent of the used algorithm. All those page evictioners should inherit from this class.
|
explicit |
Constructs an abstract page evictioner.
This constructor initializes the member variables according to specifications of the BufferPool and settings from the sm_options.
| bufferPool | The buffer pool this page evictioner is responsible for. |
|
delete |
Explicitly deleted copy constructor of an abstract page evictioner.
The copy constructor of an abstract page evictioner is explicitly removed because a page evictioner depends on its corresponding buffer pool and there can only be one buffer pool per Zero instance.
|
virtual |
Destructs an abstract page evictioner.
|
protectednoexcept |
Evicts a page from the buffer pool.
Evicts the page from the specified buffer pool frame by:
victim is not used (if this is successful) and it is not latched. If _flushDirty is set and if the page was dirty, the page is flushed to the database and if _logEvictions is set, a log record of type evict_page_log is in the log.| victim | The index of the buffer frame from which the page should be evicted. |
true if the page could successfully be evicted, otherwise false .
|
privatenoexcept |
Flush the specified page.
Writes the specified page to the database file.
| victimControlBlock | The control block that corresponds to the buffer frame whose contained page gets flushed. |
|
privatenoexcept |
Unswizzles the pointer in the parent page and updates the EMLSN of that page.
In case swizzling is enabled, this unswizzles the pointer in the parent page. Additionally, this updates the parent EMLSN. This two operations are kept in a single method because both require looking up the parent, latching, etc., so we save some work.
| victim | The buffer frame index where the page that gets evicted can be found. |
true if the updates to the parent page were successfully completed and not required, false otherwise.
|
overrideprivatevirtual |
Function evicting pages in the eviction thread.
Runs in the eviction thread (executed when the eviction thread gets woken up and when terminated it terminates the eviction thread) and evicts pages as long as there are not _evictionBatchSize free buffer frames in the BufferPool.
Implements worker_thread_t.
| zero::buffer_pool::PageEvictioner::evictOne | ( | bf_idx & | victim | ) |
Evicts a page from the buffer pool.
Selects a page for eviction and executes the eviction of it.
| [out] | victim | The index of the buffer frame from which the page was evicted. |
true if the victim could successfully be evicted, otherwise false .
|
delete |
Explicitly deleted assignment operator of an abstract page evictioner.
The assignment operator of an abstract page evictioner is explicitly removed because a page evictioner depends on its corresponding buffer pool and there can only be one buffer pool per Zero instance.
|
pure virtualnoexcept |
Selects a page to be evicted from the buffer pool.
Selects a page to be evicted according to the selected page eviction strategy.
0 if no eviction victim could be found. Implemented in zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Releases the internal latches.
Some methods of page evictioners hold internal latches beyond the invocation of one method but expect another method to be called later to release those internal latches. This should be used to explicitly release those latches.
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics of pages that cannot be evicted at all.
Updates the statistics according to the selected page eviction strategy when a page cannot be evicted at all.
| idx | The buffer frame index of the BufferPool which corresponding frame contains a page that cannot be evicted at all. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics of dirty pages during eviction.
Updates the statistics according to the selected page eviction strategy when a page was discovered dirty during eviction.
| idx | The buffer frame index of the BufferPool that was picked for eviction while the corresponding frame contained a dirty page. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, and zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >.
|
pure virtualnoexcept |
Updates the eviction statistics on explicit unbuffer.
Updates the statistics according to the selected page eviction strategy when a page got explicitly unbuffered.
| idx | The buffer frame index of the BufferPool whose corresponding frame is freed explicitly. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Updates the statistics according to the selected page eviction strategy when a page was discovered fixed during eviction.
| idx | The buffer frame index of the BufferPool that was picked for eviction while the corresponding frame was fixed. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics on page hit.
Updates the statistics according to the selected page eviction strategy when a page hit occurred.
| idx | The buffer frame index of the BufferPool on which a page hit occurred. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
Updates the eviction statistics on page miss.
Updates the statistics according to the selected page eviction strategy when a page miss occurred.
| idx | The buffer frame index of the BufferPool on which a page miss occurred. |
| pid | The PageID of the generic_page that was loaded into the buffer frame with index idx . |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Updates the statistics according to the selected page eviction strategy when a page was discovered containing swizzled pointers during eviction.
| idx | The buffer frame index of the BufferPool that was picked for eviction while the corresponding frame contained a page with swizzled pointers. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics on page unfix.
Updates the statistics according to the selected page eviction strategy when a page unfix occurred.
| idx | The buffer frame index of the BufferPool on which a page unfix occurred. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
pure virtualnoexcept |
Updates the eviction statistics of pages when its pointer got swizzled in its parent page.
Updates the statistics according to the selected page eviction strategy when the pointer of a page got swizzled in its parent page.
| idx | The buffer frame index of the BufferPool whose pointer got swizzled in its corresponding parent page. |
Implemented in zero::buffer_pool::PageEvictionerCAR< on_page_unfix >, zero::buffer_pool::PageEvictionerSelectAndFilter< selector_class, filter_class, filter_early >, and zero::buffer_pool::PageEvictionerLeanStore< cooling_stage_size_ppm >.
|
staticprotected |
Pointer swizzling used in the buffer pool.
Set if the BufferPool uses pointer swizzling for page references.
|
protected |
Target value of free buffer frames.
Once page evictioning is started, it runs till there are this many free buffer frames in the BufferPool.
|
protected |
Flush dirty pages.
Set if dirty pages should be flushed when they get evicted from the buffer pool.
|
protected |
Log page evictions.
Set if a log record should be created for each eviction of a page.
|
protected |
Maintain the page's EMLSNs on eviction.
Set if the EMLSNs of the pages should be maintained.
|
protected |
Maximum number of unsuccessful picks of eviction victims.
Maximum number of picks of pages in a row that cannot be evicted before an error ("Eviction got stuck!") is thrown.
|
protected |
Number of unsuccessful picks of eviction victims before waking up the page cleaner.
Number of picks of pages in a row that cannot be evicted before the page cleaner of the BufferPool gets woken up (BufferPool::wakeupPageCleaner()).
1.8.12