Skip to content

fix: compile wasm eagerly in benchmarks - #154

Merged
natemoo-re merged 1 commit into
mainfrom
natemoo-re/bench/eager-wasm
Dec 4, 2026
Merged

natemoo-re merged 1 commit into
mainfrom
natemoo-re/bench/eager-wasm

Conversation

@natemoo-re

Copy link
Copy Markdown
Member

What does this PR do?

Compiles WebAssembly eagerly in the bench project so that V8's wasm compilation stops showing up as memory regressions.

V8 compiles @bomb.sh/tty's wasm module lazily. Each function is compiled the first time it's called, and hot functions are recompiled later. Those are native allocations with no JS stack. Every createUI reuses the same compiled module, so the cost lands on whichever bench happens to trigger it. That's the source of the "still open" peaks from #151: initial render::grass (100) and single value update::grass (500). Before #143, the same cost landed on evergreen (100) and bamboo (100).

  • The bench project now passes --no-liftoff --no-wasm-lazy-compilation. All wasm is compiled with TurboFan when the module loads, before any bench runs.

CodSpeed

Each experiment compares against main (3481fbe):

experiment result
throwaway warmup case first 757 KB peak moved to the warmup; every other spike shifted one slot later
fixed semi-space size no change (not heap growth)
--no-wasm-lazy-compilation --no-wasm-tier-up spikes gone, walltime ~30% slower (stuck on Liftoff)
--no-liftoff --no-wasm-lazy-compilation (this PR) spikes gone, no walltime change
bench main this PR
initial render · grass (100) 756.9 KB 8 KB
single value update · grass (500) 462.5 KB 6.8 KB
initial render · evergreen (100) 290.2 KB 6.1 KB
initial render · bamboo (100) 257.7 KB 5.1 KB

Comparison

The same comparison also shows 2–3 KB swings in peak memory on 5 benches with identical ui code. That's normal variation between runs, not a regression.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

No changeset: benchmark tooling only.

AI-generated code disclosure

  • This PR includes AI-generated code

@codspeed

codspeed Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚡ 4 improved benchmarks
❌ 1 regressed benchmark
✅ 235 untouched benchmarks
⏩ 60 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory bush (500) 7.6 KB 38.7 KB -80.41%
⚡ Memory grass (100) 756.9 KB 8 KB ×95
⚡ Memory grass (500) 462.5 KB 6.8 KB ×68
⚡ Memory bamboo (100) 257.8 KB 5.1 KB ×51
⚡ Memory evergreen (100) 258.4 KB 54 KB ×4.8

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing natemoo-re/bench/eager-wasm (768197e) with main (3481fbe)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@natemoo-re

Copy link
Copy Markdown
Member Author

These numbers aren't a fair comparison because main doesn't have an up-to-date benchmark AFAICT

@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026

Copy link
Copy Markdown

commit: 768197e

@natemoo-re
natemoo-re merged commit 2ab7919 into main Dec 4, 2026
12 checks passed
@natemoo-re
natemoo-re deleted the natemoo-re/bench/eager-wasm branch December 4, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants