Skip to content

fix(layer/foyers): support suffix read#7738

Open
dentiny wants to merge 2 commits into
apache:mainfrom
dentiny:hjiang/fix-suffix-read-foyer
Open

fix(layer/foyers): support suffix read#7738
dentiny wants to merge 2 commits into
apache:mainfrom
dentiny:hjiang/fix-suffix-read-foyer

Conversation

@dentiny

@dentiny dentiny commented Jun 11, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #7736

Rationale for this change

The support for suffix read feature should be decided by storage backends, and layers should panic on this feature.

What changes are included in this PR?

Change the way how full object is sliced with suffix read involved.

Are there any user-facing changes?

No.

AI Usage Statement

fable-5 helped me make the code change for me, opus-4.6 and me doing code review.

@dentiny dentiny requested a review from Xuanwo as a code owner June 11, 2026 23:31
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Jun 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should remove foyer layer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi may I ask for some context on foyer/cache layer? I, somehow, didn't find the a related open issue.
The most relevant issue might be #7107, which reads to me:

  • we're working on a more general caching layer
  • foyer layer should be replaced with foyer service after caching layer implemented

Currently without foyer layer, the gap seems to be we don't have a transparent caching impl?
eg, caching layer impl

let cache = HybridCacheBuilder::new()
    .memory(64 * 1024 * 1024)       // 64MB memory
    .storage()
    .build()
    .await?;
let op = Operator::new(S3::default())?
    .layer(FoyerLayer::new(cache).with_size_limit(0..10 * 1024 * 1024))
    .finish();
// transparent
let data = op.read("path/to/file").await?;

while for caching service we need to explicitly do lookaside cache

let cache_op = Operator::new(Foyer::new().memory(64 * 1024 * 1024))?.finish();
let source_op = Operator::new(S3::default())?.finish();
// lookaside cache
let data = match cache_op.read("path/to/file").await {
    Ok(data) => data,
    Err(e) if e.kind() == ErrorKind::NotFound => {
        let data = source_op.read("path/to/file").await?;
        let _ = cache_op.write("path/to/file", data.clone()).await; // best-effort fill
        data
    }
    Err(e) => return Err(e),
};

after caching layer implemented

let cache_op = Operator::new(
    Foyer::new()
        .memory(64 * 1024 * 1024)
        .disk_path("/tmp/cache")
        .disk_capacity(16 * 1024 * 1024 * 1024)
)?.finish();
let op = Operator::new(S3::default())?
    .layer(CacheLayer::new(cache_op, WholeCachePolicy::new()))
    .finish();
// transparent
let data = op.read("path/to/file").await?;

In one word, foyer layer, at least for now, still benefits?

@dentiny dentiny requested a review from Xuanwo June 12, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: foyer layer doesn't support suffix read

2 participants