Skip to content

HBASE-30020 Introduce cache placement and admission policy API#8184

Merged
taklwu merged 1 commit intoapache:HBASE-30018from
VladRodionov:HBASE-30020-placement-admission-policy
May 7, 2026
Merged

HBASE-30020 Introduce cache placement and admission policy API#8184
taklwu merged 1 commit intoapache:HBASE-30018from
VladRodionov:HBASE-30020-placement-admission-policy

Conversation

@VladRodionov
Copy link
Copy Markdown
Contributor

This PR targets the HBASE-30018 feature branch.

Introduces the cache placement/admission policy layer for the pluggable block cache architecture.

Adds:

  • CachePlacementAdmissionPolicy
  • AdmissionDecision
  • AdmissionPriority
  • TierDecision
  • PromotionDecision
  • RepresentationDecision
  • CacheRequestContext
  • CacheWriteContext
  • CacheWriteSource
  • DefaultHBaseCachePlacementAdmissionPolicy

The default policy preserves current HBase behavior:

  • admission is allowed by default after existing CacheConfig decisions
  • metadata/index/bloom blocks prefer L1, with fallback to L2
  • data blocks prefer L2, with fallback to L1
  • representation preserves current HBase behavior
  • no promotion by default

No read/write path migration is included in this PR.
No behavior change intended.

JIRA: HBASE-30020

Copy link
Copy Markdown
Contributor

@petersomogyi petersomogyi left a comment

Choose a reason for hiding this comment

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

LGTM. Clean API design with good Javadocs.

@VladRodionov VladRodionov force-pushed the HBASE-30020-placement-admission-policy branch from 6a3b1be to 57513fc Compare May 6, 2026 00:45
Copy link
Copy Markdown
Contributor

@taklwu taklwu left a comment

Choose a reason for hiding this comment

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

just two questions , but LGTM

Comment on lines +64 to +70
/**
* Returns whether this is a repeated lookup for the same block.
* @return true when this is a repeated lookup
*/
public boolean isRepeat() {
return repeat;
}
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.

question: how would this repeat be used ? is it something we will define in the each implementation that more than X times lookup would considered as repeat?

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.

repeat preserves an existing HBase cache lookup semantic and is not intended as a hotness/frequency signal. Today HBase uses it mainly to avoid double-counting cache misses during retry or double-check-locking lookup paths.

* Promotion action selected by cache placement policy.
*/
@InterfaceAudience.Private
public enum PromotionAction {
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.

nit: will we have a demotion action ? IIRC that we may have block moving from L1 -> L2, ,if so and if need to record it, where should we action be annotated ?

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.

I think demotion is a separate topology operation and should not be encoded in PromotionAction.
PromotionAction is intentionally scoped to cache-hit handling: after a hit in one tier, the policy may decide whether to promote the block to a higher-priority tier. Demotion, if needed later, would likely be modeled separately, for example as DemotionDecision / DemotionAction, or recorded in topology-level metrics when CacheTopology#demote(...) is invoked. I would avoid mixing promotion and demotion into the same enum because they are triggered by different events: promotion is hit-driven, while demotion is usually eviction/pressure-driven. Besides this, demotion is quite expensive (you will need to expose CacheEngine internal eviction pipeline to listen to these events, not all cache implementations can be efficient)

For this PR, I’d keep PromotionAction limited to NONE and PROMOTE, and add demotion-specific decision/metrics later when we wire actual eviction callbacks or topology movement.

Btw, promotion is hard as well, you have to make sure that object being promoted is really worth it, otherwise you introduce additional layer of cache data trashing.

Copy link
Copy Markdown
Contributor

@wchevreuil wchevreuil left a comment

Choose a reason for hiding this comment

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

LGTM.

@taklwu taklwu merged commit 09c627a into apache:HBASE-30018 May 7, 2026
8 checks passed
@VladRodionov
Copy link
Copy Markdown
Contributor Author

Thank you, @taklwu @wchevreuil and @petersomogyi.

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.

4 participants