Skip to content

cache: tinylfu policy tests use degenerate [b; 32] keys #1854

Closed

Description

@yigitdot

crates/cache/src/policy/sketch.rs documents an explicit key() helper whose docstring explains that [b; 32] keys make the shard-routing slice and the four row slices perfectly correlated and put every row on one column, so a test built on them cannot observe a routing bug at all.

crates/cache/src/policy/tinylfu.rs still uses h(b) = [b; 32] for all five of its tests, including tinylfu_evicts_least_frequent_first_not_least_recent — which tests the cross-shard ranking property, exactly the thing degenerate keys cannot exercise.

Those tests were equally degenerate before sharding so this is not a regression, but the sketch module now establishes the convention and the sister module violates it.

Fix: switch tinylfu.rs's test keys to full-entropy hashes (Hash::new(i.to_le_bytes()), as sketch.rs's key() does).

Surfaced by the #1803 review.

Activity

  1. self-assigned this
    on Aug 26, 2026
  2. moved this from Backlog to In progress in deCDNon Aug 26, 2026
  3. moved this from In progress to Done in deCDNon Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions