1. 28 7月, 2022 1 次提交
    • G
      Fix assertion failure and memory leak in ClockCache. (#10430) · d976f689
      Guido Tagliavini Ponce 提交于
      Summary:
      This fixes two issues:
      - [T127355728](https://www.internalfb.com/intern/tasks/?t=127355728): In the stress tests, when the ClockCache is operating close to full capacity and a burst of inserts are concurrently executed, every slot in the hash table may become occupied. This contradicts an assertion in the code, which is no longer valid in the lock-free setting. We are removing that assertion and handling the case of an insertion into a full table.
      - [T127427659](https://www.internalfb.com/intern/tasks/?t=127427659): There was a memory leak when an insertion is performed over capacity, but no handle is provided. In that case, a handle was dynamically allocated, but the pointer wasn't stored anywhere.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10430
      
      Test Plan:
      - ``make -j24 check``
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_ASAN=1 COMPILE_WITH_UBSAN=1 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache" blackbox_crash_test_with_atomic_flush``
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_TSAN=1 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache" blackbox_crash_test_with_atomic_flush``
      
      Reviewed By: pdillinger
      
      Differential Revision: D38226114
      
      Pulled By: guidotag
      
      fbshipit-source-id: 18f6ab7e6214e11e9721d5ff289db1bf795d0008
      d976f689
  2. 27 7月, 2022 1 次提交
    • G
      Towards a production-quality ClockCache (#10418) · 9d7de651
      Guido Tagliavini Ponce 提交于
      Summary:
      In this PR we bring ClockCache closer to production quality. We implement the following changes:
      1. Fixed a few bugs in ClockCache.
      2. ClockCache now fully supports ``strict_capacity_limit == false``: When an insertion over capacity is commanded, we allocate a handle separately from the hash table.
      3. ClockCache now runs on almost every test in cache_test. The only exceptions are a test where either the LRU policy is required, and a test that dynamically increases the table capacity.
      4. ClockCache now supports dynamically decreasing capacity via SetCapacity. (This is easy: we shrink the capacity upper bound and run the clock algorithm.)
      5. Old FastLRUCache tests in lru_cache_test.cc are now also used on ClockCache.
      
      As a byproduct of 1. and 2. we are able to turn on ClockCache in the stress tests.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10418
      
      Test Plan:
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_ASAN=1 COMPILE_WITH_UBSAN=1 check``
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_TSAN=1 check``
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_ASAN=1 COMPILE_WITH_UBSAN=1 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache" blackbox_crash_test_with_atomic_flush``
      - ``make -j24 USE_CLANG=1 COMPILE_WITH_TSAN=1 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache" blackbox_crash_test_with_atomic_flush``
      
      Reviewed By: pdillinger
      
      Differential Revision: D38170673
      
      Pulled By: guidotag
      
      fbshipit-source-id: 508987b9dc9d9d68f1a03eefac769820b680340a
      9d7de651
  3. 26 7月, 2022 1 次提交
    • G
      Lock-free ClockCache (#10390) · 6a160e1f
      Guido Tagliavini Ponce 提交于
      Summary:
      ClockCache completely free of locks. As part of this PR we have also pushed clock algorithm functionality out of ClockCacheShard into ClockHandleTable, so that ClockCacheShard acts more as an interface and less as an actual data structure.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10390
      
      Test Plan:
      - ``make -j24 check``
      - ``make -j24 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache --cache_size=1073741824 --block_size=16384" blackbox_crash_test_with_atomic_flush``
      
      Reviewed By: pdillinger
      
      Differential Revision: D38106945
      
      Pulled By: guidotag
      
      fbshipit-source-id: 6cbf6bd2397dc9f582809ccff5118a8a33ea6cb1
      6a160e1f
  4. 16 7月, 2022 1 次提交
    • G
      Lock-free Lookup and Release in ClockCache (#10347) · efdb428e
      Guido Tagliavini Ponce 提交于
      Summary:
      This is a prototype of a partially lock-free version of ClockCache. Roughly speaking, reads are lock-free and writes are lock-based:
      - Lookup is lock-free.
      - Release is lock-free, unless (i) no references to the element are left and (ii) it was marked for deletion or ``erase_if_last_ref`` is set.
      - Insert and Erase still use a per-shard lock.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10347
      
      Test Plan:
      - ``make -j24 check``
      - ``make -j24 CRASH_TEST_EXT_ARGS="--duration=960 --cache_type=clock_cache --cache_size=1073741824 --block_size=16384" blackbox_crash_test_with_atomic_flush``
      
      Reviewed By: pdillinger
      
      Differential Revision: D37898776
      
      Pulled By: guidotag
      
      fbshipit-source-id: 6418fd980f786d69b871bf2fe959398e44cd3d80
      efdb428e
  5. 13 7月, 2022 1 次提交
    • G
      Temporarily return a LRUCache from NewClockCache (#10351) · 9645e66f
      Guido Tagliavini Ponce 提交于
      Summary:
      ClockCache is still in experimental stage, and currently fails some pre-release fbcode tests. See https://www.internalfb.com/diff/D37772011. API calls to construct ClockCache are done via the function NewClockCache. For now, NewClockCache calls will return an LRUCache (with appropriate arguments), which is stable.
      
      The idea that NewClockCache returns nullptr was also floated, but this would be interpreted as unsupported cache, and a default LRUCache would be constructed instead, potentially causing a performance regression that is harder to identify.
      
      A new version of the NewClockCache function was created for our internal tests.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10351
      
      Test Plan: ``make -j24 check`` and re-run the pre-release tests.
      
      Reviewed By: pdillinger
      
      Differential Revision: D37802685
      
      Pulled By: guidotag
      
      fbshipit-source-id: 0a8d10612ff21e576f7360cb13e20bc36e244972
      9645e66f
  6. 07 7月, 2022 1 次提交
    • G
      Midpoint insertions in ClockCache (#10305) · c277aeb4
      Guido Tagliavini Ponce 提交于
      Summary:
      When an element is first inserted into the ClockCache, it is now assigned either medium or high clock priority, depending on whether its cache priority is low or high, respectively. This is a variant of LRUCache's midpoint insertions. The main difference is that LRUCache can specify the allocated capacity for high-priority elements via the ``high_pri_pool_ratio`` parameter. Contrarily, in ClockCache, low- and high-priority elements compete for all cache slots, and one group can take over the other (of course, it takes more low-priority insertions to push out high-priority elements). However, just as LRUCache, ClockCache provides the following guarantee: a high-priority element will not be evicted before a low-priority element that was inserted earlier in time.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10305
      
      Test Plan: ``make -j24 check``
      
      Reviewed By: pdillinger
      
      Differential Revision: D37607787
      
      Pulled By: guidotag
      
      fbshipit-source-id: 24d9f2523d2f4e6415e7f0029cc061fa275c2040
      c277aeb4
  7. 30 6月, 2022 1 次提交
    • G
      Clock cache (#10273) · 57a0e2f3
      Guido Tagliavini Ponce 提交于
      Summary:
      This is the initial step in the development of a lock-free clock cache. This PR includes the base hash table design (which we mostly ported over from FastLRUCache) and the clock eviction algorithm. Importantly, it's still _not_ lock-free---all operations use a shard lock. Besides the locking, there are other features left as future work:
      - Remove keys from the handles. Instead, use 128-bit bijective hashes of them for handle comparisons, probing (we need two 32-bit hashes of the key for double hashing) and sharding (we need one 6-bit hash).
      - Remove the clock_usage_ field, which is updated on every lookup. Even if it were atomically updated, it could cause memory invalidations across cores.
      - Middle insertions into the clock list.
      - A test that exercises the clock eviction policy.
      - Update the Java API of ClockCache and Java calls to C++.
      
      Along the way, we improved the code and comments quality of FastLRUCache. These changes are relatively minor.
      
      Pull Request resolved: https://github.com/facebook/rocksdb/pull/10273
      
      Test Plan: ``make -j24 check``
      
      Reviewed By: pdillinger
      
      Differential Revision: D37522461
      
      Pulled By: guidotag
      
      fbshipit-source-id: 3d70b737dbb70dcf662f00cef8c609750f083943
      57a0e2f3
  8. 16 7月, 2017 1 次提交
  9. 06 4月, 2017 1 次提交
  10. 20 8月, 2016 1 次提交
    • Y
      Introduce ClockCache · 4cc37f59
      Yi Wu 提交于
      Summary:
      Clock-based cache implemenetation aim to have better concurreny than
      default LRU cache. See inline comments for implementation details.
      
      Test Plan:
      Update cache_test to run on both LRUCache and ClockCache. Adding some
      new tests to catch some of the bugs that I fixed while implementing the
      cache.
      
      Reviewers: kradhakrishnan, sdong
      
      Reviewed By: sdong
      
      Subscribers: andrewkr, dhruba, leveldb
      
      Differential Revision: https://reviews.facebook.net/D61647
      4cc37f59
  11. 10 2月, 2016 1 次提交
  12. 14 10月, 2015 1 次提交
    • S
      Seperate InternalIterator from Iterator · 35ad531b
      sdong 提交于
      Summary:
      Separate a new class InternalIterator from class Iterator, when the look-up is done internally, which also means they operate on key with sequence ID and type.
      
      This change will enable potential future optimizations but for now InternalIterator's functions are still the same as Iterator's.
      At the same time, separate the cleanup function to a separate class and let both of InternalIterator and Iterator inherit from it.
      
      Test Plan: Run all existing tests.
      
      Reviewers: igor, yhchiang, anthony, kradhakrishnan, IslamAbdelRahman, rven
      
      Reviewed By: rven
      
      Subscribers: leveldb, dhruba
      
      Differential Revision: https://reviews.facebook.net/D48549
      35ad531b
  13. 05 9月, 2014 1 次提交