Skip to content
WebsiteHosting.com

concept Delivery & performance

Cache admission and TinyLFU frequency estimates

A cache miss need not displace a resident item. TinyLFU-style admission compares their estimated recent demand; aging can change which item leads without changing which resident is up for eviction.

Latest recorded source check · P0162

What it means

A cache miss does not mean the requested item should replace something in the cache. TinyLFU-style admission compares the estimated recent request frequency of that item, the candidate, with that of an existing entry, the victim. The victim is the entry under consideration for eviction; a separate policy has already chosen it. The admission decision can still leave it in place.

Try it

Simulation: start with a prior frequency estimate of 6 for the candidate and 4 for the victim. With evidence provided, aging set to none, and no new observations for either item, the final estimates are 6 and 4. The model admits the candidate because 6 is greater than 4.

Cache admission and TinyLFU frequency estimates

Explain admission policy versus eviction under a changing hot-key distribution

Simulation
Modeled outcome: Admit

Candidate estimate is larger under this toy admission rule; candidate replaces the independently selected victim.

Cache admission and TinyLFU frequency estimates: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
Aging and admission comparison

Admission

  1. Epochnone
  2. Decisionadmit
Candidate after aging6 count
Victim after aging4 count
Candidate at comparison6 count
Victim at comparison4 count

The counters are exact toy estimates; no sketch collisions or live cache policy are measured. Ties retain the victim in this model.

Evaluated inputs

Required scenario evidence
provided
Prior candidate frequency estimate
6 count
Aging
none
New candidate observations
0 count
Prior victim frequency estimate
4 count
New victim observations
0 count

Ideal supplied frequency estimates, floor-half aging then exact new counts. No count-min collisions, saturation, real cache eviction policy or hit-rate prediction; not Caffeine implementation.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

In the interactive version, set New victim observations to 3 and leave everything else alone. The victim now has 4 prior observations plus 3 new ones, for an estimate of 7. The candidate is still at 6. The result switches to retain: demand changed, not the identity of the victim. Reset restores the 6 and 4 starting estimates, no aging, zero new observations, and provided evidence.

Why the timing of requests matters

Read each count bar in two parts: the portion of the prior estimate that still counts, and the observations added since then. With aging set to halve, the model halves each prior estimate, rounding down to a whole count. Only then does it add new observations at full weight. The aged count replaces the prior count; it is not an extra contribution.

Consider just two new observations for the victim and none for the candidate. Without aging, the final estimates tie at 6: the candidate has 6, and the victim has 4 plus 2. This model requires the candidate to be strictly ahead, so the victim stays. With halving, the prior estimates become 3 and 2. The same two new observations put the victim ahead, 4 to 3. Both outcomes say retain, but only the second shows that the victim has the larger estimate.

Each count input accepts whole numbers from 0 to 100. A blank or fractional count is invalid, not a zero. With valid inputs but Required scenario evidence set to missing, the result is unknown: neither item’s estimate is evaluated. That is different from a tie, which requires two known, equal estimates.

Consider candidate 6 and victim 4, then age both by halving and add one new observation to the victim. The comparison becomes 3 against 3, not 6 against 5. The fixture retains the victim at equality. Aging both counters together preserves a meaningful comparison but does not guarantee that the next request will favor the retained item.

In practice

To understand why an item stayed in a cache, first identify which resident entry was considered for eviction. Then ask what frequency estimates the admission policy compared at that decision. A lifetime request total can hide a shift in demand: it does not tell you how much of the older activity still counted.

Caffeine’s frequency sketch uses compact, bounded counters to estimate popularity and periodically halves them. The simulation instead takes two estimates as given. It does not model keys sharing counters, counters reaching their maximum, when Caffeine triggers aging, or its production replacement rules.

Use the comparison to explain a choice between two items, not to predict the next request. To judge whether those choices improve hit rate, you need evidence from a workload, not just the two estimates at one miss.

Frequently asked questions

Editorial questions based on the listed sources and explicitly labeled local examples.

Is admission the same as eviction?

No. Admission determines whether a candidate enters the cache; eviction decides what existing entry leaves. This example compares candidate and victim frequency estimates only.

Are frequency estimates exact?

No. Caffeine uses a compact probabilistic frequency sketch with bounded counters. It estimates popularity rather than maintaining an exact unbounded history for every key. The lab uses explicit small counts, not that sketch implementation.

Why age counters?

Aging reduces the influence of old demand. Caffeine's frequency sketch periodically halves its counters. Here you choose an illustrative aging step and observe how new requests can change admission; the simulation does not reproduce the implementation's trigger or collisions.

Does this prove a better hit rate?

No. The example compares two exact toy counters at one miss, retaining the victim at equality. A hit-rate claim needs a sequence of requests and the actual admission and eviction behavior.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. Caffeine project: Window TinyLFU efficiency

    Efficiency: admission and frequency estimation. Window TinyLFU distinguishes frequency-based admission from eviction and includes a recency window. The toy comparison uses supplied counts.

    Checked .

  2. Caffeine FrequencySketch

    FrequencySketch class comment; periodic aging. Caffeine FrequencySketch uses bounded 4-bit probabilistic counters and periodic halving of counters to age frequency estimates. The example uses explicit counts and an optional idealized half-aging step; it does not implement sketch collisions, saturation, trigger timing or exact production admission policy. Master snapshot; commit not pinned.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.