Repository navigation
HBASE-30550 Make cache admission decisions tier-aware - #8903
VladRodionov wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The rejection test selects an unsupported tier and bypasses admission checks, while no service-level test verifies that rejecting one tier still allows another selected tier to cache the block.
2 open issues
What changed in this PR
This PR separates cache placement from admission in HBase’s topology-backed cache service, allowing a block rejected by one tier to remain eligible for another.
Changes:
- Adds
CacheTierto admission decisions and selects placement before checking each tier. - Moves AdaptiveLRU filtering into admission for SINGLE and L1, leaving L2 unaffected.
- Updates policy tests and service mocks for the per-tier API and insertion flow.
| File | Description |
|---|---|
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessServiceWithBlockCacheBackedEngines.java | Updates admission mocks and rejection placement. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestTopologyBackedCacheAccessService.java | Updates assertions and mocks for per-tier admission. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestSingleTierTopologyBackedCacheAccessService.java | Adapts single-tier policy helpers to the new flow. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestInclusiveCombinedBlockCacheCompatibleTopologyBackedCacheAccessService.java | Updates inclusive-topology admission mocks. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestCombinedBlockCacheCompatibleTopologyBackedCacheAccessService.java | Updates exclusive-topology policy helpers. |
| hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestAdaptiveLruCachePlacementAdmissionPolicy.java | Tests placement separately from tier-specific admission. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/TopologyBackedCacheAccessService.java | Unifies insertion around placement followed by per-tier admission. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/DefaultHBaseCachePlacementAdmissionPolicy.java | Accepts the admission tier and classifies blocks through Cacheable. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CachePlacementAdmissionPolicy.java | Adds the target tier to the admission contract. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/AdmissionDecision.java | Adds a reusable null-block-type rejection decision. |
| hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/AdaptiveLruCachePlacementAdmissionPolicy.java | Preserves default placement and filters first-level admission. |
Review effort: Balanced
| if (!admission.isAdmitted()) { | ||
| continue; |
| CachePlacementAdmissionPolicy policy = mock(CachePlacementAdmissionPolicy.class); | ||
| when(policy.shouldAdmit(any(), any(), any(), any(), any())) | ||
| when(policy.selectTier(any(), any(), any(), any())) | ||
| .thenReturn(TierDecision.single(CacheTier.L1)); |
taklwu
left a comment
There was a problem hiding this comment.
claude found another possible problem, please verify it.
Single-tier caching now depends on the policy returning SINGLE, and fails silently otherwise. Before, a single-tier topology always wrote admitted blocks to topology.getEngine(CacheTier.SINGLE). Now it only caches if selectTier returns SINGLE. A single-tier topology has no L1 or L2 engine:
TestSingleTierTopologyBackedCacheAccessService.java
Ln 86–88
assertSame(engine, topology.getEngine(CacheTier.SINGLE).orElseThrow());
assertFalse(topology.getEngine(CacheTier.L1).isPresent());
assertFalse(topology.getEngine(CacheTier.L2).isPresent());
So a policy that returns L1 or L2 there makes cacheBlock skip every tier with continue. Nothing gets cached, with no log line or metric. Both shipped policies return SINGLE correctly, so nothing breaks today. But the safety net is gone, and the next policy added would fail silently. Suggestions:
- Map L1/L2 to SINGLE in the service when the topology is single-tier, or keep the old single-tier fast path.
- At minimum, log at debug level or count a metric when a selected tier has no engine.
|
|
||
| if ( | ||
| topologyView.getType() == CacheTopologyType.SINGLE_TIER | ||
| (tier == CacheTier.SINGLE || tier == CacheTier.L1) |
There was a problem hiding this comment.
nit: does that mean SINGLE or L1 mean this is one tier cache ?
|
|
||
| assertTrue(admission.isAdmitted()); | ||
| assertEquals(List.of(CacheTier.L2), placement.getTiers()); | ||
| assertTrue(admission.isAdmitted()); |
There was a problem hiding this comment.
nit: why do we need to move this line down ?
| CachePlacementAdmissionPolicy policy = mock(CachePlacementAdmissionPolicy.class); | ||
| when(policy.shouldAdmit(any(), any(), any(), any(), any())) | ||
| when(policy.selectTier(any(), any(), any(), any())) | ||
| .thenReturn(TierDecision.single(CacheTier.L1)); |

Summary
This PR makes cache admission decisions tier-aware.
Previously,
CachePlacementAdmissionPolicy.shouldAdmit()made a cache-wide admission decision before tier placement was evaluated. This does not work correctly for tiered topologies where a block may be rejected by one tier but still be admissible to another.The change separates placement from admission:
selectTier()determines the target cache tier or tiers.shouldAdmit()evaluates admission independently for each selected tier.CacheTieris now passed toshouldAdmit().TopologyBackedCacheAccessServiceperforms placement first and then checks admission for each selected tier before insertion.AdaptiveLRU
AdaptiveLruCachePlacementAdmissionPolicypreviously implemented first-level admission by modifying the result ofselectTier()and removingL1when a data block was rejected.With tier-aware admission, this is no longer necessary. AdaptiveLRU now preserves the default placement decision and performs adaptive filtering through
shouldAdmit()forSINGLEandL1.L2admission is not affected by the AdaptiveLRU first-level admission policy.For an inclusive topology this means, for example, that a data block may be rejected from L1 while still being admitted to L2.
Tests
Updated the affected cache policy and topology-backed cache service tests to reflect the new ordering and per-tier admission semantics.
The changes cover:
Scope
This PR contains the cache admission API and insertion-flow refactoring only.
The
IndexOnlyLRUmigration that motivated the need for per-tier admission is handled separately under HBASE-30362.