1 #ifndef __PAGE_EVICTIONER_FILTER_HPP 2 #define __PAGE_EVICTIONER_FILTER_HPP 335 template<
bool on_hit ,
bool on_unfix ,
bool on_miss ,
bool on_fixed ,
bool on_dirty ,
bool on_blocked ,
bool on_swizzled >
345 _refBits(bufferPool->getBlockCount()) {};
377 _refBits[idx] =
false;
392 if constexpr (on_hit) {
393 _refBits[idx] =
true;
405 if constexpr (on_unfix) {
406 _refBits[idx] =
true;
420 if constexpr (on_miss) {
421 _refBits[b_idx] =
true;
434 if constexpr (on_fixed) {
435 _refBits[idx] =
true;
448 if constexpr (on_dirty) {
449 _refBits[idx] =
true;
462 if constexpr (on_blocked) {
463 _refBits[idx] =
true;
476 if constexpr (on_swizzled) {
477 _refBits[idx] =
true;
492 _refBits[idx] =
true;
647 template<uint16_t decrement,
bool discriminate_pages,
648 bool on_hit,
bool set_on_hit, uint16_t level0_on_hit, uint16_t level1_on_hit, uint16_t level2_on_hit,
649 bool on_unfix,
bool set_on_unfix, uint16_t level0_on_unfix, uint16_t level1_on_unfix, uint16_t level2_on_unfix,
650 bool on_miss,
bool set_on_miss, uint16_t level0_on_miss, uint16_t level1_on_miss, uint16_t level2_on_miss,
651 bool on_fixed,
bool set_on_fixed, uint16_t level0_on_fixed, uint16_t level1_on_fixed, uint16_t level2_on_fixed,
652 bool on_dirty,
bool set_on_dirty, uint16_t level0_on_dirty, uint16_t level1_on_dirty, uint16_t level2_on_dirty,
653 bool on_blocked,
bool set_on_blocked, uint16_t level0_on_blocked, uint16_t level1_on_blocked, uint16_t level2_on_blocked,
654 bool on_swizzled,
bool set_on_swizzled, uint16_t level0_on_swizzled, uint16_t level1_on_swizzled, uint16_t level2_on_swizzled>
664 _refInts(bufferPool->getBlockCount()) {};
679 if (_refInts[idx] > 0) {
696 if (_refInts[idx] > 0) {
697 _refInts[idx] =
std::max(_refInts[idx] - decrement, 0);
717 if constexpr (on_hit) {
718 if constexpr (discriminate_pages) {
719 uint8_t page_level = getLevel(idx);
720 if constexpr (set_on_hit) {
721 if (page_level == 0) {
722 _refInts[idx] = level0_on_hit;
723 }
else if (page_level == 1) {
724 _refInts[idx] = level1_on_hit;
726 _refInts[idx] = level2_on_hit;
729 if (page_level == 0) {
730 _refInts[idx] += level0_on_hit;
731 }
else if (page_level == 1) {
732 _refInts[idx] += level1_on_hit;
734 _refInts[idx] += level2_on_hit;
738 if constexpr (set_on_hit) {
739 _refInts[idx] = level2_on_hit;
741 _refInts[idx] += level2_on_hit;
760 if constexpr (on_unfix) {
761 if constexpr (discriminate_pages) {
762 uint8_t page_level = getLevel(idx);
763 if constexpr (set_on_unfix) {
764 if (page_level == 0) {
765 _refInts[idx] = level0_on_unfix;
766 }
else if (page_level == 1) {
767 _refInts[idx] = level1_on_unfix;
769 _refInts[idx] = level2_on_unfix;
772 if (page_level == 0) {
773 _refInts[idx] += level0_on_unfix;
774 }
else if (page_level == 1) {
775 _refInts[idx] += level1_on_unfix;
777 _refInts[idx] += level2_on_unfix;
781 if constexpr (set_on_unfix) {
782 _refInts[idx] = level2_on_unfix;
784 _refInts[idx] += level2_on_unfix;
805 if constexpr (on_miss) {
806 if constexpr (discriminate_pages) {
807 uint8_t page_level = getLevel(b_idx);
808 if constexpr (set_on_miss) {
809 if (page_level == 0) {
810 _refInts[b_idx] = level0_on_miss;
811 }
else if (page_level == 1) {
812 _refInts[b_idx] = level1_on_miss;
814 _refInts[b_idx] = level2_on_miss;
817 if (page_level == 0) {
818 _refInts[b_idx] += level0_on_miss;
819 }
else if (page_level == 1) {
820 _refInts[b_idx] += level1_on_miss;
822 _refInts[b_idx] += level2_on_miss;
826 if constexpr (set_on_miss) {
827 _refInts[b_idx] = level2_on_miss;
829 _refInts[b_idx] += level2_on_miss;
849 if constexpr (on_fixed) {
850 if constexpr (discriminate_pages) {
851 uint8_t page_level = getLevel(idx);
852 if constexpr (set_on_fixed) {
853 if (page_level == 0) {
854 _refInts[idx] = level0_on_fixed;
855 }
else if (page_level == 1) {
856 _refInts[idx] = level1_on_fixed;
858 _refInts[idx] = level2_on_fixed;
861 if (page_level == 0) {
862 _refInts[idx] += level0_on_fixed;
863 }
else if (page_level == 1) {
864 _refInts[idx] += level1_on_fixed;
866 _refInts[idx] += level2_on_fixed;
870 if constexpr (set_on_fixed) {
871 _refInts[idx] = level2_on_fixed;
873 _refInts[idx] += level2_on_fixed;
893 if constexpr (on_dirty) {
894 if constexpr (discriminate_pages) {
895 uint8_t page_level = getLevel(idx);
896 if constexpr (set_on_dirty) {
897 if (page_level == 0) {
898 _refInts[idx] = level0_on_dirty;
899 }
else if (page_level == 1) {
900 _refInts[idx] = level1_on_dirty;
902 _refInts[idx] = level2_on_dirty;
905 if (page_level == 0) {
906 _refInts[idx] += level0_on_dirty;
907 }
else if (page_level == 1) {
908 _refInts[idx] += level1_on_dirty;
910 _refInts[idx] += level2_on_dirty;
914 if constexpr (set_on_dirty) {
915 _refInts[idx] = level2_on_dirty;
917 _refInts[idx] += level2_on_dirty;
937 if constexpr (on_blocked) {
938 if constexpr (discriminate_pages) {
939 uint8_t page_level = getLevel(idx);
940 if constexpr (set_on_blocked) {
941 if (page_level == 0) {
942 _refInts[idx] = level0_on_blocked;
943 }
else if (page_level == 1) {
944 _refInts[idx] = level1_on_blocked;
946 _refInts[idx] = level2_on_blocked;
949 if (page_level == 0) {
950 _refInts[idx] += level0_on_blocked;
951 }
else if (page_level == 1) {
952 _refInts[idx] += level1_on_blocked;
954 _refInts[idx] += level2_on_blocked;
958 if constexpr (set_on_blocked) {
959 _refInts[idx] = level2_on_blocked;
961 _refInts[idx] += level2_on_blocked;
981 if constexpr (on_swizzled) {
982 if constexpr (discriminate_pages) {
983 uint8_t page_level = getLevel(idx);
984 if constexpr (set_on_swizzled) {
985 if (page_level == 0) {
986 _refInts[idx] = level0_on_swizzled;
987 }
else if (page_level == 1) {
988 _refInts[idx] = level1_on_swizzled;
990 _refInts[idx] = level2_on_swizzled;
993 if (page_level == 0) {
994 _refInts[idx] += level0_on_swizzled;
995 }
else if (page_level == 1) {
996 _refInts[idx] += level1_on_swizzled;
998 _refInts[idx] += level2_on_swizzled;
1002 if constexpr (set_on_swizzled) {
1003 _refInts[idx] = level2_on_swizzled;
1005 _refInts[idx] += level2_on_swizzled;
1059 const generic_page* page = smlevel_0::bf->getPage(idx);
1066 }
else if (fixedPage.
level() == 2) {
1068 }
else if (fixedPage.
level() == 1) {
1084 #endif // __PAGE_EVICTIONER_FILTER_HPP virtual void releaseInternalLatches() noexcept=0
Releases the internal latches of the buffer frame filter.
PageID btree_root() const
Definition: btree_page_h.h:239
bool filter(bf_idx idx) const noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:678
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_filter.hpp:936
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_filter.hpp:1021
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_filter.hpp:433
#define w_assert1(x)
Level 1 should not add significant extra time.
Definition: w_base.h:198
bool filterAndUpdate(bf_idx idx) noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:228
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_filter.hpp:391
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_filter.hpp:246
Definition: buffer_pool.hpp:34
bool filterAndUpdate(bf_idx idx) noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:695
Page handle for B-Tree data page.
Definition: btree_page_h.h:185
virtual void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept=0
Updates the eviction statistics on explicit unbuffer.
uint8_t getLevel(const bf_idx &idx) const
B-tree depth of the contained page.
Definition: page_evictioner_filter.hpp:1058
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_filter.hpp:265
virtual void updateOnPageSwizzled(bf_idx idx) noexcept=0
Updates the eviction statistics of pages containing swizzled pointers during eviction.
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_filter.hpp:461
A generic page view: any Zero page can be viewed as being of this type but it only exposes fields sha...
Definition: generic_page.h:121
virtual void updateOnPageDirty(bf_idx idx) noexcept=0
Updates the eviction statistics of dirty pages during eviction.
bool filterAndUpdate(bf_idx idx) noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:375
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_filter.hpp:716
virtual bool filter(bf_idx idx) const noexcept=0
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:31
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_filter.hpp:980
uint32_t bf_idx
Definition: basics.h:56
PageEvictionerFilter(const BufferPool *bufferPool)
Constructs a buffer frame filter.
Definition: page_evictioner_filter.hpp:25
PageEvictionerFilterGCLOCK(const BufferPool *bufferPool)
Constructs a GCLOCK buffer frame filter.
Definition: page_evictioner_filter.hpp:662
int level() const
Returns 1 if leaf, >1 if non-leaf.
Definition: btree_page_h.h:1181
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_filter.hpp:238
uint32_t PageID
Definition: basics.h:45
std::vector< std::atomic< bool > > _refBits
Referenced bits for the buffer frames.
Definition: page_evictioner_filter.hpp:516
virtual void updateOnPageUnfix(bf_idx idx) noexcept=0
Updates the eviction statistics on page unfix.
const T max(const T x, const T y)
Definition: w_minmax.h:45
PageEvictionerFilterNone(const BufferPool *bufferPool)
Constructs a non-filtering buffer frame filter.
Definition: page_evictioner_filter.hpp:207
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_filter.hpp:848
virtual void updateOnPointerSwizzling(bf_idx idx) noexcept=0
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
btree page
Definition: generic_page.h:90
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame filter.
Definition: page_evictioner_filter.hpp:509
void updateOnPointerSwizzling(bf_idx idx) noexcept final
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
Definition: page_evictioner_filter.hpp:503
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_filter.hpp:759
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_filter.hpp:283
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_filter.hpp:256
PageID pid() const
Definition: generic_page.h:146
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame filter.
Definition: page_evictioner_filter.hpp:316
virtual void updateOnPageFixed(bf_idx idx) noexcept=0
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
bool filter(bf_idx idx) const noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:358
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_filter.hpp:491
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_filter.hpp:475
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_filter.hpp:447
A buffer manager that exploits the tree structure of indexes.
Definition: buffer_pool.hpp:40
virtual void updateOnPageHit(bf_idx idx) noexcept=0
Updates the eviction statistics on page hit.
PageEvictionerFilterCLOCK(const BufferPool *bufferPool)
Constructs a CLOCK buffer frame filter.
Definition: page_evictioner_filter.hpp:343
GCLOCK buffer frame filter
Definition: page_evictioner_filter.hpp:655
void fix_nonbufferpool_page(generic_page *s)
Definition: fixable_page_h.cpp:117
void updateOnPageMiss(bf_idx b_idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_filter.hpp:419
bool filter(bf_idx idx) const noexcept final
Filters a buffer frame for eviction.
Definition: page_evictioner_filter.hpp:217
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame filter.
Definition: page_evictioner_filter.hpp:1039
std::vector< std::atomic< uint16_t > > _refInts
Referenced integers for the buffer frames.
Definition: page_evictioner_filter.hpp:1080
void updateOnPointerSwizzling(bf_idx idx) noexcept final
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
Definition: page_evictioner_filter.hpp:1033
virtual bool filterAndUpdate(bf_idx idx) noexcept=0
Filters a buffer frame for eviction.
Buffer frame filter for the Select-and-Filter page evictioner.
Definition: page_evictioner_filter.hpp:18
void updateOnPointerSwizzling(bf_idx idx) noexcept final
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
Definition: page_evictioner_filter.hpp:310
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_filter.hpp:404
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_filter.hpp:292
virtual void updateOnPageBlocked(bf_idx idx) noexcept=0
Updates the eviction statistics of pages that cannot be evicted at all.
virtual ~PageEvictionerFilter()
Destructs a buffer frame filter.
Definition: page_evictioner_filter.hpp:31
CLOCK buffer frame filter
Definition: page_evictioner_filter.hpp:336
virtual void updateOnPageMiss(bf_idx idx, PageID pid) noexcept=0
Updates the eviction statistics on page miss.
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_filter.hpp:892
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_filter.hpp:274
None-filtering buffer frame filter.
Definition: page_evictioner_filter.hpp:200
void updateOnPageMiss(bf_idx b_idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_filter.hpp:804
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_filter.hpp:301