Skip to content

cache: disk records hold uncharged heap #91

Open

Description

@zfarrell

Found by a memory-accounting audit of 8b3c813. The tests are on branch audit/memory-tests and fail on main today; check out that branch to run them. File and line links point at that commit.

What goes wrong. A disk record is charged 0 memory (src/core/src/cache/cached_batch.rs:65). Its index slot, policy node and t4 index entry still live on the heap, so memory use grows with the disk tier and no budget sees it.

Evidence.

  • 249.4 heap bytes per live disk record in release, or with the debug trace drained. The debug figure of 467 included the event trace (debug builds only).
  • memory_usage_bytes was 0 throughout.
  • Projection, not measured: about 2.3 GB per 10 million disk entries.

Tests.

Test File Command Flags
claim1_heap_per_disk_record src/core/tests/disk_tier_audit.rs:124 AUDIT_DRAIN=1 cargo +1.96.0 test -p liquid-cache --test disk_tier_audit claim1 -- --nocapture --test-threads=1 100,000 entries (AUDIT_N1); without AUDIT_DRAIN=1, a debug build over-reports

The split of the 249 B between the cache's own structures and t4's was not measured.

Flags: P probabilistic (a pass after a fix only means the race wasn't hit), F interleaving forced by a test hook, L Linux only, D needs Docker, M measurement only, C control (passes by design).

Activity

  1. added
    bugSomething isn't working
    memoryMemory accounting or memory usage
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmemoryMemory accounting or memory usage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions