Zero  0.1.0
page_evictioner_selector.hpp
Go to the documentation of this file.
1 #ifndef __PAGE_EVICTIONER_SELECTOR_HPP
2 #define __PAGE_EVICTIONER_SELECTOR_HPP
3 
4 #include <mutex>
5 
6 #include <atomic>
7 
8 #include "cds/container/fcqueue.h"
9 #include "cds/container/fcstack.h"
10 #include "MPMCQueue/MPMCQueue.h"
11 #include <vector>
12 
13 #include "hashtable_deque.hpp"
14 
15 #include "buffer_pool.hpp"
16 
17 namespace zero::buffer_pool {
18 
26  protected:
32  explicit PageEvictionerSelector(const BufferPool* bufferPool) :
33  _maxBufferpoolIndex(bufferPool->getBlockCount() - 1) {};
34 
35  public:
40 
51  virtual bf_idx select() noexcept = 0;
52 
65  virtual void updateOnPageHit(bf_idx idx) noexcept = 0;
66 
79  virtual void updateOnPageUnfix(bf_idx idx) noexcept = 0;
80 
92  virtual void updateOnPageMiss(bf_idx idx, PageID pid) noexcept = 0;
93 
104  virtual void updateOnPageFixed(bf_idx idx) noexcept = 0;
105 
116  virtual void updateOnPageDirty(bf_idx idx) noexcept = 0;
117 
128  virtual void updateOnPageBlocked(bf_idx idx) noexcept = 0;
129 
140  virtual void updateOnPageSwizzled(bf_idx idx) noexcept = 0;
141 
152  virtual void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept = 0;
153 
164  virtual void updateOnPointerSwizzling(bf_idx idx) noexcept = 0;
165 
174  virtual void releaseInternalLatches() noexcept = 0;
175 
176  protected:
181  };
182 
204  template<uint32_t retry_list_check_ppm/* = 1000000*/, uint32_t initial_list_check_ppm/* = 10000*/>
206  public:
213  PageEvictionerSelector(bufferPool),
214  _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
215 
227  inline bf_idx select() noexcept final {
228  static thread_local bool currentlyCheckingRetryList;
229  static thread_local size_t retriedBufferIndexes;
230 
231  bf_idx selected;
232  while (true) {
233  if (!currentlyCheckingRetryList) { // This thread checked the front of the _initialList last:
234  if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _initialList.size())
235  || _retryList.empty()) { // Check again the front of the _initialList:
236  _initialList.pop(selected);
237  retriedBufferIndexes++;
238  if (_notExplicitlyEvictedList[selected].test_and_set()) {
239  return selected;
240  } else {
241  continue; // This buffer frame was explicitly evicted
242  }
243  } else { // Change to checking entries from the front of the _retryList
244  _retryList.pop(selected);
245  if (_notExplicitlyEvictedList[selected].test_and_set()) {
246  retriedBufferIndexes = 0;
247  currentlyCheckingRetryList = true;
248  return selected;
249  } else {
250  continue; // This buffer frame was explicitly evicted
251  }
252  }
253  } else { // This thread checked the front of the _retryList last:
254  if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _retryList.size())
255  || _initialList.empty()) { // Check again the front of the _retryList:
256  _retryList.pop(selected);
257  retriedBufferIndexes++;
258  if (_notExplicitlyEvictedList[selected].test_and_set()) {
259  return selected;
260  } else {
261  continue; // This buffer frame was explicitly evicted
262  }
263  } else { // Change to checking entries from the front of the _initialList
264  _initialList.pop(selected);
265  if (_notExplicitlyEvictedList[selected].test_and_set()) {
266  retriedBufferIndexes = 0;
267  currentlyCheckingRetryList = false;
268  return selected;
269  } else {
270  continue; // This buffer frame was explicitly evicted
271  }
272  }
273  }
274  }
275  };
276 
284  inline void updateOnPageHit(bf_idx idx) noexcept final {};
285 
293  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
294 
304  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
305  _notExplicitlyEvictedList[idx].test_and_set();
306  _initialList.push(idx);
307  };
308 
316  inline void updateOnPageFixed(bf_idx idx) noexcept final {
317  _retryList.push(idx);
318  };
319 
327  inline void updateOnPageDirty(bf_idx idx) noexcept final {
328  _retryList.push(idx);
329  };
330 
338  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
339  _retryList.push(idx);
340  };
341 
349  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
350  _retryList.push(idx);
351  };
352 
363  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
364  _notExplicitlyEvictedList[idx].clear();
365  };
366 
375  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
376 
381  inline void releaseInternalLatches() noexcept final {};
382 
383  private:
393  cds::container::FCQueue<bf_idx> _initialList;
394 
404  cds::container::FCQueue<bf_idx> _retryList;
405 
411  std::vector<std::atomic_flag> _notExplicitlyEvictedList;
412 
417  static constexpr double _retryListCheck = retry_list_check_ppm * 0.000001;
418 
423  static constexpr double _initialListCheck = initial_list_check_ppm * 0.000001;
424  };
425 
447  template<uint32_t retry_list_check_ppm/* = 1000000*/, uint32_t initial_list_check_ppm/* = 10000*/>
449  public:
456  PageEvictionerSelector(bufferPool),
457  _approximateInitialListLength(0),
458  _approximateRetryListLength(0),
459  _initialList(bufferPool->getBlockCount()),
460  _retryList(bufferPool->getBlockCount()),
461  _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
462 
474  inline bf_idx select() noexcept final {
475  static thread_local bool currentlyCheckingRetryList;
476  static thread_local size_t retriedBufferIndexes;
477 
478  bf_idx selected;
479  while (true) {
480  if (!currentlyCheckingRetryList) { // This thread checked the front of the _initialList last:
481  if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _approximateInitialListLength)
482  || _approximateRetryListLength == 0) {
483  if (_initialList.try_pop(selected)) { // Check again the front of the _initialList
484  _approximateInitialListLength--;
485  retriedBufferIndexes++;
486  if (_notExplicitlyEvictedList[selected].test_and_set()) {
487  return selected;
488  } else {
489  continue; // This buffer frame was explicitly evicted
490  }
491  } else {
492  currentlyCheckingRetryList = true;
493  continue;
494  }
495  } else { // Change to checking entries from the front of the _retryList
496  if (_retryList.try_pop(selected)) {
497  _approximateRetryListLength--;
498  retriedBufferIndexes = 0;
499  if (_notExplicitlyEvictedList[selected].test_and_set()) {
500  return selected;
501  } else {
502  continue; // This buffer frame was explicitly evicted
503  }
504  } else {
505  currentlyCheckingRetryList = false;
506  continue;
507  }
508  }
509  } else { // This thread checked the front of the _retryList last:
510  if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _approximateRetryListLength)
511  || _approximateInitialListLength == 0) {
512  if (_retryList.try_pop(selected)) { // Check again the front of the _retryList
513  _approximateRetryListLength--;
514  retriedBufferIndexes++;
515  if (_notExplicitlyEvictedList[selected].test_and_set()) {
516  return selected;
517  } else {
518  continue; // This buffer frame was explicitly evicted
519  }
520  } else {
521  currentlyCheckingRetryList = false;
522  continue;
523  }
524  } else { // Change to checking entries from the front of the _initialList
525  if (_initialList.try_pop(selected)) {
526  _approximateInitialListLength--;
527  retriedBufferIndexes = 0;
528  if (_notExplicitlyEvictedList[selected].test_and_set()) {
529  return selected;
530  } else {
531  continue; // This buffer frame was explicitly evicted
532  }
533  } else {
534  currentlyCheckingRetryList = true;
535  continue;
536  }
537  }
538  }
539  }
540  };
541 
549  inline void updateOnPageHit(bf_idx idx) noexcept final {};
550 
558  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
559 
569  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
570  _notExplicitlyEvictedList[idx].test_and_set();
571  _initialList.push(idx);
572  _approximateInitialListLength++;
573  };
574 
582  inline void updateOnPageFixed(bf_idx idx) noexcept final {
583  _retryList.push(idx);
584  _approximateRetryListLength++;
585  };
586 
594  inline void updateOnPageDirty(bf_idx idx) noexcept final {
595  _retryList.push(idx);
596  _approximateRetryListLength++;
597  };
598 
606  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
607  _retryList.push(idx);
608  _approximateRetryListLength++;
609  };
610 
618  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
619  _retryList.push(idx);
620  _approximateRetryListLength++;
621  };
622 
633  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
634  _notExplicitlyEvictedList[idx].clear();
635  };
636 
645  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
646 
651  inline void releaseInternalLatches() noexcept final {};
652 
653  private:
663  rigtorp::MPMCQueue<bf_idx> _initialList;
664 
669 
679  rigtorp::MPMCQueue<bf_idx> _retryList;
680 
685 
691  std::vector<std::atomic_flag> _notExplicitlyEvictedList;
692 
697  static constexpr double _retryListCheck = retry_list_check_ppm * 0.000001;
698 
703  static constexpr double _initialListCheck = initial_list_check_ppm * 0.000001;
704  };
705 
726  template<uint32_t retry_list_check_ppm/* = 1000000*/, uint32_t initial_list_check_ppm/* = 10000*/>
728  public:
735  PageEvictionerSelector(bufferPool),
736  _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
737 
749  inline bf_idx select() noexcept final {
750  static thread_local bool currentlyCheckingRetryList;
751  static thread_local size_t retriedBufferIndexes;
752 
753  bf_idx selected;
754  while (true) {
755  if (!currentlyCheckingRetryList) { // This thread checked the front of the _retryList last:
756  if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _initialList.size())
757  || _retryList.empty()) { // Check again the front of the _initialList:
758  _initialList.pop(selected);
759  retriedBufferIndexes++;
760  if (_notExplicitlyEvictedList[selected].test_and_set()) {
761  return selected;
762  } else {
763  continue; // This buffer frame was explicitly evicted
764  }
765  } else { // Change to checking entries from the front of the _retryList
766  _retryList.pop(selected);
767  if (_notExplicitlyEvictedList[selected].test_and_set()) {
768  retriedBufferIndexes = 0;
769  currentlyCheckingRetryList = true;
770  return selected;
771  } else {
772  continue; // This buffer frame was explicitly evicted
773 
774  }
775  }
776  } else { // This thread checked the front of the _initialList last:
777  if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _retryList.size())
778  || _initialList.empty()) { // Check again the front of the _retryList:
779  _retryList.pop(selected);
780  retriedBufferIndexes++;
781  if (_notExplicitlyEvictedList[selected].test_and_set()) {
782  return selected;
783  } else {
784  continue; // This buffer frame was explicitly evicted
785  }
786  } else { // Change to checking entries from the front of the _initialList
787  _initialList.pop(selected);
788  if (_notExplicitlyEvictedList[selected].test_and_set()) {
789  retriedBufferIndexes = 0;
790  currentlyCheckingRetryList = false;
791  return selected;
792  } else {
793  continue; // This buffer frame was explicitly evicted
794  }
795  }
796  }
797  }
798  };
799 
807  inline void updateOnPageHit(bf_idx idx) noexcept final {};
808 
816  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
817 
827  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
828  _notExplicitlyEvictedList[idx].test_and_set();
829  _initialList.push(idx);
830  };
831 
839  inline void updateOnPageFixed(bf_idx idx) noexcept final {
840  _retryList.push(idx);
841  };
842 
850  inline void updateOnPageDirty(bf_idx idx) noexcept final {
851  _retryList.push(idx);
852  };
853 
861  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
862  _retryList.push(idx);
863  };
864 
872  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
873  _retryList.push(idx);
874  };
875 
886  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
887  _notExplicitlyEvictedList[idx].clear();
888  };
889 
898  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
899 
904  inline void releaseInternalLatches() noexcept final {};
905 
906  private:
916  cds::container::FCStack<bf_idx> _initialList;
917 
927  cds::container::FCQueue<bf_idx> _retryList;
928 
934  std::vector<std::atomic_flag> _notExplicitlyEvictedList;
935 
940  static constexpr double _retryListCheck = retry_list_check_ppm * 0.000001;
941 
946  static constexpr double _initialListCheck = initial_list_check_ppm * 0.000001;
947  };
948 
960  public:
966  explicit PageEvictionerSelectorLRU(const BufferPool* bufferPool) :
967  PageEvictionerSelector(bufferPool),
968  _lruList(bufferPool->getBlockCount()) {};
969 
979  inline bf_idx select() noexcept final {
980  bf_idx selected;
981  _lruListLock.lock();
982  _lruList.popFromFront(selected);
983  return selected;
984  };
985 
992  inline void updateOnPageHit(bf_idx idx) noexcept final {
993  std::lock_guard<std::recursive_mutex> lock(_lruListLock);
994  _lruList.remove(idx);
995  _lruList.pushToBack(idx);
996  };
997 
1004  inline void updateOnPageUnfix(bf_idx idx) noexcept final {
1005  std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1006  _lruList.remove(idx);
1007  _lruList.pushToBack(idx);
1008  };
1009 
1024  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
1025  _lruListLock.lock();
1026  _lruList.pushToBack(idx);
1027  _lruListLock.unlock();
1028  _lruListLock.unlock();
1029  };
1030 
1044  inline void updateOnPageFixed(bf_idx idx) noexcept final {
1045  _lruList.pushToBack(idx);
1046  _lruListLock.unlock();
1047  };
1048 
1062  inline void updateOnPageDirty(bf_idx idx) noexcept final {
1063  _lruList.pushToBack(idx);
1064  _lruListLock.unlock();
1065  };
1066 
1080  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
1081  _lruList.pushToBack(idx);
1082  _lruListLock.unlock();
1083  };
1084 
1098  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
1099  _lruList.pushToBack(idx);
1100  _lruListLock.unlock();
1101  };
1102 
1116  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
1117  _lruListLock.lock();
1118  try {
1119  _lruList.remove(idx);
1121  _lruListLock.unlock();
1122  _lruListLock.unlock();
1123  };
1124 
1133  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
1134 
1149  inline void releaseInternalLatches() noexcept final {
1150  _lruListLock.unlock();
1151  };
1152 
1153  private:
1158 
1162  std::recursive_mutex _lruListLock;
1163  };
1164 
1177  template<bf_idx protected_block_ppm/* = 10000*/>
1179  public:
1185  explicit PageEvictionerSelectorSLRU(const BufferPool* bufferPool) :
1186  PageEvictionerSelector(bufferPool),
1187  _protectedBlockCount(static_cast<bf_idx>(protected_block_ppm * 0.000001 * bufferPool->getBlockCount())),
1188  _protectedLRUList(_protectedBlockCount),
1189  _probationaryLRUList(bufferPool->getBlockCount()) {};
1190 
1200  inline bf_idx select() noexcept final {
1201  bf_idx selected;
1202  _lruListLock.lock();
1203  _probationaryLRUList.popFromFront(selected);
1204  return selected;
1205  };
1206 
1215  inline void updateOnPageHit(bf_idx idx) noexcept final {
1216  std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1217  try {
1218  _protectedLRUList.remove(idx);
1220  _probationaryLRUList.remove(idx);
1221  }
1222  if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1223  bf_idx downgradeIndex;
1224  _protectedLRUList.popFromFront(downgradeIndex);
1225  _probationaryLRUList.pushToBack(downgradeIndex);
1226  }
1227  _protectedLRUList.pushToBack(idx);
1228  };
1229 
1237  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
1238 
1253  void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
1254  _lruListLock.lock();
1255  _probationaryLRUList.pushToBack(idx);
1256  _lruListLock.unlock();
1257  _lruListLock.unlock();
1258  };
1259 
1275  inline void updateOnPageFixed(bf_idx idx) noexcept final {
1276  if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1277  bf_idx downgradeIndex;
1278  _protectedLRUList.popFromFront(downgradeIndex);
1279  _probationaryLRUList.pushToBack(downgradeIndex);
1280  }
1281  _protectedLRUList.pushToBack(idx);
1282  _lruListLock.unlock();
1283  };
1284 
1300  inline void updateOnPageDirty(bf_idx idx) noexcept final {
1301  if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1302  bf_idx downgradeIndex;
1303  _protectedLRUList.popFromFront(downgradeIndex);
1304  _probationaryLRUList.pushToBack(downgradeIndex);
1305  }
1306  _protectedLRUList.pushToBack(idx);
1307  _lruListLock.unlock();
1308  };
1309 
1325  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
1326  if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1327  bf_idx downgradeIndex;
1328  _protectedLRUList.popFromFront(downgradeIndex);
1329  _probationaryLRUList.pushToBack(downgradeIndex);
1330  }
1331  _protectedLRUList.pushToBack(idx);
1332  _lruListLock.unlock();
1333  };
1334 
1350  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
1351  if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1352  bf_idx downgradeIndex;
1353  _protectedLRUList.popFromFront(downgradeIndex);
1354  _probationaryLRUList.pushToBack(downgradeIndex);
1355  }
1356  _protectedLRUList.pushToBack(idx);
1357  _lruListLock.unlock();
1358  };
1359 
1373  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
1374  std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1375  try {
1376  _protectedLRUList.remove(idx);
1378  try {
1379  _probationaryLRUList.remove(idx);
1381  }
1382  _lruListLock.unlock();
1383  _lruListLock.unlock();
1384  };
1385 
1394  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
1395 
1410  inline void releaseInternalLatches() noexcept final {
1411  _lruListLock.unlock();
1412  };
1413 
1414  private:
1419 
1424 
1429 
1433  std::recursive_mutex _lruListLock;
1434  };
1435 
1449  template<size_t k/* = 2*/, bool on_page_unfix/* = false*/>
1451  public:
1457  explicit PageEvictionerSelectorLRUK(const BufferPool* bufferPool) :
1458  PageEvictionerSelector(bufferPool),
1459  _lruList(k * bufferPool->getBlockCount()),
1460  _frameReferences(bufferPool->getBlockCount(), 0),
1461  _leastRecentlyUsedFinite(0) {};
1462 
1470  inline bf_idx select() noexcept final {
1471  uint64_t selected; // Does not remove more tracked references because the page might be not
1472  _lruListLock.lock(); // evictable right now.
1473  selected = _popFromFront();
1474  return static_cast<bf_idx>(selected / k);
1475  };
1476 
1484  inline void updateOnPageHit(bf_idx idx) noexcept final {
1485  if constexpr (!on_page_unfix) {
1486  _lruListLock.lock();
1487  _remove(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx));
1488  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1489  _lruListLock.unlock();
1490  }
1491  };
1492 
1500  inline void updateOnPageUnfix(bf_idx idx) noexcept final {
1501  if constexpr (on_page_unfix) {
1502  _lruListLock.lock();
1503  _remove(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx));
1504  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1505  _lruListLock.unlock();
1506  }
1507  };
1508 
1525  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
1526  _lruListLock.lock();
1527  _frameReferences[idx] = 0;
1528  for (size_t i = 0; i < k; i++) { // select() does not remove all the tracked references therefore, this is
1529  try { // done here to prevent influence of the old reference history on the new page.
1530  _remove(static_cast<uint64_t>((i % k) + k * idx));
1532  }
1533  if (k >= 2) {
1534  try {
1535  _lruList.insertBefore(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx),
1536  _leastRecentlyUsedFinite);
1538  _lruList.pushToBack(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx));
1539  }
1540  }
1541  for (size_t i = 2; i < k; i++) {
1542  uint64_t ref = static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx);
1543  try {
1544  _lruList.insertBefore(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx),
1545  ref);
1547  _lruList.pushToBack(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx));
1548  }
1549  }
1550  if (k >= 2) {
1551  _frameReferences[idx]++;
1552  }
1553  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1554  _lruListLock.unlock();
1555  _lruListLock.unlock();
1556  };
1557 
1568  inline void updateOnPageFixed(bf_idx idx) noexcept final {
1569  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1570  _lruListLock.unlock();
1571  };
1572 
1583  inline void updateOnPageDirty(bf_idx idx) noexcept final {
1584  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1585  _lruListLock.unlock();
1586  };
1587 
1598  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
1599  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1600  _lruListLock.unlock();
1601  };
1602 
1613  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
1614  _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1615  _lruListLock.unlock();
1616  };
1617 
1628  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
1629  _lruListLock.lock();
1630  _frameReferences[idx] = 0;
1631  for (size_t i; i < k; i++) {
1632  try {
1633  _remove(static_cast<uint64_t>((i % k) + k * idx));
1635  }
1636  _lruListLock.unlock();
1637  _lruListLock.unlock();
1638  };
1639 
1648  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
1649 
1664  inline void releaseInternalLatches() noexcept final {
1665  _lruListLock.unlock();
1666  };
1667 
1668  private:
1673 
1677  std::vector<size_t> _frameReferences;
1678 
1683  std::recursive_mutex _lruListLock;
1684 
1686 
1687  inline void _pushToBack(uint64_t key) {
1688  if (_leastRecentlyUsedFinite == 0) {
1689  _leastRecentlyUsedFinite = key;
1690  }
1691  _lruList.pushToBack(key);
1692  }
1693 
1694  inline uint64_t _popFromFront() {
1695  uint64_t front = _lruList.getFront();
1696  _remove(front);
1697  return front;
1698  }
1699 
1700  inline void _remove(uint64_t key) {
1701  if (key == _leastRecentlyUsedFinite) {
1702  try {
1703  _leastRecentlyUsedFinite = _lruList.getAfter(key);
1705  _leastRecentlyUsedFinite = 0;
1706  }
1707  }
1708  _lruList.remove(key);
1709  }
1710 
1711  };
1712 
1736  template<uint32_t retry_list_check_ppm/* = 1000000*/, uint32_t mru_list_check_ppm/* = 10000*/>
1738  public:
1744  explicit PageEvictionerSelectorQuasiMRU(const BufferPool* bufferPool) :
1745  PageEvictionerSelector(bufferPool),
1746  _mruList(bufferPool->getBlockCount()) {};
1747 
1760  inline bf_idx select() noexcept final {
1761  static thread_local bool currentlyCheckingRetryList;
1762  static thread_local size_t retriedBufferIndexes;
1763 
1764  bf_idx selected;
1765  if (currentlyCheckingRetryList) { // This thread checked the front of the _retryList last:
1766  if (retriedBufferIndexes < static_cast<bf_idx>(retry_list_check_ppm * 0.000001 * _retryList.length())
1767  || _mruList.length() == 0) { // Check again the front of the _retryList:
1768  _mruListLock.lock();
1769  _retryList.popFromFront(selected);
1770  retriedBufferIndexes++;
1771  return selected;
1772  } else { // Change to checking entries from the front of the _initialList
1773  _mruListLock.lock();
1774  _mruList.popFromFront(selected);
1775  retriedBufferIndexes = 0;
1776  currentlyCheckingRetryList = false;
1777  return selected;
1778  }
1779  } else { // This thread checked the front of the _initialList last:
1780  if (retriedBufferIndexes < static_cast<bf_idx>(mru_list_check_ppm * 0.000001 * _mruList.length())
1781  || _retryList.length() == 0) { // Check again the front of the _initialList:
1782  _mruListLock.lock();
1783  _mruList.popFromFront(selected);
1784  retriedBufferIndexes++;
1785  return selected;
1786  } else { // Change to checking entries from the front of the _retryList
1787  _mruListLock.lock();
1788  _retryList.popFromFront(selected);
1789  retriedBufferIndexes = 0;
1790  currentlyCheckingRetryList = true;
1791  return selected;
1792  }
1793  }
1794  };
1795 
1803  inline void updateOnPageHit(bf_idx idx) noexcept final {};
1804 
1811  inline void updateOnPageUnfix(bf_idx idx) noexcept final {
1812  _mruListLock.lock();
1813  try {
1814  _mruList.remove(idx);
1816  _retryList.remove(idx);
1817  }
1818  _mruList.pushToFront(idx);
1819  _mruListLock.unlock();
1820  };
1821 
1836  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
1837  _mruListLock.lock();
1838  _mruList.pushToFront(idx);
1839  _mruListLock.unlock();
1840  _mruListLock.unlock();
1841  };
1842 
1856  inline void updateOnPageFixed(bf_idx idx) noexcept final {
1857  _mruListLock.lock();
1858  _retryList.pushToBack(idx);
1859  _mruListLock.unlock();
1860  _mruListLock.unlock();
1861  };
1862 
1876  inline void updateOnPageDirty(bf_idx idx) noexcept final {
1877  _mruListLock.lock();
1878  _retryList.pushToBack(idx);
1879  _mruListLock.unlock();
1880  _mruListLock.unlock();
1881  };
1882 
1896  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
1897  _mruListLock.lock();
1898  _retryList.pushToBack(idx);
1899  _mruListLock.unlock();
1900  _mruListLock.unlock();
1901  };
1902 
1916  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
1917  _mruListLock.lock();
1918  _retryList.pushToBack(idx);
1919  _mruListLock.unlock();
1920  _mruListLock.unlock();
1921  };
1922 
1936  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
1937  _mruListLock.lock();
1938  try {
1939  _mruList.remove(idx);
1941  try {
1942  _retryList.remove(idx);
1944  }
1945  _mruListLock.unlock();
1946  _mruListLock.unlock();
1947  };
1948 
1957  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
1958 
1973  inline void releaseInternalLatches() noexcept final {
1974  _mruListLock.unlock();
1975  };
1976 
1977  private:
1984 
1989  std::recursive_mutex _mruListLock;
1990 
1998  };
1999 
2010  template<bf_idx resort_threshold_ppm/* = 750000*/>
2012  public:
2018  explicit PageEvictionerSelectorTimestampLRU(const BufferPool* bufferPool) :
2019  PageEvictionerSelector(bufferPool),
2020  _timestampsLive(bufferPool->getBlockCount()),
2021  _lruList0(bufferPool->getBlockCount()),
2022  _lruList1(bufferPool->getBlockCount()),
2023  _lastChecked(0),
2024  _useLRUList0(false),
2025  _useLRUList1(false) {
2026  _sortingInProgress.clear(); // _sortingInProgress should be initialized false but sometimes it is true!?
2027  };
2028 
2042  inline bf_idx select() noexcept final {
2043  while (true) {
2044  if (_useLRUList0) {
2045  if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (_maxBufferpoolIndex - 1))
2046  && !_sortingInProgress.test_and_set()) {
2047  _waitForSorted.lock();
2048  sort(_lruList1);
2049  _useLRUList1 = true;
2050  _lastChecked = 0;
2051  _waitForSorted.unlock();
2052  _useLRUList0 = false;
2053  _sortingInProgress.clear();
2054  continue;
2055  } else {
2056  bf_idx checkThis = ++_lastChecked;
2057  if (checkThis > _maxBufferpoolIndex) {
2058  _waitForSorted.lock();
2059  _waitForSorted.unlock();
2060  continue;
2061  } else {
2062  if (std::get<1>(_lruList0[checkThis])
2063  == _timestampsLive[std::get<0>(_lruList0[checkThis])]) {
2064  return std::get<0>(_lruList0[checkThis]);
2065  } else {
2066  continue;
2067  }
2068  }
2069  }
2070  } else if (_useLRUList1) {
2071  if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (_maxBufferpoolIndex - 1))
2072  && !_sortingInProgress.test_and_set()) {
2073  _waitForSorted.lock();
2074  sort(_lruList0);
2075  _useLRUList0 = true;
2076  _lastChecked = 0;
2077  _waitForSorted.unlock();
2078  _useLRUList1 = false;
2079  _sortingInProgress.clear();
2080  continue;
2081  } else {
2082  bf_idx checkThis = ++_lastChecked;
2083  if (checkThis > _maxBufferpoolIndex) {
2084  _waitForSorted.lock();
2085  _waitForSorted.unlock();
2086  continue;
2087  } else {
2088  if (std::get<1>(_lruList1[checkThis])
2089  == _timestampsLive[std::get<0>(_lruList1[checkThis])]) {
2090  return std::get<0>(_lruList1[checkThis]);
2091  } else {
2092  continue;
2093  }
2094  }
2095  }
2096  } else if (!_sortingInProgress.test_and_set()) {
2097  _waitForSorted.lock();
2098  sort(_lruList0);
2099  _useLRUList0 = true;
2100  _lastChecked = 0;
2101  _waitForSorted.unlock();
2102  _useLRUList1 = false;
2103  _sortingInProgress.clear();
2104  } else {
2105  _waitForSorted.lock();
2106  _waitForSorted.unlock();
2107  continue;
2108  }
2109  }
2110  };
2111 
2118  inline void updateOnPageHit(bf_idx idx) noexcept final {
2119  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2120  };
2121 
2128  inline void updateOnPageUnfix(bf_idx idx) noexcept final {
2129  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2130  };
2131 
2140  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
2141  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2142  };
2143 
2151  inline void updateOnPageFixed(bf_idx idx) noexcept final {
2152  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2153  };
2154 
2162  inline void updateOnPageDirty(bf_idx idx) noexcept final {
2163  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2164  };
2165 
2174  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
2175  _timestampsLive[idx]
2176  = std::chrono::time_point<std::chrono::steady_clock>::max().time_since_epoch().count();
2177  };
2178 
2186  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
2187  _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2188  };
2189 
2198  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
2199  _timestampsLive[idx] = std::chrono::steady_clock::duration::max().count();
2200  };
2201 
2210  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
2211 
2216  inline void releaseInternalLatches() noexcept final {};
2217 
2218  private:
2225  std::vector<std::atomic<std::chrono::steady_clock::duration::rep>> _timestampsLive;
2226 
2233  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>> _lruList0;
2234 
2241  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>> _lruList1;
2242 
2247 
2251  std::atomic<bool> _useLRUList0;
2252 
2256  std::atomic<bool> _useLRUList1;
2257 
2261  std::atomic_flag _sortingInProgress;
2262 
2268  std::mutex _waitForSorted;
2269 
2277  inline void sort(
2278  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>& into) noexcept {
2279  for (bf_idx index = 0; index < _timestampsLive.size(); index++) {
2280  into[index] = std::make_tuple(index, _timestampsLive[index].load());
2281  }
2282 
2283  std::sort(/*std::parallel::par,*/
2284  into.begin(),
2285  into.end(),
2286  [](const std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>& a,
2287  const std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>& b) {
2288  return std::get<1>(a) < std::get<1>(b);
2289  });
2290 
2291  std::cout << "0: " << std::get<0>(into[0]) << "; "
2292  << _maxBufferpoolIndex << ": " << std::get<0>(into[_maxBufferpoolIndex])
2293  << std::endl;
2294  };
2295  };
2296 
2309  template<size_t k/* = 2*/, bf_idx resort_threshold_ppm/* = 750000*/, bool on_page_unfix/* = false*/>
2311  public:
2317  explicit PageEvictionerSelectorTimestampLRUK(const BufferPool* bufferPool) :
2318  PageEvictionerSelector(bufferPool),
2319  _timestampsLiveOldestTimestamp(bufferPool->getBlockCount()),
2320  _timestampsLive(bufferPool->getBlockCount()),
2321  _lruList0(bufferPool->getBlockCount()),
2322  _lruList1(bufferPool->getBlockCount()),
2323  _lastChecked(0),
2324  _useLRUList0(false),
2325  _useLRUList1(false),
2326  _infinitePast(0) {
2327  _sortingInProgress.clear(); // _sortingInProgress should be initialized false but sometimes it is true!?
2328  };
2329 
2344  inline bf_idx select() noexcept final {
2345  while (true) {
2346  if (_useLRUList0) {
2347  if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (_maxBufferpoolIndex - 1))
2348  && !_sortingInProgress.test_and_set()) {
2349  _waitForSorted.lock();
2350  sort(_lruList1);
2351  _useLRUList1 = true;
2352  _lastChecked = 0;
2353  _waitForSorted.unlock();
2354  _useLRUList0 = false;
2355  _sortingInProgress.clear();
2356  continue;
2357  } else {
2358  bf_idx checkThis = ++_lastChecked;
2359  if (checkThis > _maxBufferpoolIndex) {
2360  _waitForSorted.lock();
2361  _waitForSorted.unlock();
2362  continue;
2363  } else {
2364  if (std::get<1>(_lruList0[checkThis])
2365  == _timestampsLive[std::get<0>(_lruList0[checkThis])][
2366  _timestampsLiveOldestTimestamp[std::get<0>(_lruList0[checkThis])] % k]
2367  && std::get<0>(_lruList0[checkThis]) != 0) {
2368  return std::get<0>(_lruList0[checkThis]);
2369  } else {
2370  continue;
2371  }
2372  }
2373  }
2374  } else if (_useLRUList1) {
2375  if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (_maxBufferpoolIndex - 1))
2376  && !_sortingInProgress.test_and_set()) {
2377  _waitForSorted.lock();
2378  sort(_lruList0);
2379  _useLRUList0 = true;
2380  _lastChecked = 0;
2381  _waitForSorted.unlock();
2382  _useLRUList1 = false;
2383  _sortingInProgress.clear();
2384  continue;
2385  } else {
2386  bf_idx checkThis = ++_lastChecked;
2387  if (checkThis > _maxBufferpoolIndex) {
2388  _waitForSorted.lock();
2389  _waitForSorted.unlock();
2390  continue;
2391  } else {
2392  if (std::get<1>(_lruList1[checkThis])
2393  == _timestampsLive[std::get<0>(_lruList1[checkThis])][
2394  _timestampsLiveOldestTimestamp[std::get<0>(_lruList1[checkThis])] % k]
2395  && std::get<0>(_lruList1[checkThis]) != 0) {
2396  return std::get<0>(_lruList1[checkThis]);
2397  } else {
2398  continue;
2399  }
2400  }
2401  }
2402  } else if (!_sortingInProgress.test_and_set()) {
2403  _waitForSorted.lock();
2404  sort(_lruList0);
2405  _useLRUList0 = true;
2406  _lastChecked = 0;
2407  _waitForSorted.unlock();
2408  _useLRUList1 = false;
2409  _sortingInProgress.clear();
2410  continue;
2411  } else {
2412  _waitForSorted.lock();
2413  _waitForSorted.unlock();
2414  continue;
2415  }
2416  }
2417  };
2418 
2427  inline void updateOnPageHit(bf_idx idx) noexcept final {
2428  if constexpr (!on_page_unfix) {
2429  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2430  = std::chrono::steady_clock::now().time_since_epoch().count();
2431  }
2432  };
2433 
2442  inline void updateOnPageUnfix(bf_idx idx) noexcept final {
2443  if constexpr (on_page_unfix) {
2444  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2445  = std::chrono::steady_clock::now().time_since_epoch().count();
2446  }
2447  };
2448 
2457  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
2458  _timestampsLiveOldestTimestamp[idx] = 0;
2459  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k] = std::chrono::steady_clock::now().time_since_epoch().count();
2460  for (size_t i = 1; i > k; i++) {
2461  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k] = _infinitePast++;
2462  }
2463  };
2464 
2473  inline void updateOnPageFixed(bf_idx idx) noexcept final {
2474  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2475  = std::chrono::steady_clock::now().time_since_epoch().count();
2476  };
2477 
2486  inline void updateOnPageDirty(bf_idx idx) noexcept final {
2487  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2488  = std::chrono::steady_clock::now().time_since_epoch().count();
2489  };
2490 
2499  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
2500  for (size_t i = 0; i < k; i++) {
2501  _timestampsLive[idx][i]
2502  = std::chrono::time_point<std::chrono::steady_clock>::max().time_since_epoch().count();
2503  }
2504  };
2505 
2514  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
2515  _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2516  = std::chrono::steady_clock::now().time_since_epoch().count();
2517  };
2518 
2527  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
2528  for (size_t i = 0; i < k; i++) {
2529  _timestampsLive[idx][i]
2530  = std::chrono::steady_clock::now().time_since_epoch().count();
2531  }
2532  };
2533 
2542  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
2543 
2548  inline void releaseInternalLatches() noexcept final {};
2549 
2550  private:
2557  std::vector<size_t> _timestampsLiveOldestTimestamp;
2558 
2566  std::vector<std::array<std::atomic<std::chrono::steady_clock::duration::rep>, k>> _timestampsLive;
2567 
2574  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>> _lruList0;
2575 
2582  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>> _lruList1;
2583 
2588 
2592  std::atomic<bool> _useLRUList0;
2593 
2597  std::atomic<bool> _useLRUList1;
2598 
2602  std::atomic_flag _sortingInProgress;
2603 
2609  std::mutex _waitForSorted;
2610 
2611  std::atomic<std::chrono::steady_clock::duration::rep> _infinitePast;
2612 
2621  inline void sort(
2622  std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>& into) noexcept {
2623  for (bf_idx index = 0; index < _timestampsLive.size(); index++) {
2624  into[index] = std::make_tuple(index,
2625  _timestampsLive[index][_timestampsLiveOldestTimestamp[index] % k].load());
2626  }
2627 
2628  std::sort(/*std::parallel::par,*/
2629  into.begin(),
2630  into.end(),
2631  [](const std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>& a,
2632  const std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>& b) {
2633  return std::get<1>(a) < std::get<1>(b);
2634  });
2635  };
2636  };
2637 
2645  public:
2651  explicit PageEvictionerSelectorLFU(const BufferPool* bufferPool) :
2652  PageEvictionerSelector(bufferPool),
2653  _frameReferences(bufferPool->getBlockCount()),
2654  _frameAlreadySelected(bufferPool->getBlockCount()) {};
2655 
2664  inline bf_idx select() noexcept final {
2665  bf_idx minIndex = 0;
2666  uint64_t minReferences = std::numeric_limits<uint64_t>::max();
2667 
2668  while (true) {
2669  for (bf_idx index = 1; index <= _maxBufferpoolIndex; index++) {
2670  if (_frameReferences[index] < minReferences) {
2671  if (!_frameAlreadySelected[index].test_and_set()) {
2672  _frameAlreadySelected[minIndex].clear();
2673  minIndex = index;
2674  minReferences = _frameReferences[index];
2675  }
2676  }
2677  }
2678 
2679  if (_frameReferences[minIndex] != minReferences) {
2680  _frameAlreadySelected[minIndex].clear();
2681  minReferences = std::numeric_limits<uint64_t>::max();
2682  continue;
2683  } else {
2684  return minIndex;
2685  }
2686  }
2687  };
2688 
2695  inline void updateOnPageHit(bf_idx idx) noexcept final {
2696  _frameReferences[idx]++;
2697  };
2698 
2705  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
2706 
2715  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
2716  _frameReferences[idx] = 1;
2717  _frameAlreadySelected[idx].clear();
2718  };
2719 
2728  inline void updateOnPageFixed(bf_idx idx) noexcept final {
2729  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2730  _frameAlreadySelected[idx].clear();
2731  };
2732 
2741  inline void updateOnPageDirty(bf_idx idx) noexcept final {
2742  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2743  _frameAlreadySelected[idx].clear();
2744  };
2745 
2754  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
2755  _frameReferences[idx] = std::numeric_limits<uint64_t>::max() / 2;
2756  };
2757 
2765  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
2766  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2767  _frameAlreadySelected[idx].clear();
2768  };
2769 
2779  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
2780  _frameReferences[idx] = std::numeric_limits<uint64_t>::max();
2781  _frameAlreadySelected[idx].test_and_set();
2782  }
2783 
2792  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
2793 
2798  inline void releaseInternalLatches() noexcept final {};
2799 
2800  private:
2806  std::vector<std::atomic<uint64_t>> _frameReferences;
2807 
2811  std::vector<std::atomic_flag> _frameAlreadySelected;
2812 
2813  };
2814 
2826  public:
2832  explicit PageEvictionerSelectorLFUDA(const BufferPool* bufferPool) :
2833  PageEvictionerSelector(bufferPool),
2834  _frameReferences(bufferPool->getBlockCount()),
2835  _inflationFactor(1),
2836  _frameAlreadySelected(bufferPool->getBlockCount()) {};
2837 
2846  inline bf_idx select() noexcept final {
2847  bf_idx minIndex = 0;
2848  uint64_t minReferences = std::numeric_limits<uint64_t>::max();
2849 
2850  while (true) {
2851  for (bf_idx index = 1; index <= _maxBufferpoolIndex; index++) {
2852  if (_frameReferences[index] < minReferences) {
2853  if (!_frameAlreadySelected[index].test_and_set()) {
2854  _frameAlreadySelected[minIndex].clear();
2855  minIndex = index;
2856  minReferences = _frameReferences[index];
2857  }
2858  }
2859  }
2860 
2861  if (_frameReferences[minIndex] != minReferences) {
2862  _frameAlreadySelected[minIndex].clear();
2863  minReferences = std::numeric_limits<uint64_t>::max();
2864  continue;
2865  } else {
2866  _inflationFactor = minReferences;
2867  return minIndex;
2868  }
2869  }
2870  };
2871 
2878  inline void updateOnPageHit(bf_idx idx) noexcept final {
2879  _frameReferences[idx]++;
2880  };
2881 
2888  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
2889 
2899  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
2900  _frameReferences[idx] = _inflationFactor.load();
2901  _frameAlreadySelected[idx].clear();
2902  };
2903 
2912  inline void updateOnPageFixed(bf_idx idx) noexcept final {
2913  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2914  _frameAlreadySelected[idx].clear();
2915  };
2916 
2925  inline void updateOnPageDirty(bf_idx idx) noexcept final {
2926  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2927  _frameAlreadySelected[idx].clear();
2928  };
2929 
2938  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
2939  _frameReferences[idx] = std::numeric_limits<uint64_t>::max() / 2;
2940  };
2941 
2950  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
2951  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
2952  _frameAlreadySelected[idx].clear();
2953  };
2954 
2964  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
2965  _frameReferences[idx] = std::numeric_limits<uint64_t>::max();
2966  _frameAlreadySelected[idx].test_and_set();
2967  };
2968 
2977  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
2978 
2983  inline void releaseInternalLatches() noexcept final {};
2984 
2985  private:
2991  std::vector<std::atomic<uint64_t>> _frameReferences;
2992 
2996  std::atomic<uint64_t> _inflationFactor;
2997 
3001  std::vector<std::atomic_flag> _frameAlreadySelected;
3002 
3003  };
3004 
3014  public:
3020  explicit PageEvictionerSelectorLRDV1(const BufferPool* bufferPool) :
3021  PageEvictionerSelector(bufferPool),
3022  _frameReferences(bufferPool->getBlockCount()),
3023  _frameFirstReferenced(bufferPool->getBlockCount()),
3024  _frameAlreadySelected(bufferPool->getBlockCount()),
3025  _globalReferences(0) {};
3026 
3035  inline bf_idx select() noexcept final {
3036  bf_idx minLRDIndex = 0;
3037  uint64_t minLRDReferences;
3038  double minLRDReferenceDensity = std::numeric_limits<double>::max();
3039 
3040  while (true) {
3041  for (bf_idx index = 1; index <= _maxBufferpoolIndex; index++) {
3042  if ((static_cast<double>(_frameReferences[index])
3043  / static_cast<double>(_globalReferences - _frameFirstReferenced[index]))
3044  < minLRDReferenceDensity) {
3045  if (!_frameAlreadySelected[index].test_and_set()) {
3046  _frameAlreadySelected[minLRDIndex].clear();
3047  minLRDIndex = index;
3048  minLRDReferences = _frameReferences[index];
3049  minLRDReferenceDensity = static_cast<double>(_frameReferences[index])
3050  / static_cast<double>(_globalReferences
3051  - _frameFirstReferenced[index]);
3052  }
3053  }
3054  }
3055 
3056  if (_frameReferences[minLRDIndex] != minLRDReferences) {
3057  _frameAlreadySelected[minLRDIndex].clear();
3058  minLRDReferenceDensity = std::numeric_limits<double>::max();
3059  continue;
3060  } else {
3061  return minLRDIndex;
3062  }
3063  }
3064  };
3065 
3073  inline void updateOnPageHit(bf_idx idx) noexcept final {
3074  _globalReferences++;
3075  _frameReferences[idx]++;
3076  };
3077 
3086  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
3087 
3098  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
3099  _frameFirstReferenced[idx] = _globalReferences++;
3100  _frameReferences[idx] = 1;
3101  _frameAlreadySelected[idx].clear();
3102  };
3103 
3112  inline void updateOnPageFixed(bf_idx idx) noexcept final {
3113  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3114  _frameAlreadySelected[idx].clear();
3115  };
3116 
3125  inline void updateOnPageDirty(bf_idx idx) noexcept final {
3126  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3127  _frameAlreadySelected[idx].clear();
3128  };
3129 
3138  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
3139  _frameReferences[idx] = _globalReferences.load(); // Prevent further tries of eviction!
3140  };
3141 
3150  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
3151  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3152  _frameAlreadySelected[idx].clear();
3153  };
3154 
3163  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
3164  _frameFirstReferenced[idx] = 0;
3165  _frameReferences[idx] = 0;
3166  _frameAlreadySelected[idx].test_and_set();
3167  };
3168 
3177  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
3178 
3183  inline void releaseInternalLatches() noexcept final {};
3184 
3185  private:
3189  std::vector<std::atomic<uint64_t>> _frameReferences;
3190 
3194  std::vector<std::atomic<uint64_t>> _frameFirstReferenced;
3195 
3199  std::vector<std::atomic_flag> _frameAlreadySelected;
3200 
3204  std::atomic<uint64_t> _globalReferences;
3205  };
3206 
3207  struct AgingFunction {
3208  virtual void operator()(std::atomic<uint64_t>& referenceCount) noexcept = 0;
3209  };
3210 
3211  template<uint64_t subtrahend/* = 10*/>
3213  inline void operator()(std::atomic<uint64_t>& referenceCount) noexcept final {
3214  if (referenceCount > subtrahend) {
3215  referenceCount -= subtrahend;
3216  } else {
3217  referenceCount = 0;
3218  }
3219  }
3220  };
3221 
3222  template<uint64_t factor_ppm/* = 750000*/>
3224  inline void operator()(std::atomic<uint64_t>& referenceCount) noexcept final {
3225  referenceCount = static_cast<uint64_t>(factor_ppm * 0.000001 * referenceCount);
3226  }
3227  };
3228 
3244  template<uint64_t aging_frequency/* = 10*/, class aging_function>
3246  static_assert(std::is_base_of<AgingFunction, aging_function>::value,
3247  "'selector_class' is not of type 'AgingFunction'!");
3248 
3249  public:
3255  explicit PageEvictionerSelectorLRDV2(const BufferPool* bufferPool) :
3256  PageEvictionerSelector(bufferPool),
3257  _frameReferences(bufferPool->getBlockCount()),
3258  _frameFirstReferenced(bufferPool->getBlockCount()),
3259  _frameAlreadySelected(bufferPool->getBlockCount()),
3260  _globalReferences(0),
3261  _agingFrequency(aging_frequency * bufferPool->getBlockCount()) {};
3262 
3271  inline bf_idx select() noexcept final {
3272  bf_idx minLRDIndex = 0;
3273  uint64_t minLRDReferences;
3274  double minLRDReferenceDensity = std::numeric_limits<double>::max();
3275 
3276  while (true) {
3277  for (bf_idx index = 1; index <= _maxBufferpoolIndex; index++) {
3278  if ((static_cast<double>(_frameReferences[index])
3279  / static_cast<double>(_globalReferences - _frameFirstReferenced[index]))
3280  < minLRDReferenceDensity) {
3281  if (!_frameAlreadySelected[index].test_and_set()) {
3282  _frameAlreadySelected[minLRDIndex].clear();
3283  minLRDIndex = index;
3284  minLRDReferences = _frameReferences[index];
3285  minLRDReferenceDensity = static_cast<double>(_frameReferences[index])
3286  / static_cast<double>(_globalReferences
3287  - _frameFirstReferenced[index]);
3288  }
3289  }
3290  }
3291 
3292  if (_frameReferences[minLRDIndex] != minLRDReferences) {
3293  _frameAlreadySelected[minLRDIndex].clear();
3294  minLRDReferenceDensity = std::numeric_limits<double>::max();
3295  continue;
3296  } else {
3297  return minLRDIndex;
3298  }
3299  }
3300  };
3301 
3311  inline void updateOnPageHit(bf_idx idx) noexcept final {
3312  _frameReferences[idx]++;
3313  if (_globalReferences++ % _agingFrequency == 0) {
3314  std::for_each(/*std::parallel::par, */_frameReferences.begin(), _frameReferences.end(),
3315  [this](std::atomic<uint64_t>& referenceCount) {
3316  _agingFunction(referenceCount);
3317  });
3318  }
3319  };
3320 
3329  inline void updateOnPageUnfix(bf_idx idx) noexcept final {};
3330 
3342  inline void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final {
3343  _frameFirstReferenced[idx] = _globalReferences++;
3344  if (_frameFirstReferenced[idx] % _agingFrequency == 0) {
3345  std::for_each(/*std::parallel::par, */_frameReferences.begin(), _frameReferences.end(),
3346  [this](std::atomic<uint64_t>& referenceCount) {
3347  _agingFunction(referenceCount);
3348  });
3349  }
3350  _frameReferences[idx] = 1;
3351  _frameAlreadySelected[idx].clear();
3352  };
3353 
3362  inline void updateOnPageFixed(bf_idx idx) noexcept final {
3363  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3364  _frameAlreadySelected[idx].clear();
3365  };
3366 
3375  inline void updateOnPageDirty(bf_idx idx) noexcept final {
3376  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3377  _frameAlreadySelected[idx].clear();
3378  };
3379 
3388  inline void updateOnPageBlocked(bf_idx idx) noexcept final {
3389  _frameReferences[idx] = _globalReferences.load(); // Prevent further tries of eviction!
3390  };
3391 
3400  inline void updateOnPageSwizzled(bf_idx idx) noexcept final {
3401  _frameReferences[idx]++; // Prevent infinite loops of non-evictable selects.
3402  _frameAlreadySelected[idx].clear();
3403  };
3404 
3413  inline void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final {
3414  _frameFirstReferenced[idx] = 0;
3415  _frameReferences[idx] = 0;
3416  _frameAlreadySelected[idx].test_and_set();
3417  };
3418 
3427  void updateOnPointerSwizzling(bf_idx idx) noexcept final {};
3428 
3433  inline void releaseInternalLatches() noexcept final {};
3434 
3435  private:
3439  std::vector<std::atomic<uint64_t>> _frameReferences;
3440 
3444  std::vector<std::atomic<uint64_t>> _frameFirstReferenced;
3445 
3449  std::vector<std::atomic_flag> _frameAlreadySelected;
3450 
3454  std::atomic<uint64_t> _globalReferences;
3455 
3460 
3464  aging_function _agingFunction;
3465  };
3466 } // zero::buffer_pool
3467 
3468 #endif // __PAGE_EVICTIONER_SELECTOR_HPP
void sort(std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep >> &into) noexcept
Sorts the buffer frames according to timestamps.
Definition: page_evictioner_selector.hpp:2277
rigtorp::MPMCQueue< bf_idx > _retryList
Queue of buffer frames currently last selected for eviction.
Definition: page_evictioner_selector.hpp:679
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:1811
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:1275
virtual void updateOnPageDirty(bf_idx idx) noexcept=0
Updates the eviction statistics of dirty pages during eviction.
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.
std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep > > _lruList0
List of buffer frame indexes sorted by page reference recency.
Definition: page_evictioner_selector.hpp:2233
zero::hashtable_deque::HashtableDeque< bf_idx, 0 > _protectedLRUList
The protected segment sorted according to reference recency.
Definition: page_evictioner_selector.hpp:1418
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:3138
virtual void updateOnPageHit(bf_idx idx) noexcept=0
Updates the eviction statistics on page hit.
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:1024
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_selector.hpp:375
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:1525
Definition: page_evictioner_selector.hpp:3223
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:558
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:2938
zero::hashtable_deque::HashtableDeque< bf_idx, 0 > _mruList
Stack of recently referenced buffer frame indexes (most recent at the top)
Definition: page_evictioner_selector.hpp:1983
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:594
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:850
std::vector< std::atomic_flag > _notExplicitlyEvictedList
Flags not explicitly buffer frames.
Definition: page_evictioner_selector.hpp:934
std::vector< std::atomic< std::chrono::steady_clock::duration::rep > > _timestampsLive
Most recent page reference timestamps for the buffer frames.
Definition: page_evictioner_selector.hpp:2225
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:2779
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:2925
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:992
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:1350
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:3342
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:3150
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_selector.hpp:2792
cds::container::FCStack< bf_idx > _initialList
Queue of buffer frames currently used but not selected for eviction.
Definition: page_evictioner_selector.hpp:916
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:327
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:2198
virtual ~PageEvictionerSelector()
Destructs a buffer frame selector.
Definition: page_evictioner_selector.hpp:39
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:474
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:349
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:839
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:827
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:2174
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:338
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:1484
PageEvictionerSelectorLRDV1(const BufferPool *bufferPool)
Constructs a Least Reference Density V1 buffer frame selector.
Definition: page_evictioner_selector.hpp:3020
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:1836
PageEvictionerSelectorQuasiMRU(const BufferPool *bufferPool)
Constructs a MRU buffer frame selector.
Definition: page_evictioner_selector.hpp:1744
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:227
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:1803
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:293
Definition: buffer_pool.hpp:34
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:2846
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:1373
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:2715
std::recursive_mutex _lruListLock
Protects the protected and probationary segments from concurrent manupulations.
Definition: page_evictioner_selector.hpp:1433
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_selector.hpp:3177
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:633
MRU buffer frame selector
Definition: page_evictioner_selector.hpp:1737
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_selector.hpp:2210
zero::hashtable_deque::HashtableDeque< bf_idx, 0 > _retryList
Queue of buffer frames currently last selected for eviction.
Definition: page_evictioner_selector.hpp:1997
const bf_idx _protectedBlockCount
Maximum number of buffer frame indexes in the protected segment.
Definition: page_evictioner_selector.hpp:1428
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:2695
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_selector.hpp:1957
PageEvictionerSelector(const BufferPool *bufferPool)
Constructs a buffer frame selector.
Definition: page_evictioner_selector.hpp:32
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:3433
void operator()(std::atomic< uint64_t > &referenceCount) noexcept final
Definition: page_evictioner_selector.hpp:3224
virtual bf_idx select() noexcept=0
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:39
Exception thrown when an entry was not already contained in an HashtableDeque.
Definition: hashtable_deque_exceptions.hpp:161
LFU buffer frame selector
Definition: page_evictioner_selector.hpp:2644
zero::hashtable_deque::HashtableDeque< bf_idx, 0 > _probationaryLRUList
The probationary segment sorted according to reference recency.
Definition: page_evictioner_selector.hpp:1423
PageEvictionerSelectorLRU(const BufferPool *bufferPool)
Constructs a LRU buffer frame selector.
Definition: page_evictioner_selector.hpp:966
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:1876
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:1916
uint64_t _agingFrequency
Global page references between aging runs.
Definition: page_evictioner_selector.hpp:3459
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:2983
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:1598
atomic_bf_idx _approximateRetryListLength
Approximate length of the _initialList (not synchronized)
Definition: page_evictioner_selector.hpp:684
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:549
std::atomic< std::chrono::steady_clock::duration::rep > _infinitePast
Definition: page_evictioner_selector.hpp:2611
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:886
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:381
std::recursive_mutex _lruListLock
Latch protecting the _lruList and _frameReferences from concurrent manipulations. ...
Definition: page_evictioner_selector.hpp:1683
bf_idx _maxBufferpoolIndex
The maximum buffer frame index.
Definition: page_evictioner_selector.hpp:180
void _remove(uint64_t key)
Definition: page_evictioner_selector.hpp:1700
LRU buffer frame selector
Definition: page_evictioner_selector.hpp:959
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:2741
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:2427
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:1410
PageEvictionerSelectorLFUDA(const BufferPool *bufferPool)
Constructs a LFU with dynamic aging buffer frame selector.
Definition: page_evictioner_selector.hpp:2832
std::vector< std::atomic< uint64_t > > _frameReferences
Reference counters for the buffer frames.
Definition: page_evictioner_selector.hpp:3189
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:3125
std::vector< std::atomic< uint64_t > > _frameFirstReferenced
Times of first reference of the buffer frames.
Definition: page_evictioner_selector.hpp:3444
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:1080
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:749
std::vector< std::atomic_flag > _notExplicitlyEvictedList
Flags not explicitly buffer frames.
Definition: page_evictioner_selector.hpp:411
virtual void updateOnPageFixed(bf_idx idx) noexcept=0
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
cds::container::FCQueue< bf_idx > _initialList
Queue of buffer frames currently used but not selected for eviction.
Definition: page_evictioner_selector.hpp:393
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:1004
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:2878
std::vector< std::atomic< uint64_t > > _frameReferences
Reference counters for the buffer frames.
Definition: page_evictioner_selector.hpp:2806
PageEvictionerSelectorLRDV2(const BufferPool *bufferPool)
Constructs a Least Reference Density V2 buffer frame selector.
Definition: page_evictioner_selector.hpp:3255
uint32_t bf_idx
Definition: basics.h:56
PageEvictionerSelectorTimestampLRUK(const BufferPool *bufferPool)
Constructs a LRU-k buffer frame selector.
Definition: page_evictioner_selector.hpp:2317
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:1044
virtual void releaseInternalLatches() noexcept=0
Releases the internal latches of the buffer frame selector.
Exception thrown when an entry was already at the back of an HashtableDeque.
Definition: hashtable_deque_exceptions.hpp:247
std::vector< std::atomic_flag > _frameAlreadySelected
Whether a buffer frame index was already selected by one thread.
Definition: page_evictioner_selector.hpp:3449
virtual void updateOnPageBlocked(bf_idx idx) noexcept=0
Updates the eviction statistics of pages that cannot be evicted at all.
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:304
PageEvictionerSelectorTimestampLRU(const BufferPool *bufferPool)
Constructs a LRU buffer frame selector.
Definition: page_evictioner_selector.hpp:2018
cds::container::FCQueue< bf_idx > _retryList
Queue of buffer frames currently last selected for eviction.
Definition: page_evictioner_selector.hpp:927
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:2527
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:872
uint64_t _leastRecentlyUsedFinite
Definition: page_evictioner_selector.hpp:1685
zero::hashtable_deque::HashtableDeque< bf_idx, 0 > _lruList
Queue of recently referenced buffer frame indexes (most recent in the back)
Definition: page_evictioner_selector.hpp:1157
LRU-k buffer frame selector
Definition: page_evictioner_selector.hpp:2310
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:1500
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:3271
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:1470
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:2140
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:1664
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:2042
uint32_t PageID
Definition: basics.h:45
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:651
std::vector< std::atomic< uint64_t > > _frameReferences
Reference counters for the buffer frames.
Definition: page_evictioner_selector.hpp:2991
PageEvictionerSelectorQuasiFILOLowContention(const BufferPool *bufferPool)
Constructs a FILO buffer frame selector.
Definition: page_evictioner_selector.hpp:734
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:3073
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:3086
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:2912
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_selector.hpp:2542
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:2473
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:2442
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_selector.hpp:1394
uint64_t _popFromFront()
Definition: page_evictioner_selector.hpp:1694
std::vector< std::atomic_flag > _frameAlreadySelected
Whether a buffer frame index was already selected by one thread.
Definition: page_evictioner_selector.hpp:3001
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_selector.hpp:1133
PageEvictionerSelectorLFU(const BufferPool *bufferPool)
Constructs a LFU buffer frame selector.
Definition: page_evictioner_selector.hpp:2651
const T max(const T x, const T y)
Definition: w_minmax.h:45
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:316
std::mutex _waitForSorted
Manages a queue for the sorting process.
Definition: page_evictioner_selector.hpp:2609
PageEvictionerSelectorLRUK(const BufferPool *bufferPool)
Constructs a LRU-k buffer frame selector.
Definition: page_evictioner_selector.hpp:1457
PageEvictionerSelectorSLRU(const BufferPool *bufferPool)
Constructs a Segmented LRU buffer frame selector.
Definition: page_evictioner_selector.hpp:1185
Definition: page_evictioner_selector.hpp:3212
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:2162
FIFO buffer frame selector
Definition: page_evictioner_selector.hpp:205
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:2705
PageEvictionerSelectorQuasiFIFOLowContention(const BufferPool *bufferPool)
Constructs a FIFO buffer frame selector.
Definition: page_evictioner_selector.hpp:212
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:1062
std::atomic< bool > _useLRUList1
_lruList1 is most recently sorted list if set
Definition: page_evictioner_selector.hpp:2597
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:1896
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:2118
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:807
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:2754
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_selector.hpp:1648
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:3112
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:2950
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:2798
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:2964
rigtorp::MPMCQueue< bf_idx > _initialList
Queue of buffer frames currently used but not selected for eviction.
Definition: page_evictioner_selector.hpp:663
LRD-V2 buffer frame selector
Definition: page_evictioner_selector.hpp:3245
std::atomic_flag _sortingInProgress
One thread currently sorts one of the lists if set.
Definition: page_evictioner_selector.hpp:2602
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:1628
FIFO buffer frame selector
Definition: page_evictioner_selector.hpp:448
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:1300
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:1237
LRU buffer frame selector
Definition: page_evictioner_selector.hpp:2011
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:1613
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:3311
void sort(std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep >> &into) noexcept
Sorts the buffer frames according to timestamps.
Definition: page_evictioner_selector.hpp:2621
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:1200
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_selector.hpp:898
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:1149
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:569
std::atomic< uint64_t > _globalReferences
Global reference counter.
Definition: page_evictioner_selector.hpp:3454
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:2899
std::recursive_mutex _lruListLock
Latch protecting the _lruList from concurrent manipulations.
Definition: page_evictioner_selector.hpp:1162
void remove(const key_type &k)
Removes a specific key from this deque.
Definition: hashtable_deque.hpp:343
A buffer manager that exploits the tree structure of indexes.
Definition: buffer_pool.hpp:40
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:284
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:2128
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:861
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:363
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:1760
std::atomic_flag _sortingInProgress
One thread currently sorts one of the lists if set.
Definition: page_evictioner_selector.hpp:2261
virtual void updateOnPointerSwizzling(bf_idx idx) noexcept=0
Updates the eviction statistics of pages when its pointer got swizzled in its parent page...
std::vector< std::atomic_flag > _notExplicitlyEvictedList
Flags not explicitly buffer frames.
Definition: page_evictioner_selector.hpp:691
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:3163
virtual void updateOnPageUnfix(bf_idx idx) noexcept=0
Updates the eviction statistics on page unfix.
zero::hashtable_deque::HashtableDeque< uint64_t, 0 > _lruList
At most k page references per buffer frame index (most recent in the back)
Definition: page_evictioner_selector.hpp:1672
virtual void updateOnPageSwizzled(bf_idx idx) noexcept=0
Updates the eviction statistics of pages containing swizzled pointers during eviction.
std::vector< std::atomic< uint64_t > > _frameFirstReferenced
Times of first reference of the buffer frames.
Definition: page_evictioner_selector.hpp:3194
std::vector< size_t > _timestampsLiveOldestTimestamp
Index of oldest timestamp for each buffer frame.
Definition: page_evictioner_selector.hpp:2557
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:3413
std::atomic< bool > _useLRUList0
_lruList0 is most recently sorted list if set
Definition: page_evictioner_selector.hpp:2592
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:1856
std::atomic< bool > _useLRUList0
_lruList0 is most recently sorted list if set
Definition: page_evictioner_selector.hpp:2251
std::atomic< uint64_t > _inflationFactor
The inflation factor (reference counter of last selected buffer frame)
Definition: page_evictioner_selector.hpp:2996
std::recursive_mutex _mruListLock
Latch protecting the _mruList and the _retryList from concurrent manipulations.
Definition: page_evictioner_selector.hpp:1989
LRU-k buffer frame selector
Definition: page_evictioner_selector.hpp:1450
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:816
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:3183
aging_function _agingFunction
Instance of the aging function.
Definition: page_evictioner_selector.hpp:3464
void pushToBack(const key_type &k)
Add the key to the back of this deque.
Definition: hashtable_deque.hpp:80
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:3400
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:1568
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:2344
atomic_bf_idx _lastChecked
The last checked index of the currently sorted list of buffer frames.
Definition: page_evictioner_selector.hpp:2587
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:1936
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:2151
std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep > > _lruList0
List of buffer frame indexes sorted by page reference recency.
Definition: page_evictioner_selector.hpp:2574
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:3388
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:3362
LRD-V1 buffer frame selector
Definition: page_evictioner_selector.hpp:3013
SLRU buffer frame selector
Definition: page_evictioner_selector.hpp:1178
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:2457
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:2664
void getAfter(key_type &k, const key_type &ref)
Get the key to after a reference key.
Definition: hashtable_deque.hpp:711
std::vector< std::atomic_flag > _frameAlreadySelected
Whether a buffer frame index was already selected by one thread.
Definition: page_evictioner_selector.hpp:2811
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:2888
FIFO buffer frame selector
Definition: page_evictioner_selector.hpp:727
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:2216
std::vector< size_t > _frameReferences
Next used page reference numbers per buffer frame index.
Definition: page_evictioner_selector.hpp:1677
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:1098
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_selector.hpp:2977
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:1973
std::atomic< bool > _useLRUList1
_lruList1 is most recently sorted list if set
Definition: page_evictioner_selector.hpp:2256
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:3375
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:2486
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:2728
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:3098
void updateOnPageFixed(bf_idx idx) noexcept final
Updates the eviction statistics of fixed (i.e. used) pages during eviction.
Definition: page_evictioner_selector.hpp:582
void updateOnPageExplicitlyUnbuffered(bf_idx idx) noexcept final
Updates the eviction statistics on explicit unbuffer.
Definition: page_evictioner_selector.hpp:1116
void operator()(std::atomic< uint64_t > &referenceCount) noexcept final
Definition: page_evictioner_selector.hpp:3213
Buffer frame selector for the Select-and-Filter page evictioner.
Definition: page_evictioner_selector.hpp:25
std::vector< std::atomic_flag > _frameAlreadySelected
Whether a buffer frame index was already selected by one thread.
Definition: page_evictioner_selector.hpp:3199
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:3035
atomic_bf_idx _lastChecked
The last checked index of the currently sorted list of buffer frames.
Definition: page_evictioner_selector.hpp:2246
cds::container::FCQueue< bf_idx > _retryList
Queue of buffer frames currently last selected for eviction.
Definition: page_evictioner_selector.hpp:404
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_selector.hpp:3427
std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep > > _lruList1
List of buffer frame indexes sorted by page reference recency.
Definition: page_evictioner_selector.hpp:2582
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:2765
void updateOnPageHit(bf_idx idx) noexcept final
Updates the eviction statistics on page hit.
Definition: page_evictioner_selector.hpp:1215
bf_idx select() noexcept final
Selects a page to be evicted from the buffer pool.
Definition: page_evictioner_selector.hpp:979
std::atomic< uint32_t > atomic_bf_idx
Definition: basics.h:58
std::mutex _waitForSorted
Manages a queue for the sorting process.
Definition: page_evictioner_selector.hpp:2268
void updateOnPageUnfix(bf_idx idx) noexcept final
Updates the eviction statistics on page unfix.
Definition: page_evictioner_selector.hpp:3329
std::vector< std::tuple< bf_idx, std::chrono::steady_clock::duration::rep > > _lruList1
List of buffer frame indexes sorted by page reference recency.
Definition: page_evictioner_selector.hpp:2241
void updateOnPageDirty(bf_idx idx) noexcept final
Updates the eviction statistics of dirty pages during eviction.
Definition: page_evictioner_selector.hpp:1583
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:2548
PageEvictionerSelectorQuasiFIFOHighContention(const BufferPool *bufferPool)
Constructs a FIFO buffer frame selector.
Definition: page_evictioner_selector.hpp:455
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:606
atomic_bf_idx _approximateInitialListLength
Approximate length of the _initialList (not synchronized)
Definition: page_evictioner_selector.hpp:668
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:2514
std::atomic< uint64_t > _globalReferences
Global reference counter.
Definition: page_evictioner_selector.hpp:3204
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:618
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:2499
void _pushToBack(uint64_t key)
Definition: page_evictioner_selector.hpp:1687
void getFront(key_type &k)
Get the key at the front.
Definition: hashtable_deque.hpp:546
std::vector< std::atomic< uint64_t > > _frameReferences
Reference counters for the buffer frames.
Definition: page_evictioner_selector.hpp:3439
void updateOnPageSwizzled(bf_idx idx) noexcept final
Updates the eviction statistics of pages containing swizzled pointers during eviction.
Definition: page_evictioner_selector.hpp:2186
std::vector< std::array< std::atomic< std::chrono::steady_clock::duration::rep >, k > > _timestampsLive
k most recent page reference timestamps for the buffer frames
Definition: page_evictioner_selector.hpp:2566
void updateOnPageMiss(bf_idx idx, PageID pid) noexcept final
Updates the eviction statistics on page miss.
Definition: page_evictioner_selector.hpp:1253
Definition: page_evictioner_selector.hpp:3207
void updateOnPageBlocked(bf_idx idx) noexcept final
Updates the eviction statistics of pages that cannot be evicted at all.
Definition: page_evictioner_selector.hpp:1325
LFUDA buffer frame selector
Definition: page_evictioner_selector.hpp:2825
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_selector.hpp:645
void releaseInternalLatches() noexcept final
Releases the internal latches of this buffer frame selector.
Definition: page_evictioner_selector.hpp:904