Skip to content

Stop conflating EnergyQuanta and FunctionBudget#4930

Merged
joshua-spacetime merged 7 commits into
masterfrom
noa/unconflate-budget-and-energy
Jun 3, 2026
Merged

Stop conflating EnergyQuanta and FunctionBudget#4930
joshua-spacetime merged 7 commits into
masterfrom
noa/unconflate-budget-and-energy

Conversation

@coolreader18
Copy link
Copy Markdown
Contributor

@coolreader18 coolreader18 commented May 1, 2026

Description of Changes

A sort of followup to/unrevert of #4884, an alternative to #4927.

In #3832, we made FunctionBudget a different unit than EnergyQuanta, but there were still many places where we treated them the same and directly converted between them. I got confused by that in #4884, and now this PR properly separates them and corrects the v8 energy calculation.

Also, since we now benchmark the same module in rust and typescript in the form of the keynote benchmark, this patch adds a new assertion to that test that the fuel usage of both modules is within 2X of each other.

Expected complexity level and risk

3 - touches energy calculation without reverting the problematic #4884, but I'm confident it's correct this time.

Testing

  • Verified that the conversion factors make sense for wasmtime and for v8.
  • Assert that typescript and rust keynote bench runs have similar cpu usage

@coolreader18 coolreader18 requested a review from cloutiertyler May 1, 2026 19:25
Comment thread crates/core/src/client/messages.rs Outdated
Comment thread crates/core/src/host/module_host.rs Outdated
Copy link
Copy Markdown
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

Left some comments.

@coolreader18 coolreader18 force-pushed the noa/unconflate-budget-and-energy branch from 8a610dd to 1fa49c1 Compare June 1, 2026 15:59
@joshua-spacetime joshua-spacetime force-pushed the noa/unconflate-budget-and-energy branch from 1c58250 to 5559e2c Compare June 2, 2026 06:35
@joshua-spacetime joshua-spacetime force-pushed the noa/unconflate-budget-and-energy branch from 5559e2c to 82f4595 Compare June 2, 2026 06:46
@joshua-spacetime
Copy link
Copy Markdown
Contributor

Keynote transfer fuel comparison: TypeScript=46444571114, Rust=48181790881, relative difference 1.04x

Copy link
Copy Markdown
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

I defer my codeowner review to @joshua-spacetime who says this is good.

@joshua-spacetime joshua-spacetime added this pull request to the merge queue Jun 2, 2026
Merged via the queue into master with commit 5291f57 Jun 3, 2026
55 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants