Zero  0.1.0
page_evictioner.hpp
Go to the documentation of this file.
1 #ifndef __ZERO_SM_PAGE_EVICTIONER_HPP
2 #define __ZERO_SM_PAGE_EVICTIONER_HPP
3 
4 #include "sm_options.h"
5 #include "worker_thread.h"
7 
8 struct bf_tree_cb_t;
9 
10 namespace zero::buffer_pool {
11  using namespace zero::buffer_pool;
12 
25  public:
36  explicit PageEvictioner(const BufferPool* bufferPool);
37 
43  PageEvictioner(const PageEvictioner&) = delete;
44 
51  PageEvictioner& operator=(const PageEvictioner&) = delete;
52 
56  virtual ~PageEvictioner();
57 
70  virtual bf_idx pickVictim() noexcept = 0;
71 
84  virtual void updateOnPageHit(bf_idx idx) noexcept = 0;
85 
98  virtual void updateOnPageUnfix(bf_idx idx) noexcept = 0;
99 
111  virtual void updateOnPageMiss(bf_idx idx, PageID pid) noexcept = 0;
112 
124  virtual void updateOnPageFixed(bf_idx idx) noexcept = 0;
125 
137  virtual void updateOnPageDirty(bf_idx idx) noexcept = 0;
138 
150  virtual void updateOnPageBlocked(bf_idx idx) noexcept = 0;
151 
163  virtual void updateOnPageSwizzled(bf_idx idx) noexcept = 0;
164 
176  virtual void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept = 0;
177 
189  virtual void updateOnPointerSwizzling(bf_idx idx) noexcept = 0;
190 
197  virtual void releaseInternalLatches() noexcept = 0;
198 
206  bool evictOne(bf_idx& victim);
207 
208  protected:
213  static constexpr bool _enabledSwizzling = POINTER_SWIZZLER::usesPointerSwizzling;
214 
219  const bool _maintainEMLSN;
220 
225  const bool _flushDirty;
226 
231  const bool _logEvictions;
232 
238  const uint_fast32_t _evictionBatchSize;
239 
245  const uint_fast32_t _maxAttempts;
246 
254  const uint_fast32_t _wakeupCleanerAttempts = 42;
255 
256  protected:
277  bool _doEviction(bf_idx victim) noexcept;
278 
279  private:
290  bool _unswizzleAndUpdateEMLSN(bf_idx victim) noexcept;
291 
302  void _flushDirtyPage(const bf_tree_cb_t& victimControlBlock) noexcept;
303 
310  void do_work() override;
311  };
312 } // zero::buffer_pool
313 
314 #endif // __ZERO_SM_PAGE_EVICTIONER_HPP
virtual void updateOnPageHit(bf_idx idx) noexcept=0
Updates the eviction statistics on page hit.
const bool _maintainEMLSN
Maintain the page's EMLSNs on eviction.
Definition: page_evictioner.hpp:219
Definition: worker_thread.h:12
virtual ~PageEvictioner()
Destructs an abstract page evictioner.
Definition: page_evictioner.cpp:22
Control block in the new buffer pool class.
Definition: bf_tree_cb.h:53
virtual void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept=0
Updates the eviction statistics on explicit unbuffer.
virtual void updateOnPageMiss(bf_idx idx, PageID pid) noexcept=0
Updates the eviction statistics on page miss.
PageEvictioner(const BufferPool *bufferPool)
Constructs an abstract page evictioner.
Definition: page_evictioner.cpp:12
Definition: buffer_pool.hpp:34
virtual bf_idx pickVictim() noexcept=0
Selects a page to be evicted from the buffer pool.
virtual void updateOnPageSwizzled(bf_idx idx) noexcept=0
Updates the eviction statistics of pages containing swizzled pointers during eviction.
const uint_fast32_t _evictionBatchSize
Target value of free buffer frames.
Definition: page_evictioner.hpp:238
uint32_t bf_idx
Definition: basics.h:56
bool evictOne(bf_idx &victim)
Evicts a page from the buffer pool.
Definition: page_evictioner.cpp:24
void _flushDirtyPage(const bf_tree_cb_t &victimControlBlock) noexcept
Flush the specified page.
Definition: page_evictioner.cpp:256
Page evictioner for the buffer pool.
Definition: page_evictioner.hpp:24
virtual void updateOnPageUnfix(bf_idx idx) noexcept=0
Updates the eviction statistics on page unfix.
uint32_t PageID
Definition: basics.h:45
const uint_fast32_t _maxAttempts
Maximum number of unsuccessful picks of eviction victims.
Definition: page_evictioner.hpp:245
bool _doEviction(bf_idx victim) noexcept
Evicts a page from the buffer pool.
Definition: page_evictioner.cpp:55
const bool _flushDirty
Flush dirty pages.
Definition: page_evictioner.hpp:225
void do_work() override
Function evicting pages in the eviction thread.
Definition: page_evictioner.cpp:272
virtual void updateOnPageFixed(bf_idx idx) noexcept=0
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
PageEvictioner & operator=(const PageEvictioner &)=delete
Explicitly deleted assignment operator of an abstract page evictioner.
A buffer manager that exploits the tree structure of indexes.
Definition: buffer_pool.hpp:40
const uint_fast32_t _wakeupCleanerAttempts
Number of unsuccessful picks of eviction victims before waking up the page cleaner.
Definition: page_evictioner.hpp:254
bool _unswizzleAndUpdateEMLSN(bf_idx victim) noexcept
Unswizzles the pointer in the parent page and updates the EMLSN of that page.
Definition: page_evictioner.cpp:153
virtual void releaseInternalLatches() noexcept=0
Releases the internal latches.
virtual void updateOnPageDirty(bf_idx idx) noexcept=0
Updates the eviction statistics of dirty pages during eviction.
virtual void updateOnPageBlocked(bf_idx idx) noexcept=0
Updates the eviction statistics of pages that cannot be evicted at all.
static constexpr bool _enabledSwizzling
Pointer swizzling used in the buffer pool.
Definition: page_evictioner.hpp:213
virtual void updateOnPointerSwizzling(bf_idx idx) noexcept=0
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
const bool _logEvictions
Log page evictions.
Definition: page_evictioner.hpp:231