Skip to content

Ram only mode for liquid cache#3

Open
shefeek-jinnah wants to merge 1 commit into
mainfrom
shefeek/skip_disk_spill
Open

Ram only mode for liquid cache#3
shefeek-jinnah wants to merge 1 commit into
mainfrom
shefeek/skip_disk_spill

Conversation

@shefeek-jinnah
Copy link
Copy Markdown
Collaborator

No description provided.

Comment on lines +320 to 324
let victims = self.cache_policy.find_victim(1);
if victims.is_empty() {
// no advice, because the cache is already empty
// this can happen if the entry to be inserted is too large, in that case,
// we write it to disk
let on_disk_batch = self
.write_in_memory_batch_to_disk(entry_id, not_inserted)
.await;
batch_to_cache = on_disk_batch;
continue;
// Nothing left to free; the entry is larger than the budget.
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two existing tests assume the now-removed squeeze/spill path and will fail under this change:

  • src/core/src/cache/core.rs:982 (test_cache_advice_strategies) does store.index().get(&entry_id1).unwrap() and asserts MemoryLiquid after eviction. Under RAM-only behavior entry_id1 is dropped, so unwrap() panics.
  • src/core/src/cache/tests/policies.rs:26 (default_policies) inserts 5 entries into a 2-entry-capacity cache and reads back all 5 — only the last 2 survive now, the earlier reads will return None and the snapshot will diverge.
  • src/core/src/cache/tests/policies.rs:51 (insert_wont_fit_cache) inserts an oversized entry and unwraps the read result; under the new code the insert is silently skipped (the return here on victims.is_empty()), so the read returns None and the test panics. The corresponding liquid_cache__cache__tests__policies__insert_wont_fit_cache.snap is also stale.

Please update or replace these tests to verify the new RAM-only behavior (entries are dropped on eviction; oversized entries are not cached) and refresh the affected snapshot.


fn drop_victims(&self, victims: &[EntryID]) {
for victim in victims {
self.trace(InternalEvent::SqueezeVictim { entry: *victim });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: (not blocking) the trace event is still InternalEvent::SqueezeVictim, but the new path drops the victim rather than squeezing it. Consider renaming the variant (or adding a new DropVictim event) so traces accurately describe what happened.

}
}

fn drop_victims(&self, victims: &[EntryID]) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: (not blocking) with the new RAM-only insert path, several pieces of code are no longer reachable: squeeze_victims / squeeze_victim_inner (~lines 411–458), write_in_memory_batch_to_disk (~lines 260–303), and the squeeze_policy field on LiquidCache together with LiquidCacheBuilder::with_squeeze_policy. Either delete them, or — if "RAM-only" is meant to be a configurable mode rather than the only mode — wire up an explicit toggle on the builder. As-is, callers can still pass a SqueezePolicy that silently has no effect, which is misleading.

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Blocking Issues

  • Existing tests assume the squeeze/spill behavior and will fail under this change. None of the tests appear to have been updated for the new RAM-only semantics:
    • src/core/src/cache/core.rs:982test_cache_advice_strategies unwraps index().get(&entry_id1) after eviction and asserts MemoryLiquid. Under the new code entry_id1 is dropped, so this panics.
    • src/core/src/cache/tests/policies.rs:26default_policies inserts 5 entries into a 2-entry cache and reads back all 5; only the last 2 will survive.
    • src/core/src/cache/tests/policies.rs:51insert_wont_fit_cache expects to read an oversized entry that is now silently skipped.
    • src/core/src/cache/tests/snapshots/liquid_cache__cache__tests__policies__insert_wont_fit_cache.snap is now stale.

Action Required

  1. Update or replace the three tests above to verify the new RAM-only behavior: evicted entries are dropped (not transcoded), and entries that exceed the budget after the cache is empty are not cached.
  2. Refresh the affected insta snapshot.
  3. Decide whether SqueezePolicy / disk-spill is being removed entirely or made configurable, and either delete the now-dead code (squeeze_victims, squeeze_victim_inner, write_in_memory_batch_to_disk, squeeze_policy field, LiquidCacheBuilder::with_squeeze_policy) or add an explicit RAM-only toggle on the builder so callers don't pass a squeeze policy that has no effect.
  4. Consider adding a PR description that calls out the user-visible behavior change: oversized inserts and evictions are now silent drops rather than disk spills.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant