rocksdb/cache
anand76 2222caec9e Make CacheWithSecondaryAdapter reservation accounting more robust (#12059)
Summary:
`CacheWithSecondaryAdapter` can distribute placeholder reservations across the primary and secondary caches. The current implementation of the accounting is quite complicated in order to avoid using a mutex. This may cause the accounting to be slightly off after changes to the cache capacity and ratio, resulting in assertion failures. There's also a bug in the unlikely event that the total reservation exceeds the cache capacity. Furthermore, the current implementation is difficult to reason about.

This PR simplifies it by doing the accounting while holding a mutex. The reservations are processed in 1MB chunks in order to avoid taking a lock too frequently. As a side effect, this also removes the restriction of not allowing to increase the compressed secondary cache capacity after decreasing it to 0.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12059

Test Plan: Existing unit tests, and a new test for capacity increase from 0

Reviewed By: pdillinger

Differential Revision: D51278686

Pulled By: anand1976

fbshipit-source-id: 7e1ad2c50694772997072dd59cab35c93c12ba4f
2023-11-14 16:25:52 -08:00
..
cache.cc
cache_bench.cc
cache_bench_tool.cc AutoHCC: fix a bug with "blind" Insert (#12046) 2023-11-06 16:06:01 -08:00
cache_entry_roles.cc
cache_entry_roles.h
cache_entry_stats.h
cache_helpers.cc
cache_helpers.h
cache_key.cc
cache_key.h
cache_reservation_manager.cc
cache_reservation_manager.h
cache_reservation_manager_test.cc
cache_test.cc
charged_cache.cc
charged_cache.h
clock_cache.cc Safer wrapper for std::atomic, use in HCC (#12051) 2023-11-08 13:28:43 -08:00
clock_cache.h Safer wrapper for std::atomic, use in HCC (#12051) 2023-11-08 13:28:43 -08:00
compressed_secondary_cache.cc
compressed_secondary_cache.h
compressed_secondary_cache_test.cc Make CacheWithSecondaryAdapter reservation accounting more robust (#12059) 2023-11-14 16:25:52 -08:00
lru_cache.cc
lru_cache.h
lru_cache_test.cc
secondary_cache.cc
secondary_cache_adapter.cc Make CacheWithSecondaryAdapter reservation accounting more robust (#12059) 2023-11-14 16:25:52 -08:00
secondary_cache_adapter.h Make CacheWithSecondaryAdapter reservation accounting more robust (#12059) 2023-11-14 16:25:52 -08:00
sharded_cache.cc Add APIs to query secondary cache capacity and usage for TieredCache (#12011) 2023-10-25 16:54:50 -07:00
sharded_cache.h Add APIs to query secondary cache capacity and usage for TieredCache (#12011) 2023-10-25 16:54:50 -07:00
tiered_secondary_cache.cc
tiered_secondary_cache.h
tiered_secondary_cache_test.cc
typed_cache.h