Skip to content

Split remote providers into their own crates - #19958

Merged
huonw merged 18 commits into
mainfrom
huonw/remote-provider-crates
Oct 5, 2023
Merged

Split remote providers into their own crates#19958
huonw merged 18 commits into
mainfrom
huonw/remote-provider-crates

Conversation

@huonw

@huonw huonw commented Oct 1, 2023

Copy link
Copy Markdown
Contributor

This does a no-functionality-change refactoring of the remote store providers (backed by REAPI and OpenDAL). This splits the concept of a remote provider out into their own internal "surface" crate remote_provider, plus three crates that are (mostly) implementation-details of that one:

  • remote_provider/remote_provider_traits for the traits (and structs!) that the various providers have to implement
  • remote_provider/remote_provider_reapi for the gRPC/REAPI-backed provider
  • remote_provider/remote_provider_opendal for the OpenDAL-backed provider

They're arranged like this:

graph BT
   remote("process_execution/remote (existing)")
   store("fs/store (existing)")
   traits("remote_provider_traits (new)")
   grpc("remote_provider_reapi (new)")
   opendal("remote_provider_opendal (new)")
   selector("remote_provider (new)")
   grpc --> traits
   opendal --> traits
   selector --> grpc
   selector --> opendal
   remote -- for remote execution --> grpc
   remote --> selector
   store --> selector
Loading

Theoretically the new crates other than remote_provider are an implementation detail... except there's a helper in remote_provider_reapi that's used for the remote execution in process_execution/remote, in addition to the byte store and action cache, hence the dependency there.

This is one point of #19902, following up on #19827 (comment).

The commits are individually reviewable, although the overall PR view gives a slightly more useful view of the overall file renames for some files.

@huonw huonw added the category:internal CI, fixes for not-yet-released features, etc. label Oct 1, 2023
@huonw
huonw force-pushed the huonw/remote-provider-crates branch from 0d32612 to 419288c Compare October 2, 2023 06:49
@huonw
huonw force-pushed the huonw/remote-provider-crates branch from 419288c to db46815 Compare October 3, 2023 01:00
async fn get_action_result(
&self,
action_digest: Digest,
build_id: &str,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This has changed from context: &process_execution::Context to just build_id: &str, because that's all that's used and it ensures that this code doesn't need to depend on process_execution.


const REAPI_ADDRESS_SCHEMAS: [&str; 4] = ["grpc://", "grpcs://", "http://", "https://"];

// TODO(#19902): a unified view of choosing a provider would be nice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These two functions are very similar, but I haven't tried to merge them as part of this work. There's two closely-related points in #19902 for follow-up ("tweaking the internal Rust details of how the remote providers are built to have less duplication", "improving how the options are fed through").


pub(crate) const STORE_BATCH_API_SIZE_LIMIT: usize = 4 * 1024 * 1024;

pub fn big_file_fingerprint() -> Fingerprint {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The functions here have moved to testutil so they can be used by the remote_provider_... tests without duplication.

@huonw
huonw marked this pull request as ready for review October 3, 2023 06:20

@stuhood stuhood left a comment

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.

Thanks!

@tgolsson tgolsson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks overall good, one comment. A bit hard to follow each individual move as I'm not familiar with all the code involved, but it mostly seems sensible.

If I have to make one complaint; it's that the remote_provider/remote_provider_xxx scheme is a bit redundant -- I'd repeat the domain if it wasn't nested, but when nesting it just leads to paths that are overly long -- it's a lot easier to distinguish remote_provider/{src,opendal,reapi,traits}/. And if you're in an shell, tab completion works better.

parking_lot = { workspace = true }
opendal = { workspace = true }
remote_provider = { path = "../../remote_provider" }
remote_provider_reapi = { path = "../../remote_provider/remote_provider_reapi" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't in your graph in the PR description; and it seems maybe a bit leaky if we're just picking up this dependency for apply_headers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

seems maybe a bit leaky if we're just picking up this dependency for apply_headers?

Yeah, I guess theoretically this should be entirely an implementation detail of providers surfaced by remote_provider... except currently the remote execution isn't wrapped up into a "provider" interface, just hard-coded to Bazel REAPI (and I could imagine it will remain this way), so it felt okay to leak here.

This isn't in your graph in the PR description

Oops good catch, fixed and updated the text to call it out too.

@huonw

huonw commented Oct 5, 2023

Copy link
Copy Markdown
Contributor Author

A bit hard to follow each individual move as I'm not familiar with all the code involved, but it mostly seems sensible.

Yeah, sorry, it's a bit of a mess, especially how it's not just moving files around, but merging/splitting some too!

If I have to make one complaint; it's that the remote_provider/remote_provider_xxx scheme is a bit redundant -- I'd repeat the domain if it wasn't nested, but when nesting it just leads to paths that are overly long -- it's a lot easier to distinguish remote_provider/{src,opendal,reapi,traits}/. And if you're in an shell, tab completion works better.

Yeah, I was in two minds, I definitely am sympathetic to the repetition being annoying... but I thought overall it's better if the crates names are spelled out for the uses etc., so remote_provider_reapi not just reapi, which means name = "remote_provider_reapi" in the Cargo.toml... and, thus the directory names too, to match (this isn't strictly necessary, but felt better to be consistent there).

@huonw

huonw commented Oct 5, 2023

Copy link
Copy Markdown
Contributor Author

I'm going to merge because I think the broad strokes are good enough here (and it'll be good to unblock downstream work towards #19902), but can iterate as follow-up, depending on the discussion from @tgolsson's points.

Thanks both.

@huonw
huonw merged commit 76f8103 into main Oct 5, 2023
@huonw
huonw deleted the huonw/remote-provider-crates branch October 5, 2023 21:59
@huonw huonw mentioned this pull request Oct 19, 2023
huonw added a commit that referenced this pull request Oct 31, 2023
This replaces uses of `RemoteCacheProviderOptions` with
`RemoteStoreOptions` (previously `RemoteOptions`): they're very similar,
and only separate because they were previously in very different parts
of the codebase, but this has changed with #19958.

This makes a few additional changes to make the merging smoother:
- removes the "capability cell" sharing optimisation, which enabled
sharing of the `GetCapabilitiesRequest` gRPC request result between the
CAS and the remote execution providers, if both were being used with the
same address. I thought that optimising one-time (on start-up) requests
from 2 to 1 wasn't worth the complexity of plumbing it through these
more generic options, but can restore it if it is.
- renames various fields

This does meant that there's a few options that are seemingly irrelevant
to the action cache providers, e.g. "batch API size limit" is
meaningless. I think this is fine: I think it's fundamental to
supporting multiple providers that there'll be a grab-bag of options,
which some providers support and others do not.

The commits are individually reviewable.

(This is one point of #19902.)
huonw added a commit that referenced this pull request Nov 19, 2023
There's a been a few new crates added recently (#18854, #19958), but we
didn't update `[workspace].members` and `[workspace].default-members` in
`src/rust/engine/Cargo.toml` to match. In addition, the older `protos`
and `grpc_util` weren't listed. This syncs up the lists.

The lists of `members` and `default-members` now exactly matches, except
for `fs/brfs` as commented. They also match the `Cargo.toml`s that exist
on disk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:internal CI, fixes for not-yet-released features, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants