facebook/CacheLib

Fail to persist nvm cache due to "exceeding metadata limit"

waterxjw opened this issue · 1 comments

I want to enable a persistent cache by following the wiki.
Meanwhile, I enable the NVM cache.
when I shutdown the cache, it seems that nvm cache shut down failed.

I1021 02:28:38.815955 57910 BlockCache.cpp:678] Flush block cache
I1021 02:28:38.823921 57910 BlockCache.cpp:769] Starting block cache persist
E1021 02:29:21.929277 57910 NvmCache-inl.h:883] Got error persisting cache: exceeding metadata limit
E1021 02:29:21.929424 57910 CacheAllocator-inl.h:3545] Could not shutdown nvmcache cleanly

it seems the reason is that "device metadata size" is not enough.
but i am confused about how to set "device metadata size" properly.
i don't find useful information about it in document.
i note the default size is set by following code

  auto getDefaultMetadataSize = [](size_t size, size_t alignment) {
    XDCHECK(folly::isPowTwo(alignment));
    auto mask = ~(alignment - 1);
    return (static_cast<size_t>(kDefaultMetadataPercent * size / 100) & mask);
  };

why the default size is not enough? and i want to know the appropriate value

Hi @waterxjw

The required metadata size can vary depending on the state of the NVM cache (e.g., the number of BlockCache items). There is no good estimate for that; e.g., the space needed for BlockCache index table is proportional to the number of keys and the sum of key sizes for all items.

I suggest to start from setting it big enough (i.e., using setDeviceMetadataSize(...)), so you can have a good estimate for your use case to find the best size.