Vladimir Rodionov created HBASE-30406:
-----------------------------------------
Summary: Add cache access notification support to CacheEngine and
cache topologies
Key: HBASE-30406
URL: https://issues.apache.org/jira/browse/HBASE-30406
Project: HBase
Issue Type: New Feature
Components: BlockCache
Reporter: Vladimir Rodionov
Assignee: Vladimir Rodionov
Fix For: 4.0.0-alpha-1
h2. Description
{{CacheEngine}} currently provides {{getBlock()}} for retrieving cached blocks,
but there is no lightweight mechanism to notify a cache engine that a block has
been accessed without retrieving the block from that engine.
This is required for cache topologies where the same block may reside in
multiple tiers.
In particular, {{TieredInclusiveTopology}} keeps a block in both L1 and L2.
When a request is satisfied from L1, L2 does not observe the access. As a
result, the L2 cache engine cannot update access-based eviction, recency,
frequency, or admission metadata for the block.
Add a {{touch(BlockCacheKey)}} operation to {{CacheEngine}}. The operation
provides an access notification without retrieving the cached object and
without affecting normal cache hit/miss accounting.
Access propagation should be topology-specific. {{CacheTopology}} should
provide a hook for handling successful cache accesses.
{{TopologyBackedCacheAccessService}} should notify the topology when a block is
found, allowing the topology to propagate the access to other tiers when
required.
For {{TieredInclusiveTopology}}, an L1 hit should result in a {{touch()}}
notification to L2. No cross-tier touch is required for
{{TieredExclusiveTopology}} or {{SingleTierTopology}}.
h2. Proposed Changes
* Add {{CacheEngine.touch(BlockCacheKey)}} with a default no-op implementation.
* Add a topology-level access notification hook, e.g.
{{CacheTopology.handleAccess(...)}}.
* Update {{TopologyBackedCacheAccessService}} to notify the topology after a
successful cache lookup.
* Update {{TieredInclusiveTopology}} to propagate an L1 hit to L2 using
{{touch()}}.
* Implement {{touch()}} for cache engines that maintain access-based metadata.
* Add tests for inclusive, exclusive, and single-tier topology behavior.
h2. Semantics
* {{touch()}} is a lightweight access notification and does not retrieve the
cached object.
* {{touch()}} is best-effort. If the block is no longer present in the target
engine, the operation has no effect.
* {{touch()}} must not increment normal cache hit/miss statistics.
* An L1 hit in {{TieredInclusiveTopology}} causes L2 to receive {{touch()}}.
* An L2 hit does not require an additional {{touch()}} because L2 already
observes the access through {{getBlock()}}.
* {{TieredExclusiveTopology}} does not propagate L1 hits to L2 because the
block is not expected to be present in both tiers.
* {{SingleTierTopology}} requires no additional access propagation.
* Cache engines that do not need access notifications retain the default no-op
behavior.
h2. Acceptance Criteria
* {{CacheEngine}} exposes a {{touch(BlockCacheKey)}} operation.
* L1 hits in {{TieredInclusiveTopology}} are propagated to L2.
* L2 can update its access metadata without fetching the cached block.
* {{TieredExclusiveTopology}} and {{SingleTierTopology}} do not generate
unnecessary cross-tier touches.
* {{touch()}} does not affect cache hit/miss statistics.
* Existing {{CacheEngine}} implementations remain compatible through the
default no-op implementation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)