Skip to content

Commit

Permalink
Remove enableFastNegativeLookup option from cachelib
Browse files Browse the repository at this point in the history
Summary: fast negative lookup is alway turned on in production. Remove the option to turn it off.

Reviewed By: therealgymmy

Differential Revision: D51477963

fbshipit-source-id: 2159e6f4e51d2cf6c4f4688dfafe0af701133f61
  • Loading branch information
Hao Wu authored and facebook-github-bot committed Dec 8, 2023
1 parent 2b39f38 commit dfe0af8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
11 changes: 5 additions & 6 deletions cachelib/allocator/nvmcache/NvmCache-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ typename NvmCache<C>::WriteHandle NvmCache<C>::find(HashedKey hk) {
// For concurrent put, if it is already enqueued, its put context already
// exists. If it is not enqueued yet (in-flight) the above invalidateToken
// will prevent the put from being enqueued.
if (config_.enableFastNegativeLookups && it == fillMap.end() &&
!putContexts_[shard].hasContexts() && !navyCache_->couldExist(hk)) {
if (it == fillMap.end() && !putContexts_[shard].hasContexts() &&
!navyCache_->couldExist(hk)) {
stats().numNvmGetMiss.inc();
stats().numNvmGetMissFast.inc();
return WriteHandle{};
Expand Down Expand Up @@ -234,8 +234,8 @@ bool NvmCache<C>::couldExistFast(HashedKey hk) {
// For concurrent put, if it is already enqueued, its put context already
// exists. If it is not enqueued yet (in-flight) the above invalidateToken
// will prevent the put from being enqueued.
if (config_.enableFastNegativeLookups && it == fillMap.end() &&
!putContexts_[shard].hasContexts() && !navyCache_->couldExist(hk)) {
if (it == fillMap.end() && !putContexts_[shard].hasContexts() &&
!navyCache_->couldExist(hk)) {
return false;
}

Expand Down Expand Up @@ -813,8 +813,7 @@ void NvmCache<C>::remove(HashedKey hk, DeleteTombStoneGuard tombstone) {
// (in-flight puts) before we check for couldExist. Any put contexts
// created after couldExist api returns does not matter, since the put
// token is invalidated before all of this begins.
if (config_.enableFastNegativeLookups && !putContexts_[shard].hasContexts() &&
!navyCache_->couldExist(hk)) {
if (!putContexts_[shard].hasContexts() && !navyCache_->couldExist(hk)) {
stats().numNvmSkippedDeletes.inc();
return;
}
Expand Down
4 changes: 0 additions & 4 deletions cachelib/allocator/nvmcache/NvmCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ class NvmCache {
// If true, only store the orignal size the user requested.
bool truncateItemToOriginalAllocSizeInNvm{false};

// when enabled, nvmcache will attempt to resolve misses without incurring
// thread hops by using synchronous methods.
bool enableFastNegativeLookups{true};

// serialize the config for debugging purposes
std::map<std::string, std::string> serialize() const;

Expand Down
1 change: 0 additions & 1 deletion cachelib/allocator/nvmcache/tests/NvmCacheTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ TEST_F(NvmCacheTest, BasicGet) {

TEST_F(NvmCacheTest, CouldExistFast) {
// Enable fast negative lookup
this->allocConfig_.nvmConfig->enableFastNegativeLookups = true;
this->makeCache();

auto& nvm = this->cache();
Expand Down
1 change: 0 additions & 1 deletion website/docs/Cache_Library_User_Guides/CacheLib_configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Configs to initialize NVM cache lives in `CacheAllocatorConfig::nvmConfig` and a
* `setDropNvmCacheOnShmNew`: This flag is used to determine whether the NVM cache would start truncated.
* `enableNvmCacheEncryption`: This sets CacheAllocatorConfig::nvmConfig::deviceEncryptor.
* `enableNvmCacheTruncateAllocSize`: This sets CacheAllocatorConfig::nvmConfig::truncateItemToOriginalAllocSizeInNvm.
* `enableFastNegativeLookups`: This enables/disables the feature to resolve NVM cache misses quickly in the sync path of `find(...)` call without kicking the lookup for NVM cache. This is essential to reduce the overall end-to-end latency, but comes with the penalty of small overhead added in the hit cases for additional accesses to index tables or bloom filters. The default is enabled.
* `setNvmCacheAdmissionPolicy`/`enableRejectFirstAPForNvm`: Sets the NvmAdmissionPolicy. Notice that the field lives with CacheAllocatorConfig.
* `setNvmAdmissionMinTTL`: Sets the NVM admission min TTL. Similarly this lives directly with CacheAllocatorConfig.
* `enableNvmCache`: Sets `CacheAllocatorConfig::nvmConfig` directly. This function should be called first if you intend to turn on NVM cache. And the other functions above would correctly modify the nvmConfig.
Expand Down

0 comments on commit dfe0af8

Please sign in to comment.