1 #ifndef __PAGE_EVICTIONER_SELECTOR_HPP 2 #define __PAGE_EVICTIONER_SELECTOR_HPP 8 #include "cds/container/fcqueue.h" 9 #include "cds/container/fcstack.h" 10 #include "MPMCQueue/MPMCQueue.h" 204 template<uint32_t retry_list_check_ppm, uint32_t initial_list_check_ppm>
214 _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
228 static thread_local
bool currentlyCheckingRetryList;
229 static thread_local
size_t retriedBufferIndexes;
233 if (!currentlyCheckingRetryList) {
234 if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _initialList.size())
235 || _retryList.empty()) {
236 _initialList.pop(selected);
237 retriedBufferIndexes++;
238 if (_notExplicitlyEvictedList[selected].test_and_set()) {
244 _retryList.pop(selected);
245 if (_notExplicitlyEvictedList[selected].test_and_set()) {
246 retriedBufferIndexes = 0;
247 currentlyCheckingRetryList =
true;
254 if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _retryList.size())
255 || _initialList.empty()) {
256 _retryList.pop(selected);
257 retriedBufferIndexes++;
258 if (_notExplicitlyEvictedList[selected].test_and_set()) {
264 _initialList.pop(selected);
265 if (_notExplicitlyEvictedList[selected].test_and_set()) {
266 retriedBufferIndexes = 0;
267 currentlyCheckingRetryList =
false;
305 _notExplicitlyEvictedList[idx].test_and_set();
306 _initialList.push(idx);
317 _retryList.push(idx);
328 _retryList.push(idx);
339 _retryList.push(idx);
350 _retryList.push(idx);
364 _notExplicitlyEvictedList[idx].clear();
417 static constexpr
double _retryListCheck = retry_list_check_ppm * 0.000001;
423 static constexpr
double _initialListCheck = initial_list_check_ppm * 0.000001;
447 template<uint32_t retry_list_check_ppm, uint32_t initial_list_check_ppm>
457 _approximateInitialListLength(0),
458 _approximateRetryListLength(0),
459 _initialList(bufferPool->getBlockCount()),
460 _retryList(bufferPool->getBlockCount()),
461 _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
475 static thread_local
bool currentlyCheckingRetryList;
476 static thread_local
size_t retriedBufferIndexes;
480 if (!currentlyCheckingRetryList) {
481 if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _approximateInitialListLength)
482 || _approximateRetryListLength == 0) {
483 if (_initialList.try_pop(selected)) {
484 _approximateInitialListLength--;
485 retriedBufferIndexes++;
486 if (_notExplicitlyEvictedList[selected].test_and_set()) {
492 currentlyCheckingRetryList =
true;
496 if (_retryList.try_pop(selected)) {
497 _approximateRetryListLength--;
498 retriedBufferIndexes = 0;
499 if (_notExplicitlyEvictedList[selected].test_and_set()) {
505 currentlyCheckingRetryList =
false;
510 if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _approximateRetryListLength)
511 || _approximateInitialListLength == 0) {
512 if (_retryList.try_pop(selected)) {
513 _approximateRetryListLength--;
514 retriedBufferIndexes++;
515 if (_notExplicitlyEvictedList[selected].test_and_set()) {
521 currentlyCheckingRetryList =
false;
525 if (_initialList.try_pop(selected)) {
526 _approximateInitialListLength--;
527 retriedBufferIndexes = 0;
528 if (_notExplicitlyEvictedList[selected].test_and_set()) {
534 currentlyCheckingRetryList =
true;
570 _notExplicitlyEvictedList[idx].test_and_set();
571 _initialList.push(idx);
572 _approximateInitialListLength++;
583 _retryList.push(idx);
584 _approximateRetryListLength++;
595 _retryList.push(idx);
596 _approximateRetryListLength++;
607 _retryList.push(idx);
608 _approximateRetryListLength++;
619 _retryList.push(idx);
620 _approximateRetryListLength++;
634 _notExplicitlyEvictedList[idx].clear();
697 static constexpr
double _retryListCheck = retry_list_check_ppm * 0.000001;
703 static constexpr
double _initialListCheck = initial_list_check_ppm * 0.000001;
726 template<uint32_t retry_list_check_ppm, uint32_t initial_list_check_ppm>
736 _notExplicitlyEvictedList(bufferPool->getBlockCount()) {};
750 static thread_local
bool currentlyCheckingRetryList;
751 static thread_local
size_t retriedBufferIndexes;
755 if (!currentlyCheckingRetryList) {
756 if (retriedBufferIndexes < static_cast<bf_idx>(_initialListCheck * _initialList.size())
757 || _retryList.empty()) {
758 _initialList.pop(selected);
759 retriedBufferIndexes++;
760 if (_notExplicitlyEvictedList[selected].test_and_set()) {
766 _retryList.pop(selected);
767 if (_notExplicitlyEvictedList[selected].test_and_set()) {
768 retriedBufferIndexes = 0;
769 currentlyCheckingRetryList =
true;
777 if (retriedBufferIndexes < static_cast<bf_idx>(_retryListCheck * _retryList.size())
778 || _initialList.empty()) {
779 _retryList.pop(selected);
780 retriedBufferIndexes++;
781 if (_notExplicitlyEvictedList[selected].test_and_set()) {
787 _initialList.pop(selected);
788 if (_notExplicitlyEvictedList[selected].test_and_set()) {
789 retriedBufferIndexes = 0;
790 currentlyCheckingRetryList =
false;
828 _notExplicitlyEvictedList[idx].test_and_set();
829 _initialList.push(idx);
840 _retryList.push(idx);
851 _retryList.push(idx);
862 _retryList.push(idx);
873 _retryList.push(idx);
887 _notExplicitlyEvictedList[idx].clear();
940 static constexpr
double _retryListCheck = retry_list_check_ppm * 0.000001;
946 static constexpr
double _initialListCheck = initial_list_check_ppm * 0.000001;
968 _lruList(bufferPool->getBlockCount()) {};
982 _lruList.popFromFront(selected);
993 std::lock_guard<std::recursive_mutex> lock(_lruListLock);
994 _lruList.remove(idx);
995 _lruList.pushToBack(idx);
1005 std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1006 _lruList.remove(idx);
1007 _lruList.pushToBack(idx);
1025 _lruListLock.lock();
1026 _lruList.pushToBack(idx);
1027 _lruListLock.unlock();
1028 _lruListLock.unlock();
1045 _lruList.pushToBack(idx);
1046 _lruListLock.unlock();
1063 _lruList.pushToBack(idx);
1064 _lruListLock.unlock();
1081 _lruList.pushToBack(idx);
1082 _lruListLock.unlock();
1099 _lruList.pushToBack(idx);
1100 _lruListLock.unlock();
1117 _lruListLock.lock();
1119 _lruList.remove(idx);
1121 _lruListLock.unlock();
1122 _lruListLock.unlock();
1150 _lruListLock.unlock();
1177 template<
bf_idx protected_block_ppm>
1187 _protectedBlockCount(static_cast<
bf_idx>(protected_block_ppm * 0.000001 * bufferPool->getBlockCount())),
1188 _protectedLRUList(_protectedBlockCount),
1189 _probationaryLRUList(bufferPool->getBlockCount()) {};
1202 _lruListLock.lock();
1203 _probationaryLRUList.popFromFront(selected);
1216 std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1218 _protectedLRUList.remove(idx);
1220 _probationaryLRUList.remove(idx);
1222 if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1224 _protectedLRUList.popFromFront(downgradeIndex);
1225 _probationaryLRUList.pushToBack(downgradeIndex);
1227 _protectedLRUList.pushToBack(idx);
1254 _lruListLock.lock();
1255 _probationaryLRUList.pushToBack(idx);
1256 _lruListLock.unlock();
1257 _lruListLock.unlock();
1276 if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1278 _protectedLRUList.popFromFront(downgradeIndex);
1279 _probationaryLRUList.pushToBack(downgradeIndex);
1281 _protectedLRUList.pushToBack(idx);
1282 _lruListLock.unlock();
1301 if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1303 _protectedLRUList.popFromFront(downgradeIndex);
1304 _probationaryLRUList.pushToBack(downgradeIndex);
1306 _protectedLRUList.pushToBack(idx);
1307 _lruListLock.unlock();
1326 if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1328 _protectedLRUList.popFromFront(downgradeIndex);
1329 _probationaryLRUList.pushToBack(downgradeIndex);
1331 _protectedLRUList.pushToBack(idx);
1332 _lruListLock.unlock();
1351 if (_protectedLRUList.length() >= _protectedBlockCount - 1) {
1353 _protectedLRUList.popFromFront(downgradeIndex);
1354 _probationaryLRUList.pushToBack(downgradeIndex);
1356 _protectedLRUList.pushToBack(idx);
1357 _lruListLock.unlock();
1374 std::lock_guard<std::recursive_mutex> lock(_lruListLock);
1376 _protectedLRUList.remove(idx);
1379 _probationaryLRUList.remove(idx);
1382 _lruListLock.unlock();
1383 _lruListLock.unlock();
1411 _lruListLock.unlock();
1449 template<
size_t k,
bool on_page_unfix>
1459 _lruList(k * bufferPool->getBlockCount()),
1460 _frameReferences(bufferPool->getBlockCount(), 0),
1461 _leastRecentlyUsedFinite(0) {};
1472 _lruListLock.lock();
1473 selected = _popFromFront();
1474 return static_cast<bf_idx>(selected / k);
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();
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();
1526 _lruListLock.lock();
1527 _frameReferences[idx] = 0;
1528 for (
size_t i = 0; i < k; i++) {
1530 _remove(static_cast<uint64_t>((i % k) + k * idx));
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));
1541 for (
size_t i = 2; i < k; i++) {
1542 uint64_t ref =
static_cast<uint64_t
>((_frameReferences[idx]++ % k) + k * idx);
1544 _lruList.insertBefore(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx),
1547 _lruList.pushToBack(static_cast<uint64_t>((_frameReferences[idx] % k) + k * idx));
1551 _frameReferences[idx]++;
1553 _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1554 _lruListLock.unlock();
1555 _lruListLock.unlock();
1569 _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1570 _lruListLock.unlock();
1584 _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1585 _lruListLock.unlock();
1599 _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1600 _lruListLock.unlock();
1614 _pushToBack(static_cast<uint64_t>((_frameReferences[idx]++ % k) + k * idx));
1615 _lruListLock.unlock();
1629 _lruListLock.lock();
1630 _frameReferences[idx] = 0;
1631 for (
size_t i; i < k; i++) {
1633 _remove(static_cast<uint64_t>((i % k) + k * idx));
1636 _lruListLock.unlock();
1637 _lruListLock.unlock();
1665 _lruListLock.unlock();
1688 if (_leastRecentlyUsedFinite == 0) {
1689 _leastRecentlyUsedFinite = key;
1695 uint64_t front = _lruList.
getFront();
1701 if (key == _leastRecentlyUsedFinite) {
1703 _leastRecentlyUsedFinite = _lruList.
getAfter(key);
1705 _leastRecentlyUsedFinite = 0;
1736 template<uint32_t retry_list_check_ppm, uint32_t mru_list_check_ppm>
1746 _mruList(bufferPool->getBlockCount()) {};
1761 static thread_local
bool currentlyCheckingRetryList;
1762 static thread_local
size_t retriedBufferIndexes;
1765 if (currentlyCheckingRetryList) {
1766 if (retriedBufferIndexes < static_cast<bf_idx>(retry_list_check_ppm * 0.000001 * _retryList.length())
1767 || _mruList.length() == 0) {
1768 _mruListLock.lock();
1769 _retryList.popFromFront(selected);
1770 retriedBufferIndexes++;
1773 _mruListLock.lock();
1774 _mruList.popFromFront(selected);
1775 retriedBufferIndexes = 0;
1776 currentlyCheckingRetryList =
false;
1780 if (retriedBufferIndexes < static_cast<bf_idx>(mru_list_check_ppm * 0.000001 * _mruList.length())
1781 || _retryList.length() == 0) {
1782 _mruListLock.lock();
1783 _mruList.popFromFront(selected);
1784 retriedBufferIndexes++;
1787 _mruListLock.lock();
1788 _retryList.popFromFront(selected);
1789 retriedBufferIndexes = 0;
1790 currentlyCheckingRetryList =
true;
1812 _mruListLock.lock();
1814 _mruList.remove(idx);
1816 _retryList.remove(idx);
1818 _mruList.pushToFront(idx);
1819 _mruListLock.unlock();
1837 _mruListLock.lock();
1838 _mruList.pushToFront(idx);
1839 _mruListLock.unlock();
1840 _mruListLock.unlock();
1857 _mruListLock.lock();
1858 _retryList.pushToBack(idx);
1859 _mruListLock.unlock();
1860 _mruListLock.unlock();
1877 _mruListLock.lock();
1878 _retryList.pushToBack(idx);
1879 _mruListLock.unlock();
1880 _mruListLock.unlock();
1897 _mruListLock.lock();
1898 _retryList.pushToBack(idx);
1899 _mruListLock.unlock();
1900 _mruListLock.unlock();
1917 _mruListLock.lock();
1918 _retryList.pushToBack(idx);
1919 _mruListLock.unlock();
1920 _mruListLock.unlock();
1937 _mruListLock.lock();
1939 _mruList.remove(idx);
1942 _retryList.remove(idx);
1945 _mruListLock.unlock();
1946 _mruListLock.unlock();
1974 _mruListLock.unlock();
2010 template<
bf_idx resort_threshold_ppm>
2020 _timestampsLive(bufferPool->getBlockCount()),
2021 _lruList0(bufferPool->getBlockCount()),
2022 _lruList1(bufferPool->getBlockCount()),
2024 _useLRUList0(false),
2025 _useLRUList1(false) {
2026 _sortingInProgress.clear();
2045 if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (
_maxBufferpoolIndex - 1))
2046 && !_sortingInProgress.test_and_set()) {
2047 _waitForSorted.lock();
2049 _useLRUList1 =
true;
2051 _waitForSorted.unlock();
2052 _useLRUList0 =
false;
2053 _sortingInProgress.clear();
2056 bf_idx checkThis = ++_lastChecked;
2058 _waitForSorted.lock();
2059 _waitForSorted.unlock();
2062 if (std::get<1>(_lruList0[checkThis])
2063 == _timestampsLive[std::get<0>(_lruList0[checkThis])]) {
2064 return std::get<0>(_lruList0[checkThis]);
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();
2075 _useLRUList0 =
true;
2077 _waitForSorted.unlock();
2078 _useLRUList1 =
false;
2079 _sortingInProgress.clear();
2082 bf_idx checkThis = ++_lastChecked;
2084 _waitForSorted.lock();
2085 _waitForSorted.unlock();
2088 if (std::get<1>(_lruList1[checkThis])
2089 == _timestampsLive[std::get<0>(_lruList1[checkThis])]) {
2090 return std::get<0>(_lruList1[checkThis]);
2096 }
else if (!_sortingInProgress.test_and_set()) {
2097 _waitForSorted.lock();
2099 _useLRUList0 =
true;
2101 _waitForSorted.unlock();
2102 _useLRUList1 =
false;
2103 _sortingInProgress.clear();
2105 _waitForSorted.lock();
2106 _waitForSorted.unlock();
2119 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2129 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2141 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2152 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2163 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2175 _timestampsLive[idx]
2187 _timestampsLive[idx] = std::chrono::steady_clock::now().time_since_epoch().count();
2233 std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>
_lruList0;
2241 std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>
_lruList1;
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());
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);
2291 std::cout <<
"0: " << std::get<0>(into[0]) <<
"; " 2309 template<
size_t k,
bf_idx resort_threshold_ppm,
bool on_page_unfix>
2319 _timestampsLiveOldestTimestamp(bufferPool->getBlockCount()),
2320 _timestampsLive(bufferPool->getBlockCount()),
2321 _lruList0(bufferPool->getBlockCount()),
2322 _lruList1(bufferPool->getBlockCount()),
2324 _useLRUList0(false),
2325 _useLRUList1(false),
2327 _sortingInProgress.clear();
2347 if (_lastChecked > static_cast<bf_idx>(resort_threshold_ppm * 0.000001 * (
_maxBufferpoolIndex - 1))
2348 && !_sortingInProgress.test_and_set()) {
2349 _waitForSorted.lock();
2351 _useLRUList1 =
true;
2353 _waitForSorted.unlock();
2354 _useLRUList0 =
false;
2355 _sortingInProgress.clear();
2358 bf_idx checkThis = ++_lastChecked;
2360 _waitForSorted.lock();
2361 _waitForSorted.unlock();
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]);
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();
2379 _useLRUList0 =
true;
2381 _waitForSorted.unlock();
2382 _useLRUList1 =
false;
2383 _sortingInProgress.clear();
2386 bf_idx checkThis = ++_lastChecked;
2388 _waitForSorted.lock();
2389 _waitForSorted.unlock();
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]);
2402 }
else if (!_sortingInProgress.test_and_set()) {
2403 _waitForSorted.lock();
2405 _useLRUList0 =
true;
2407 _waitForSorted.unlock();
2408 _useLRUList1 =
false;
2409 _sortingInProgress.clear();
2412 _waitForSorted.lock();
2413 _waitForSorted.unlock();
2428 if constexpr (!on_page_unfix) {
2429 _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2430 = std::chrono::steady_clock::now().time_since_epoch().count();
2443 if constexpr (on_page_unfix) {
2444 _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2445 = std::chrono::steady_clock::now().time_since_epoch().count();
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++;
2474 _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2475 = std::chrono::steady_clock::now().time_since_epoch().count();
2487 _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2488 = std::chrono::steady_clock::now().time_since_epoch().count();
2500 for (
size_t i = 0; i < k; i++) {
2501 _timestampsLive[idx][i]
2515 _timestampsLive[idx][_timestampsLiveOldestTimestamp[idx]++ % k]
2516 = std::chrono::steady_clock::now().time_since_epoch().count();
2528 for (
size_t i = 0; i < k; i++) {
2529 _timestampsLive[idx][i]
2530 = std::chrono::steady_clock::now().time_since_epoch().count();
2566 std::vector<std::array<std::atomic<std::chrono::steady_clock::duration::rep>, k>>
_timestampsLive;
2574 std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>
_lruList0;
2582 std::vector<std::tuple<bf_idx, std::chrono::steady_clock::duration::rep>>
_lruList1;
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());
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);
2653 _frameReferences(bufferPool->getBlockCount()),
2654 _frameAlreadySelected(bufferPool->getBlockCount()) {};
2670 if (_frameReferences[index] < minReferences) {
2671 if (!_frameAlreadySelected[index].test_and_set()) {
2672 _frameAlreadySelected[minIndex].clear();
2674 minReferences = _frameReferences[index];
2679 if (_frameReferences[minIndex] != minReferences) {
2680 _frameAlreadySelected[minIndex].clear();
2696 _frameReferences[idx]++;
2716 _frameReferences[idx] = 1;
2717 _frameAlreadySelected[idx].clear();
2729 _frameReferences[idx]++;
2730 _frameAlreadySelected[idx].clear();
2742 _frameReferences[idx]++;
2743 _frameAlreadySelected[idx].clear();
2766 _frameReferences[idx]++;
2767 _frameAlreadySelected[idx].clear();
2781 _frameAlreadySelected[idx].test_and_set();
2834 _frameReferences(bufferPool->getBlockCount()),
2835 _inflationFactor(1),
2836 _frameAlreadySelected(bufferPool->getBlockCount()) {};
2852 if (_frameReferences[index] < minReferences) {
2853 if (!_frameAlreadySelected[index].test_and_set()) {
2854 _frameAlreadySelected[minIndex].clear();
2856 minReferences = _frameReferences[index];
2861 if (_frameReferences[minIndex] != minReferences) {
2862 _frameAlreadySelected[minIndex].clear();
2866 _inflationFactor = minReferences;
2879 _frameReferences[idx]++;
2900 _frameReferences[idx] = _inflationFactor.load();
2901 _frameAlreadySelected[idx].clear();
2913 _frameReferences[idx]++;
2914 _frameAlreadySelected[idx].clear();
2926 _frameReferences[idx]++;
2927 _frameAlreadySelected[idx].clear();
2951 _frameReferences[idx]++;
2952 _frameAlreadySelected[idx].clear();
2966 _frameAlreadySelected[idx].test_and_set();
3022 _frameReferences(bufferPool->getBlockCount()),
3023 _frameFirstReferenced(bufferPool->getBlockCount()),
3024 _frameAlreadySelected(bufferPool->getBlockCount()),
3025 _globalReferences(0) {};
3037 uint64_t minLRDReferences;
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]);
3056 if (_frameReferences[minLRDIndex] != minLRDReferences) {
3057 _frameAlreadySelected[minLRDIndex].clear();
3074 _globalReferences++;
3075 _frameReferences[idx]++;
3099 _frameFirstReferenced[idx] = _globalReferences++;
3100 _frameReferences[idx] = 1;
3101 _frameAlreadySelected[idx].clear();
3113 _frameReferences[idx]++;
3114 _frameAlreadySelected[idx].clear();
3126 _frameReferences[idx]++;
3127 _frameAlreadySelected[idx].clear();
3139 _frameReferences[idx] = _globalReferences.load();
3151 _frameReferences[idx]++;
3152 _frameAlreadySelected[idx].clear();
3164 _frameFirstReferenced[idx] = 0;
3165 _frameReferences[idx] = 0;
3166 _frameAlreadySelected[idx].test_and_set();
3208 virtual void operator()(std::atomic<uint64_t>& referenceCount) noexcept = 0;
3211 template<uint64_t subtrahend>
3213 inline void operator()(std::atomic<uint64_t>& referenceCount) noexcept
final {
3214 if (referenceCount > subtrahend) {
3215 referenceCount -= subtrahend;
3222 template<uint64_t factor_ppm>
3224 inline void operator()(std::atomic<uint64_t>& referenceCount) noexcept
final {
3225 referenceCount =
static_cast<uint64_t
>(factor_ppm * 0.000001 * referenceCount);
3244 template<uint64_t aging_frequency,
class aging_function>
3246 static_assert(std::is_base_of<AgingFunction, aging_function>::value,
3247 "'selector_class' is not of type 'AgingFunction'!");
3257 _frameReferences(bufferPool->getBlockCount()),
3258 _frameFirstReferenced(bufferPool->getBlockCount()),
3259 _frameAlreadySelected(bufferPool->getBlockCount()),
3260 _globalReferences(0),
3261 _agingFrequency(aging_frequency * bufferPool->getBlockCount()) {};
3273 uint64_t minLRDReferences;
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]);
3292 if (_frameReferences[minLRDIndex] != minLRDReferences) {
3293 _frameAlreadySelected[minLRDIndex].clear();
3312 _frameReferences[idx]++;
3313 if (_globalReferences++ % _agingFrequency == 0) {
3314 std::for_each(_frameReferences.begin(), _frameReferences.end(),
3315 [
this](std::atomic<uint64_t>& referenceCount) {
3316 _agingFunction(referenceCount);
3343 _frameFirstReferenced[idx] = _globalReferences++;
3344 if (_frameFirstReferenced[idx] % _agingFrequency == 0) {
3345 std::for_each(_frameReferences.begin(), _frameReferences.end(),
3346 [
this](std::atomic<uint64_t>& referenceCount) {
3347 _agingFunction(referenceCount);
3350 _frameReferences[idx] = 1;
3351 _frameAlreadySelected[idx].clear();
3363 _frameReferences[idx]++;
3364 _frameAlreadySelected[idx].clear();
3376 _frameReferences[idx]++;
3377 _frameAlreadySelected[idx].clear();
3389 _frameReferences[idx] = _globalReferences.load();
3401 _frameReferences[idx]++;
3402 _frameAlreadySelected[idx].clear();
3414 _frameFirstReferenced[idx] = 0;
3415 _frameReferences[idx] = 0;
3416 _frameAlreadySelected[idx].test_and_set();
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