Skip to content

HBASE-30363 Migrate AdaptiveLRU to LruCacheEngine and adaptive policy - #8766

Merged
taklwu merged 2 commits into
apache:HBASE-30018from
VladRodionov:HBASE-30363-adaptive-lru-policy
Oct 16, 2026
Merged

taklwu merged 2 commits into
apache:HBASE-30018from
VladRodionov:HBASE-30363-adaptive-lru-policy

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

Summary

Migrates the native CacheAccessService path for AdaptiveLRU from
LruAdaptiveBlockCache to LruCacheEngine plus a dedicated adaptive
placement/admission policy.

The legacy BlockCache construction path remains unchanged.

Changes

  • Add AdaptiveLruCachePlacementAdmissionPolicy.
  • Move AdaptiveLRU admission state and adjustment logic into the policy.
  • Add eviction-pressure feedback to CacheEvictionListener.
  • Add a default eviction-pressure callback to CachePlacementAdmissionPolicy.
  • Have LruCacheEngine report requested eviction pressure (bytesToFree).
  • Have TopologyBackedCacheAccessService route:
    • concrete block evictions to CacheTopology;
    • eviction-pressure feedback to CachePlacementAdmissionPolicy.
  • Use native LruCacheEngine for AdaptiveLRU in the CacheAccessService path.
  • Preserve LruAdaptiveBlockCache for the legacy BlockCacheFactory
    construction path.

AdaptiveLRU behavior

The adaptive algorithm preserves the behavior of the legacy
LruAdaptiveBlockCache, including:

  • the existing AdaptiveLRU configuration properties;
  • the approximately 10-second evaluation window;
  • requested eviction pressure rather than actual bytes freed;
  • heavy-eviction count threshold;
  • adaptive data-block admission percentage;
  • deterministic block-offset filtering;
  • recovery when eviction pressure decreases.

For tiered caches, AdaptiveLRU controls L1 admission only. It does not
globally reject a block that can still be placed in L2.

Tests

Adds coverage for:

  • AdaptiveLRU admission adjustment and recovery;
  • single-tier data-block admission;
  • inclusive and exclusive tier placement;
  • eviction-pressure reporting by LruCacheEngine;
  • eviction-pressure routing through TopologyBackedCacheAccessService;
  • native AdaptiveLRU CacheAccessService construction;
  • preservation of the legacy LruAdaptiveBlockCache construction path.

@taklwu
taklwu requested a balanced review from Copilot October 14, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
What changed in this PR

Migrates AdaptiveLRU in the CacheAccessService path from LruAdaptiveBlockCache to native LruCacheEngine with a dedicated adaptive placement/admission policy, and wires eviction-pressure feedback from engines through topology to the policy.

Changes:

  • Adds AdaptiveLruCachePlacementAdmissionPolicy and routes eviction-pressure callbacks to it via CacheEvictionListener and TopologyBackedCacheAccessService.
  • Updates LruCacheEngine to report “requested eviction pressure” (bytesToFree) to listeners.
  • Adds/updates tests to validate pressure reporting/routing and AdaptiveLRU behavior across topologies and construction paths.
File Description
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​TestTopologyBackedCacheAccessService.java Adds tests ensuring eviction-pressure goes to the policy and block evictions still go to topology.
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​TestLruCacheEngine.java Adds tests for eviction-pressure reporting from LruCacheEngine.
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​TestAdaptiveLruCachePlacementAdmissionPolicy.java Adds unit tests for AdaptiveLRU admission adjustment and topology behaviors.
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​TestCacheConfig.java Adds tests asserting the CacheAccessService path uses LruCacheEngine + adaptive policy, while legacy BlockCache path remains LruAdaptiveBlockCache.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​TopologyBackedCacheAccessService.java Creates tier-bound eviction listeners to route block evictions to topology and pressure to policy.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​LruCacheEngine.java Implements eviction-pressure notification on eviction pass completion.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​CachePlacementAdmissionPolicy.java Adds a default onEvictionPressure(...) callback to the policy interface.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​CacheEvictionListener.java Adds a default onEvictionPressure(...) listener callback and updates documentation.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​CacheAccessServices.java Instantiates the adaptive policy when AdaptiveLRU is configured.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​cache/​AdaptiveLruCachePlacementAdmissionPolicy.java New AdaptiveLRU logic moved into a policy, controlling L1 admission/placement.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​hfile/​BlockCacheFactory.java Switches AdaptiveLRU CacheEngine creation to native LruCacheEngine for the engine-based path.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +631 to +632
}

* @param bytesToFree amount of cache pressure observed, in bytes
*/
@Override
public void onEvictionPressure(CacheEngine sourceEngine, long bytesToFree) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CacheEvictionListener#onEvictionPressure has parameter with sourceEngine that is not being used when creating, but the tier is passing to the policy.onEvictionPressure

why do we have this mis-match ? should we always use CacheEvictionListener with tier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CacheEvictionListener is an engine-level API, so it reports the CacheEngine that generated the event. The engine does not know whether it is used as SINGLE, L1, or L2.
TopologyBackedCacheAccessService knows that mapping, so when it registers the listener it captures the corresponding CacheTier and passes that tier to the policy.
So the mismatch is intentional: engine event in, topology tier out. I would keep CacheEvictionListener independent of CacheTier.

Remove notifyEvictionPressure call when eviction lock is not acquired

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@VladRodionov
VladRodionov force-pushed the HBASE-30363-adaptive-lru-policy branch from 17b8736 to 41dd3f1 Compare October 16, 2026 06:05
@taklwu
taklwu merged commit 4706c90 into apache:HBASE-30018 Oct 16, 2026
7 of 8 checks passed
@VladRodionov

Copy link
Copy Markdown
Contributor Author

Thanks, @taklwu as usual :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants