feat(foyer-layer): add chunked cache mode #7170
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #6372
Rationale for this change
the current FoyerLayer caches entire objects, which is inefficient for large files with partial/range reads. this PR adds chunked caching mode to improve cache efficiency for large objects by caching fixed-size chunks independently.
What changes are included in this PR?
with_chunk_size()is set, the caching scheme changes to chunked mode. the caching processing logics in deleter/writer are disabled in the chunked mode, we can consider to add them later in another pr.FoyerKeyandFoyerValueto enums: with chunked caching enabled, besides the chunked data, we also require to cache the metadata about each object.Are there any user-facing changes?
yes, new API added
FoyerLayer::with_chunk_size(chunk_size: usize)to enable chunked caching modeAI Usage Statement
this PR was developed with assistance from opus4.5, with review by myself.
suggestions for review: The main changes are located in the newly added chunked.rs file, while the other modifications are mostly tests in lib.rs.