Skip to content

cranelift: save and reload fuel around new_epoch libcall - #14647

Open
ctiller wants to merge 1 commit into
bytecodealliance:mainfrom
ctiller:fix/epoch-check-fuel
Open

ctiller wants to merge 1 commit into
bytecodealliance:mainfrom
ctiller:fix/epoch-check-fuel

Conversation

@ctiller

@ctiller ctiller commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

When both consume_fuel and epoch_interruption are enabled, FuncEnvironment::epoch_check_full emits a conditional call to the new_epoch libcall at function entry and loop headers. Although fuel_check flushes buffered fuel into the SSA variable self.fuel_var immediately beforehand, epoch_check_full did not store self.fuel_var back to VMStoreContext::fuel_consumed before invoking new_epoch or reload it afterwards.

Consequently, if the epoch deadline callback inspected store.get_fuel() or trapped (UpdateDeadline::Interrupt / Err(...)), all fuel consumed since the last store synchronization was missing from the Store.

Save self.fuel_var before calling new_epoch and reload self.fuel_var afterwards when consume_fuel is enabled.

Assisted-by: Gemini

@ctiller
ctiller requested review from a team as code owners October 9, 2026 23:47
@ctiller
ctiller requested review from cfallin and removed request for a team October 9, 2026 23:47

@cfallin cfallin 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!

@cfallin
cfallin added this pull request to the merge queue Oct 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 10, 2026
@alexcrichton

Copy link
Copy Markdown
Member

@ctiller would you be up for resolving the merge conflict here?

When both `consume_fuel` and `epoch_interruption` are enabled,
`FuncEnvironment::epoch_check_full` emits a conditional call to the `new_epoch`
libcall at function entry and loop headers. Although `fuel_check` flushes
buffered fuel into the SSA variable `self.fuel_var` immediately beforehand,
`epoch_check_full` did not store `self.fuel_var` back to
`VMStoreContext::fuel_consumed` before invoking `new_epoch` or reload it
afterwards.

Consequently, if the epoch deadline callback inspected `store.get_fuel()` or
trapped (`UpdateDeadline::Interrupt` / `Err(...)`), all fuel consumed since the
last store synchronization was missing from the `Store`.

Save `self.fuel_var` before calling `new_epoch` and reload `self.fuel_var`
afterwards when `consume_fuel` is enabled.

Assisted-by: Gemini
@ctiller
ctiller force-pushed the fix/epoch-check-fuel branch from d577095 to 2fc056d Compare October 15, 2026 16:43
@cfallin
cfallin added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 15, 2026
@cfallin

cfallin commented Oct 15, 2026

Copy link
Copy Markdown
Member

@ctiller as with here, it seems this is yet again a merge conflict

colinhacks added a commit to amikofalvy/frizz that referenced this pull request Oct 15, 2026
…he PR

The previous commit kept the merge-queue sentence for every queue exit.
It still read wrong for a queue that dropped the PR without failing it:
bytecodealliance/wasmtime#14647, removed today over a merge conflict, was
told that "those failures do not show on the PR head" when nothing had
failed.

Three next steps now, most specific first: a queue that failed the PR
(GitHub's `failed_checks`, or a failed check in the merge group, as when
someone removes a red PR by hand) explains the `gh-readonly-queue/…`
commit; any other queue exit says to find out why it left and re-queue;
auto-merge going off says to find out why and turn it back on. A
re-minted report keeps the most specific of the reports it folds.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
colinhacks added a commit to colinhacks/frizz that referenced this pull request Oct 15, 2026
…61)

* fix(pr-watch): wake when a PR leaves the merge queue without merging

A thread parked on a queued PR slept through the PR bouncing out of the
merge queue: GitHub removed it for failed_checks, and a human noticed
2h25m later. The queue tests a separate merge-group commit, so the PR
head's checks stayed green and its merge state CLEAN: nothing the
watcher read had moved.

The batched PR query now also reads isDraft, mergeQueueEntry and the
last RemovedFromMergeQueue / AutoMergeDisabled timeline events, with the
merge group's own check rollup off each removal's beforeCommit (still 1
GraphQL point per PR). A fresh exit wakes the worker with GitHub's
reason, the failing merge-group checks, and, when the PR is not back in
the queue, what to do next. A PR turned back into a draft wakes it too.

Same class: a watched PR or issue GitHub stops resolving (deleted,
transferred, access lost) logged NOT_FOUND forever while the thread
waited out a for: of up to a year. After 30 minutes of NOT_FOUND the
watcher now settles and tells its worker.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(pr-watch): only consecutive NOT_FOUND answers settle a watcher

The not-found clock kept running through polls that never reached GitHub: a rate-limit deferral or
a network error left it alone, so one NOT_FOUND blip followed by half an hour of backoff settled the
watcher. Any outcome other than another NOT_FOUND now restarts the run.

The gone wake also pointed at `mcp__frizz__watch_pr`, which the worker prompt never teaches; it now
names `frizzctl watch-pr add` / `frizzctl watch-issue add`, as the expiry wake does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(pr-watch): tell auto-merge going off apart from a queue bounce

The paragraph under a merge-path exit always explained the merge queue: the
PR was tested merged onto its base in a separate `gh-readonly-queue/…`
commit, "so those failures do not show on the PR head". That is the point
of a queue bounce, but the same paragraph went out when auto-merge was
switched off in a repository with no queue at all. There it names a commit
and failures that do not exist (microsoft/vscode#339642, cli/cli#13665 and
vercel/next.js#99677 all carry such an exit today, none of them queued).

The report now carries which road the PR left. A queue exit keeps the
paragraph as it was; auto-merge alone says to find out why it went off and
gives the command that turns it back on. A re-minted report that folds
both keeps the queue wording, since it says everything the other does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(pr-watch): name the merge group's failed job before the ones it cancelled

A merge group fails fast: one job goes red and the queue cancels the rest.
`failedCheckNames` counts a cancellation as a failure and keeps rollup
order, so the eight names the clause has room for were cancellations and
the job that actually failed was folded into "+N more".

Measured on bytecodealliance/wasmtime#14375, dropped for `failed_checks` on
2026-09-22: 26 cancelled, 1 failed (Test MSVC x86_64 (1/8)), listed 14th.
The wake named eight ASAN and MPK jobs that never ran to the end, which is
exactly where a worker would go looking. The exit clause now lists the
non-cancelled failures first; the head's own CI wake is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* test(pr-watch): pin the not-found settle for an issue watcher too

The settle after 30 minutes of NOT_FOUND runs for issue watchers as well
(the issue branch of the poll feeds the same clock, and the check comes
before the issue is evaluated), but only the PR case was tested. This pins
the issue one: no wake inside the grace period, then one wake that names
`frizzctl watch-issue add`, and the watcher settles. Disabling the issue
branch's tracking fails it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(pr-watch): explain the merge group's commit only when it failed the PR

The previous commit kept the merge-queue sentence for every queue exit.
It still read wrong for a queue that dropped the PR without failing it:
bytecodealliance/wasmtime#14647, removed today over a merge conflict, was
told that "those failures do not show on the PR head" when nothing had
failed.

Three next steps now, most specific first: a queue that failed the PR
(GitHub's `failed_checks`, or a failed check in the merge group, as when
someone removes a red PR by hand) explains the `gh-readonly-queue/…`
commit; any other queue exit says to find out why it left and re-queue;
auto-merge going off says to find out why and turn it back on. A
re-minted report keeps the most specific of the reports it folds.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Colin McDonnell <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @ctiller for your contribution to this repository, but
this automated bot is closing this PR.

Bytecode Alliance projects have been overwhelmed with AI-generated
PRs that monopolize reviewer time, and this bot is an attempt to
push back. Please discuss this change on [zulip] with maintainers
first before jumping straight into making a PR. After discussion,
a maintainer may reopen this PR.

AI usage must abide by the Bytecode Alliance's AI Tool Use
Policy
,
and we ask that new contributors engage with maintainers
beforehand as humans to ensure that what you're working on is
reasonable for a newcomer to tackle. For more information, see
the contributing
docs
.

If you believe this PR was caught by this bot erroneously, reach
out to us on [zulip].

@github-actions github-actions Bot closed this Nov 20, 2026
@alexcrichton alexcrichton reopened this Nov 20, 2026

This branch has not been deployed

No deployments
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.

3 participants