From 5961b801cc9f9fcabd1c59463b0343a256b78973 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Tue, 5 Apr 2022 15:11:07 -0700 Subject: [PATCH] Keep decode caches in page cache based on page height minimum set by a knob with a default value of 2. --- fdbclient/ServerKnobs.cpp | 1 + fdbclient/ServerKnobs.h | 1 + fdbserver/VersionedBTree.actor.cpp | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fdbclient/ServerKnobs.cpp b/fdbclient/ServerKnobs.cpp index ba31b697ea..95dda135b2 100644 --- a/fdbclient/ServerKnobs.cpp +++ b/fdbclient/ServerKnobs.cpp @@ -823,6 +823,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi init( REDWOOD_METRICS_INTERVAL, 5.0 ); init( REDWOOD_HISTOGRAM_INTERVAL, 30.0 ); init( REDWOOD_EVICT_UPDATED_PAGES, true ); if( randomize && BUGGIFY ) { REDWOOD_EVICT_UPDATED_PAGES = false; } + init( REDWOOD_DECODECACHE_REUSE_MIN_HEIGHT, 2 ); if( randomize && BUGGIFY ) { REDWOOD_DECODECACHE_REUSE_MIN_HEIGHT = deterministicRandom()->randomInt(1, 7); } // Server request latency measurement init( LATENCY_SAMPLE_SIZE, 100000 ); diff --git a/fdbclient/ServerKnobs.h b/fdbclient/ServerKnobs.h index 5f88a9975c..def87b06cd 100644 --- a/fdbclient/ServerKnobs.h +++ b/fdbclient/ServerKnobs.h @@ -777,6 +777,7 @@ public: double REDWOOD_METRICS_INTERVAL; double REDWOOD_HISTOGRAM_INTERVAL; bool REDWOOD_EVICT_UPDATED_PAGES; // Whether to prioritize eviction of updated pages from cache. + int REDWOOD_DECODECACHE_REUSE_MIN_HEIGHT; // Minimum height for which to keep and reuse page decode caches // Server request latency measurement int LATENCY_SAMPLE_SIZE; diff --git a/fdbserver/VersionedBTree.actor.cpp b/fdbserver/VersionedBTree.actor.cpp index 256b0a4100..2bad4c2ac3 100644 --- a/fdbserver/VersionedBTree.actor.cpp +++ b/fdbserver/VersionedBTree.actor.cpp @@ -6053,8 +6053,15 @@ private: inline BTreePage::BinaryTree::Cursor getCursor(const ArenaPage* page, const RedwoodRecordRef& lowerBound, const RedwoodRecordRef& upperBound) { - if (!page->extra.valid()) { - debug_printf("Creating DecodeCache for ptr=%p lower=%s upper=%s %s\n", + + Reference cache; + + if (page->extra.valid()) { + cache = page->extra.getReference(); + } else { + cache = makeReference(lowerBound, upperBound, m_pDecodeCacheMemory); + + debug_printf("Created DecodeCache for ptr=%p lower=%s upper=%s %s\n", page->data(), lowerBound.toString(false).c_str(), upperBound.toString(false).c_str(), @@ -6066,12 +6073,13 @@ private: upperBound) .c_str()); - page->extra = - makeReference(lowerBound, upperBound, m_pDecodeCacheMemory); + // Store decode cache into page based on height + if (((BTreePage*)page->data())->height >= SERVER_KNOBS->REDWOOD_DECODECACHE_REUSE_MIN_HEIGHT) { + page->extra = cache; + } } - return BTreePage::BinaryTree::Cursor(page->extra.getReference(), - ((BTreePage*)page->mutateData())->tree()); + return BTreePage::BinaryTree::Cursor(cache, ((BTreePage*)page->mutateData())->tree()); } // Get cursor into a BTree node from a child link