Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Prefetch trait #595

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Introduce Prefetch trait #595

merged 1 commit into from
Nov 8, 2023

Conversation

passaro
Copy link
Contributor

@passaro passaro commented Nov 3, 2023

Description of change

Introduce a new Prefetch trait to abstract how S3Filesystem fetches object data from an ObjectClient. While this change does not introduce any functional change, this abstraction will be used to implement optional object data caching.

The existing Prefetcher struct has been adapted to implement the new Prefetch trait. The main changes are:

  • it is generic on the ObjectPartStream (previously ObjectPartFeed), rather than using dynamic dispatch,
  • it does not own an ObjectClient instance, instead one is required when initiating a prefetch request,
  • the logic to spawn a new task for each GetObject request and handle the object body parts returned was moved into ObjectPartStream.

Relevant issues: #255

Does this change impact existing behavior?

No changes in behavior.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).

Copy link
Member

@jamesbornholt jamesbornholt left a comment

Choose a reason for hiding this comment

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

Still not really sure we have the abstraction right here, but it's better than before and not worth blocking on, so just a couple notes.

Comment on lines +37 to +40
type PrefetchResult<Client: ObjectClient + Send + Sync + 'static>: PrefetchResult<Client>;

/// Start a new prefetch request to the specified object.
fn prefetch<Client>(
Copy link
Member

Choose a reason for hiding this comment

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

Not going to block on it because we can refactor it later, but the Client type is a little weird here -- it's saying that you can pass any client into any prefetcher, but in reality it probably makes sense for a prefetcher to be coupled to a particular client once it's constructed.

I think in practice we want trait Prefetch<Client> or something, but that's a bit of annoying change to make.

mountpoint-s3/src/prefetch.rs Outdated Show resolved Hide resolved
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:19 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:19 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:19 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:19 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:20 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:20 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:20 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 7, 2023 11:20 — with GitHub Actions Inactive
@jamesbornholt
Copy link
Member

The send constraint might just be a nightly regression (rust-lang/rust#117602), maybe check again tomorrow.

Introduce a new `Prefetch` trait to abstract how `S3Filesystem` fetches object data from an `ObjectClient`. While this change does not introduce any functional change, this abstraction will be used to implement optional object data caching.

The existing `Prefetcher` struct has been adapted to implement the new `Prefetch` trait. The main changes are:
* it is generic on the `ObjectPartStream` (previously `ObjectPartFeed`), rather than using dynamic dispatch,
* it does not own an `ObjectClient` instance, instead one is required when initiating a `prefetch` request,
* the logic to spawn a new task for each `GetObject` request and handle the object body parts returned was moved into `ObjectPartStream`.

Signed-off-by: Alessandro Passaro <[email protected]>
@passaro passaro temporarily deployed to PR integration tests November 8, 2023 13:26 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 8, 2023 13:26 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 8, 2023 13:26 — with GitHub Actions Inactive
@passaro passaro temporarily deployed to PR integration tests November 8, 2023 13:26 — with GitHub Actions Inactive
@passaro
Copy link
Contributor Author

passaro commented Nov 8, 2023

The send constraint might just be a nightly regression (rust-lang/rust#117602), maybe check again tomorrow.

Right. It's been fixed now. I reverted the changes and rebased.

@jamesbornholt jamesbornholt added this pull request to the merge queue Nov 8, 2023
Merged via the queue into awslabs:main with commit c6b2a17 Nov 8, 2023
18 checks passed
@passaro passaro deleted the prefetcher branch November 14, 2023 11:41
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.

2 participants