Skip to content

Conversation

@HammadB
Copy link
Collaborator

@HammadB HammadB commented Dec 6, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Prefer this since it reduces foreground contention for disk since flushers don't delay
  • New functionality
    • None

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

None needed

Observability plan

Monitor cache insert latencies

Documentation Changes

None

@github-actions
Copy link

github-actions bot commented Dec 6, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Contributor

Switch hybrid cache policy to write-on-eviction

Updates the hybrid cache configuration to persist entries to disk during eviction rather than on insertion. This aligns with the stated goal of reducing foreground disk contention by deferring writes to the eviction path.

Key Changes

• Change HybridCacheBuilder configuration to use foyer::HybridCachePolicy::WriteOnEviction instead of foyer::HybridCachePolicy::WriteOnInsertion

Affected Areas

• rust/cache/src/foyer.rs

This summary was automatically generated by @propel-code-bot

.with_metrics_registry(otel_0_27_metrics)
.with_tracing_options(tracing_options.clone())
.with_policy(foyer::HybridCachePolicy::WriteOnInsertion)
.with_policy(foyer::HybridCachePolicy::WriteOnEviction)
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommended

[Documentation] This change from WriteOnInsertion to WriteOnEviction is a good optimization for insert latency, as it defers disk writes until an item is evicted from the in-memory tier.

This introduces a trade-off: improved performance at the cost of durability. In the case of an unclean shutdown (e.g., a process crash), any data in the memory cache that hasn't been evicted will be lost. The previous WriteOnInsertion policy provided stronger durability against crashes.

This is a reasonable trade-off for a cache, but it's an important change in behavior. To ensure this is clear for future maintainers, could you add a brief note about this durability trade-off to the PR description?

Context for Agents
This change from `WriteOnInsertion` to `WriteOnEviction` is a good optimization for insert latency, as it defers disk writes until an item is evicted from the in-memory tier.

This introduces a trade-off: improved performance at the cost of durability. In the case of an unclean shutdown (e.g., a process crash), any data in the memory cache that hasn't been evicted will be lost. The previous `WriteOnInsertion` policy provided stronger durability against crashes.

This is a reasonable trade-off for a cache, but it's an important change in behavior. To ensure this is clear for future maintainers, could you add a brief note about this durability trade-off to the PR description?

File: rust/cache/src/foyer.rs
Line: 352

@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Dec 6, 2025

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
chroma-cache/foyer::test::test_foyer_hybrid_cache_can_recover View Logs

Fix in Cursor

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.

3 participants