rocksdb/cache
Peter Dillinger b1b6f87fbe Some small improvements to HyperClockCache (#11601)
Summary:
Stacked on https://github.com/facebook/rocksdb/issues/11572
* Minimize use of std::function and lambdas to minimize chances of
compiler heap-allocating closures (unnecessary stress on allocator). It
appears that converting FindSlot to a template enables inlining the
lambda parameters, avoiding heap allocations.
* Clean up some logic with FindSlot (FIXMEs from https://github.com/facebook/rocksdb/issues/11572)
* Fix handling of rare case of probing all slots, with new unit test.
(Previously Insert would not roll back displacements in that case, which
would kill performance if it were to happen.)
* Add an -early_exit option to cache_bench for gathering memory stats
before deallocation.

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

Test Plan:
unit test added for probing all slots

## Seeing heap allocations
Run `MALLOC_CONF="stats_print:true" ./cache_bench -cache_type=hyper_clock_cache`
before https://github.com/facebook/rocksdb/issues/11572 vs. after this change. Before, we see this in the
interesting bin statistics:

```
size  nrequests
----  ---------
  32     578460
  64      24340
8192     578460
```
And after:
```
size  nrequests
----  ---------
  32  (insignificant)
  64      24370
8192     579130
```

## Performance test
Build with `make USE_CLANG=1 PORTABLE=0 DEBUG_LEVEL=0 -j32 cache_bench`

Run `./cache_bench -cache_type=hyper_clock_cache -ops_per_thread=5000000`
in before and after configurations, simultaneously:

```
Before: Complete in 33.244 s; Rough parallel ops/sec = 2406442
After:  Complete in 32.773 s; Rough parallel ops/sec = 2441019
```

Reviewed By: jowlyzhang

Differential Revision: D47375092

Pulled By: pdillinger

fbshipit-source-id: 46f0f57257ddb374290a0a38c651764ea60ba410
2023-07-14 16:19:22 -07:00
..
cache.cc HyperClockCache support for SecondaryCache, with refactoring (#11301) 2023-03-17 20:23:49 -07:00
cache_bench.cc Add (& fix) some simple source code checks (#8821) 2021-09-07 21:19:27 -07:00
cache_bench_tool.cc Some small improvements to HyperClockCache (#11601) 2023-07-14 16:19:22 -07:00
cache_entry_roles.cc Major Cache refactoring, CPU efficiency improvement (#10975) 2023-01-11 14:20:40 -08:00
cache_entry_roles.h Major Cache refactoring, CPU efficiency improvement (#10975) 2023-01-11 14:20:40 -08:00
cache_entry_stats.h Simplify tracking entries already in SecondaryCache (#11299) 2023-03-15 17:51:44 -07:00
cache_helpers.cc Major Cache refactoring, CPU efficiency improvement (#10975) 2023-01-11 14:20:40 -08:00
cache_helpers.h Put Cache and CacheWrapper in new public header (#11192) 2023-02-09 12:12:02 -08:00
cache_key.cc Put Cache and CacheWrapper in new public header (#11192) 2023-02-09 12:12:02 -08:00
cache_key.h Derive cache keys from SST unique IDs (#10394) 2022-08-12 13:49:49 -07:00
cache_reservation_manager.cc Simplify tracking entries already in SecondaryCache (#11299) 2023-03-15 17:51:44 -07:00
cache_reservation_manager.h Major Cache refactoring, CPU efficiency improvement (#10975) 2023-01-11 14:20:40 -08:00
cache_reservation_manager_test.cc Print stack traces on frozen tests in CI (#10828) 2022-10-18 00:35:35 -07:00
cache_test.cc Add hash_seed to Caches (#11391) 2023-05-09 22:24:26 -07:00
charged_cache.cc HyperClockCache support for SecondaryCache, with refactoring (#11301) 2023-03-17 20:23:49 -07:00
charged_cache.h HyperClockCache support for SecondaryCache, with refactoring (#11301) 2023-03-17 20:23:49 -07:00
clock_cache.cc Some small improvements to HyperClockCache (#11601) 2023-07-14 16:19:22 -07:00
clock_cache.h Some small improvements to HyperClockCache (#11601) 2023-07-14 16:19:22 -07:00
compressed_secondary_cache.cc Integrate CacheReservationManager with compressed secondary cache (#11449) 2023-05-30 14:05:48 -07:00
compressed_secondary_cache.h Integrate CacheReservationManager with compressed secondary cache (#11449) 2023-05-30 14:05:48 -07:00
compressed_secondary_cache_test.cc Integrate CacheReservationManager with compressed secondary cache (#11449) 2023-05-30 14:05:48 -07:00
lru_cache.cc Compatibility step for separating BlockCache and GeneralCache APIs (#11450) 2023-05-18 20:40:19 -07:00
lru_cache.h Add hash_seed to Caches (#11391) 2023-05-09 22:24:26 -07:00
lru_cache_test.cc Some small improvements to HyperClockCache (#11601) 2023-07-14 16:19:22 -07:00
secondary_cache.cc Simplify tracking entries already in SecondaryCache (#11299) 2023-03-15 17:51:44 -07:00
secondary_cache_adapter.cc Update secondary_cache_adapter.cc (#11566) 2023-06-27 10:42:42 -07:00
secondary_cache_adapter.h Integrate CacheReservationManager with compressed secondary cache (#11449) 2023-05-30 14:05:48 -07:00
sharded_cache.cc Add hash_seed to Caches (#11391) 2023-05-09 22:24:26 -07:00
sharded_cache.h Add hash_seed to Caches (#11391) 2023-05-09 22:24:26 -07:00
typed_cache.h HyperClockCache support for SecondaryCache, with refactoring (#11301) 2023-03-17 20:23:49 -07:00