Skip to content

[Feature]: Enhance cache eviction policy to support payload-size-aware eviction #417

@xiexiaoy

Description

@xiexiaoy
  • Summary (Provide a general summary of the issue in the Title above):

    Add a payload-size-aware cache eviction policy that cooperates with the
    existing LRU-based eviction policy, so that entries with large payloads
    are kept in memory longer than small entries.

  • Detailed Description (Provide a detailed description of the change or
    addition you are proposing):

    EloqKV stores some very large values. When such a large value is evicted
    from the in-memory cache (cc map) and later requested again, it must be
    reloaded from disk — an expensive operation that hurts latency. The current
    LRU eviction policy treats all cache entries equally regardless of payload
    size, so a large value may be evicted well before its reload cost would
    justify doing so.

    The proposed enhancement introduces two new configuration knobs:

    • large_value_threshold (bytes, default 0 = disabled): entries
      whose PayloadSize() exceeds this threshold are candidates for
      large-value protection.
    • large_value_eviction_age (LRU access-counter units, default
      1000): the minimum LRU age that a page must accumulate before its
      large-value entries become eligible for eviction.

    The protection cooperates with — rather than replaces — the existing LRU
    policy:

    • Small entries continue to be evicted in normal LRU order.
    • Large entries are shielded from eviction while their page is "young"
      (recently accessed). Once the page has aged past
      large_value_eviction_age access-counter ticks without being touched,
      the protection is lifted and the entry can be evicted by the regular
      LRU scan.

    This means hot large values (pages that are accessed frequently) are never
    evicted, while cold large values are eventually evicted once they have been
    idle long enough.

  • Software version (the version of the software you're running):

    main branch

  • Possible Implementation (suggest an idea for implementing addition or
    change)

    • Add txservice_large_value_threshold (size_t) and
      txservice_large_value_eviction_age (uint64_t) inline variables to
      tx_service_common.h, defaulting to 0 and 1000 respectively.
    • Expose CcShard::AccessCounter() as a public getter so the clean guard
      can read the current LRU access counter.
    • In CcPageCleanGuardWithoutKickoutCc::CanBeCleaned() (in
      cc_page_clean_guard.h), after the existing IsFree()/GetBeingCkpt()
      check, add:
      if (txservice_large_value_threshold > 0 &&
          cce->PayloadSize() > txservice_large_value_threshold)
      {
          uint64_t age =
              cc_shard_->AccessCounter() - page_->last_access_ts_;
          if (age < txservice_large_value_eviction_age)
              return {false, false};
      }
    • Parse the optional large_value_threshold and
      large_value_eviction_age config keys in TxService::Init().

    Implementation is in PR Add payload-size-aware large-value zone eviction for EloqKV (ObjectCcMap) #415.

Metadata

Metadata

Assignees

Labels

featureAdd new feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions