-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
Overhaul BinaryUtil to play nicely with v2 #7790
Comments
The exciting but not-strictly-necessary extension would allow us to avoid having to e.g. download a version of a compiler for Linux onto our OSX box if the remote execution platform is Linux (and not just compilers, but any native tool) -- |
Additional optimisation: It would be nice to be able to specify something along the lines of: |
This is a great idea that I believe
I'm into this idea, but a nitpick -- is there a reason we'd need to specify |
It doesn't feel like "extracting a tarball" strictly needs to be a native operation, but I guess there are some advantages there? Having said that, it doesn't feel like something that should be "part" of downloading them... rather, a composable component. After typing this though, it occurred to me that because URL fetching is native, it runs in the client, rather than on the cluster. And that... may not always be desirable. Ditto extracting tarballs. |
Sure, but it might not be obscenely difficult to extract a I think one distinction between things that should run on the client vs the cluster could be whether the process (download/etc) is cacheable in a way other processes can use (url downloading actually seems like a good example of this, as I think you were alluding to). I can see tarball extraction potentially going the same way, although we'd want to benchmark either of these before making any optimization decisions. |
The goal of having the digest is mostly so that we can skip the download entirely if we (or if we're executing remotely, the remote side) already know about that file. So if I have already downloaded digest bar, maybe not from a tar, or maybe from an old version of the tar, or maybe it's already on the remote execution cluster because of another user, I don't have to do the download or untar at all.
The advantage of doing this natively is that the native side has knowledge of the contents of the store (and if it likes, the remote store), so can skip things if needed. We could also expose that information another way if we wanted.
The local side could turn either of those things into a remote action if it wanted to, but I'm pretty sure the local side needs to be the thing that decides whether the action needs doing. Alternatively, we could teach the remote side about different well-known sources of digests, but that would be a lot more design work (and probably remote execution system implementation-specific).
My current line of thinking is that all process executions should be cacheable in a way that other processes can use (if the files are materialised). This would interact with platform though, in that downloading a file specific to a platform in the wrong place is bad. cc #7735 |
This will need to change as part of pantsbuild#7790 and pantsbuild#7735
This will need to change as part of pantsbuild#7790 and pantsbuild#7735
### Problem In runs with high degrees of concurrency, we end up seeing many simultaneous instances of tools being fetched and snapshotted. ### Solution Enforce a single fetch+snapshot attempt per tool. As mentioned in the comment, this is a temporary solution until #7790 migrates this into the engine itself.
### Problem In runs with high degrees of concurrency, we end up seeing many simultaneous instances of tools being fetched and snapshotted. ### Solution Enforce a single fetch+snapshot attempt per tool. As mentioned in the comment, this is a temporary solution until #7790 migrates this into the engine itself.
### Problem In runs with high degrees of concurrency, we end up seeing many simultaneous instances of tools being fetched and snapshotted. ### Solution Enforce a single fetch+snapshot attempt per tool. As mentioned in the comment, this is a temporary solution until #7790 migrates this into the engine itself.
Relevant upstream API PR: bazelbuild/remote-apis#88 |
And a pointer to the code that implements pants/src/rust/engine/src/nodes.rs Lines 647 to 802 in 44c2741
|
### Problem *One step towards a conclusion for #7790.* v2 rules currently have no way to make use of the extremely useful infrastructure we have for downloading tools hosted by ourselves or others, exposed via the `NativeTool` and `Script` subclasses of `BinaryToolBase`. This requires us to hard-code the digest and url to fetch from for `cloc` and `pex`, e.g.: https://github.com/pantsbuild/pants/blob/fd469cb62f330b73e7814f86e94558d16cfc9da3/src/python/pants/backend/python/rules/download_pex_bin.py#L67-L73 ### Solution - Add a v2 ruleset in `binary_tool.py`, which exposes a `BinaryToolFetchRequest` object which wraps a `BinaryToolBase` instance and converts into a `UrlToFetch`. - Add a `default_digest` field to `BinaryToolBase`, along with the `--fingerprint` and `--size-bytes` options, so that tools can specify the expected digest for their `default_version`, while giving the user the ability to set `--fingerprint` and `--size-bytes` if they override the `--version`. - Make cloc and pex use `BinaryToolFetchRequest` instead of hardcoding the url and digest. ### Result It should be much, much easier to integrate outside tools into v2 `@rule`s! The above pex `@rule` can now look like: ```python @rule async def download_pex_bin(pex_binary_tool: DownloadedPexBin.Factory) -> DownloadedPexBin: snapshot = await Get[Snapshot](BinaryToolFetchRequest(pex_binary_tool)) return DownloadedPexBin(SingleFileExecutable(snapshot)) ```
Addressed in #9625 (Other than the lazy-by-default downloads, but that feels like a much bigger issue) |
Right now, BinaryUtil works by eagerly http fetching files to a known location in
~/.cache
.We should overhaul it to work in a v2-first way. Some of the things I think this entails (not in any order):
UrlToFetch
requires.Store
, rather than to a known location on disk (probably using aUrlToFetch
request, so that these can happen in parallel in v2). Materialize them to disk only if needed (ideally only as part of v2 process executions, but for v1-compat we may need to materialize them to~/.cache
too if being called from v1).Exciting but not-strictly-necessary extension:
3. Make their downloads lazy by default; a remote execution which uses file X shouldn't need the local system to have file X, if the remote execution already knows about the file. Hopefully we can do this without needing to teach the engine to rewind the graph, or needing to introduce a tri-state execution status ("treat-as-if-executed-but-may-need-to-execute"), but... We may need to do something slightly tricky there...
The text was updated successfully, but these errors were encountered: