cfallin opened PR #15083 from cfallin:isle-veri-cache-s3 to bytecodealliance:main:
This PR addresses some problems we've had with the current "cached SMT query solver" implementation we have on top of GitHub CI's builtin cache action. In particular, the current cache action seems to refresh its cache once per night; so on a change that invalidates most of the cache (which may plausibly happen with any crosscutting change to the verifier itself or some base-level lowering rules or helpers), all CI jobs on that day will take multiple hours to run.
This PR instead implements a cache on top of an S3 bucket that we control separately. The basic data structure is a bit like an LSM tree: there is a packfile with sorted keys/values, and there are delta files that can be uploaded with new keys/values. Every so often, the current base packfile and deltas are consolidated into a new base packfile. This design is meant to minimize the number of PUT requests to S3 (which are relatively expensive) and the number of GET roundtrips (which can have nontrivial latency): ideally, we (i) have one or just a few big binary downloads to get the whole cache, and (ii) do no uploads if nothing changed, or one upload with everything that changed otherwise.
The read/write scoping is somewhat subtle too: previously we relied on GitHub CI's built-in key scoping hierarchy, with
mainCI runs implicitly visible to all PR branches, and each PR having its own private key-space. With this PR, we now have a simpler design: CI jobs onmainwill write the S3 cache (using a secret visible only to CI), and jobs on branches will read the cache. The cache bucket is publicly readable, so any job can query it without a secret. This keeps the AWS secret away from CI runs on branches, which we might not have fully vetted yet.With this design, any change that merges to
mainwill have its new cache entries immediately available to all PRs based on it, once it merges, so a cross-cutting change that invalidates a lot of the cache should only cause one long CI run in the merge queue.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested fitzgen for a review on PR #15083.
cfallin removed the review request for wasmtime-compiler-reviewers from PR #15083.
cfallin requested wasmtime-compiler-reviewers for a review on PR #15083.
cfallin requested wasmtime-default-reviewers for a review on PR #15083.
cfallin commented on PR #15083:
(I've created the appropriate secrets in this repo pointing to the S3 bucket that I created for testing -- let's see if this works!)
github-actions[bot] added the label cranelift on PR #15083.
github-actions[bot] added the label isle on PR #15083.
github-actions[bot] commented on PR #15083:
Subscribe to Label Action
cc @avanhatt, @cfallin, @fitzgen, @mmcloughlin
<details>
This issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
- avanhatt: isle
- cfallin: isle
- fitzgen: isle
- mmcloughlin: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
Could this unconditionally set the
environmentkey? My assumption is that PRs already don't get access to secrets, even if this is set
:speech_balloon: alexcrichton created PR review comment:
Could
CACHE_MODEbe inferred based on the presence/absence of the access key and secret access key?
:speech_balloon: alexcrichton created PR review comment:
This file in general is pretty intense -- could this perhaps shell out to the AWS CLI which I believe is installed on github runners instead?
alexcrichton commented on PR #15083:
I'll also note that ideally we'd leverage S3-based caching (or just something external) for much more than just ISLE, for example integrating
sccache, caching docker images, etc. IMO we should probably replace basically all usage ofactions/cachewith something that uses S3 instead
:memo: bjorn3 submitted PR review.
:speech_balloon: bjorn3 created PR review comment:
- You can restrict which workflows and branches can access an environment. Setting the environment here unconditionally means that wouldn't be possible as defense in depth.
- Each time a workflow runs, this causes an entry in https://github.com/bytecodealliance/wasmtime/deployments and in addition, an event is added to the PR that caused the environment saying that it deployed to the environment. So each time you add a new commit to a PR you did get a rather noisy event that is way bigger than a commit event and persists after force pushes.
<img width="643" height="250" alt="noise caused by setting an environment on PR CI" src="https://github.com/user-attachments/assets/be401532-2fda-4f7b-86a3-d0e3edf836da" />
:speech_balloon: bjorn3 edited PR review comment.
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
I don't understand much about GitHub environments beyond what I briefly read yesterday, but I did believe that this rule was necessary to ensure that secrets would not leak to PRs; and even if technically not with current scoping rules, I'd prefer to have defense-in-depth.
Reading the page in settings, I see: "They are not passed to workflows that are triggered by a pull request from a fork." That seems to imply (by omission) that secrets are present for PRs from branches within the main repo. I don't want to grant access to the secrets to anyone who has collaborator access on their own unreviewed PRs, so I do think we need an explicit condition here (or at least, that's my reading!).
What do you think?
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Sure, I can take a look at this next week! My intent was to make this usable for developers running client-side too, for what it's worth, where I would not necessarily want to require them to install the AWS SDK. With the public-readonly ACL on the bucket, the idea is that folks could let the tool download the cache when the run locally and it should Just Work.
The other options seemed to be either a little 400-line handwritten (err, robot-written) S3 client with just the methods we need, or the full AWS Rust SDK (and vet it + deps).
What do you think?
:speech_balloon: cfallin edited PR review comment.
:memo: bjorn3 submitted PR review.
:speech_balloon: bjorn3 created PR review comment:
That seems to imply (by omission) that secrets are present for PRs from branches within the main repo.
I believe so yeah.
so I do think we need an explicit condition here (or at least, that's my reading!).
Yes and you will have to restrict the environment to the main branch (+ branch protection to prevent direct pushes) to prevent a contributor from just modifying the workflow to use the environment on their branch.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
PRs from other repos will never get secrets, and by default no new branches are allowed in the Wasmtime repo. In that sense there's no real chance of leakage AFAIK. We've had a
PERSONAL_ACCESS_TOKENsecret for quite some time, not in an environment, and that's arguably much more important to protect than access to the s3 bucket.If the
environmentwere unconditionally configured here then my understanding is we'd go edit the environment settings to conditionally have access to the secret on some branches but not others. Why wouldn't that work to scope this? (or, alternatively, just removeenvironmenthere since it may not play well with our repo configuration)
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
That's the part for me basically, I don't really want an unreviewed S3 client LLM-authored here, and I'd prefer to not have to review it myself. Could
awsbe used when available and maybecurlwhen it's not?
:speech_balloon: cfallin created PR review comment:
So my thinking on this is: the S3 actions we need are more than just "get a single file with a known name", so curl is not going to lead to a simpler end-state: we will effectively need to write an AWS client still, except instead of using
ureqto access the endpoint, we are shelling out to a subprocess with the right verb/URI/request headers/signature/etc and then parsing the result just the same.Concretely for example: parts of s3.rs implement (i) XML parsing of the result of a list-object request; (ii) request signing, which requires an AWS-specific algorithm and inserts a custom header with the signature, for authorization; (iii) all the setup of other request details for each kind of action. Very little of the file is base-level HTTP stuff that
curlwould handle, andcurlused to implement any cache usage or update (usage requires list-objects) would need all of the above. So we'd have "an S3 client but with more steps".IMHO if we want to minimize custom logic that we carry ourselves, the right answer is probably to use a real S3 client crate. I haven't quantified exactly what the vetting burden of that is but that'd be the cost, vs. reviewing this code here (or equivalent code that does all the same things but generating curl commandlines). That's probably a better long-term direction if we hope to use S3 from other build infra though, now that I write it out...
Alternately, we redesign the cache so it really is still "a single file" and then decouple all uses of S3 to separate actions run in CI to download and upload; but then we lose the incremental-update benefit, and I think that's important here (otherwise we amplify our S3 PUT cost by ~20x compared to this compact-every-20-times approach, and PUTs are the expensive actions). I imagine that other kinds of caching we might want to do will probably want fine-grained hit/miss/update capabilities rather than "single giant blob we monolithically rebuild" so it seems better to me to push in the direction (i.e. figure out our S3 client approach) of enabling in-band S3 API access from whatever build tools, rather than making all our tooling use a local filesystem than snapshotting the whole thing at the end. At least that's the hypothesis of this PR.
What do you think?
:memo: cfallin submitted PR review.
cfallin updated PR #15083.
cfallin commented on PR #15083:
I talked with @alexcrichton just now and we came upon a much simpler idea: we can solve the proximate issue (once-per-night frequency of updates to cached ISLE verification state) in a much simpler way by moving where the GitHub cache update happens into the on-every-merge
publish-artifactsworkflow.We can still potentially use S3 for other caching actions, but it's probably more complexity than we want to accept for now.
I just force-pushed away the S3-related changes here (and will update title/description) and made the yaml-only change; @alexcrichton let me know what you think!
Last updated: Nov 19 2026 at 20:05 UTC