Skip to content

perf: avoid live-block scans in wasm allocator - #799

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
vansh-nagar:perf/wasm-allocator-free-list
Sep 26, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
vansh-nagar:perf/wasm-allocator-free-list

Conversation

@vansh-nagar

Copy link
Copy Markdown
Contributor

Closes #794

Adds an address-ordered free list for reusable blocks and a tail pointer for fresh appends. Fresh allocation no longer scans live metadata, while the existing address-order list remains available for ownership validation and adjacent coalescing. Split blocks stay on the free list and tail updates cover split/coalesce cases.

The wasm32 and wasm64 allocator cases now retain 16,000 additional small allocations so both runtimes exercise the no-free path.

O2 scaling results on macOS arm64 with LLVM 21.1.8 and Node 26.0.0 (five measured runs after warmup):

Allocations wasm32 median (range) wasm64 median (range)
4,000 0.042 ms (0.039–0.106) 0.031 ms (0.026–0.041)
8,000 0.105 ms (0.072–0.178) 0.059 ms (0.051–0.081)
16,000 0.214 ms (0.150–0.484) 0.122 ms (0.106–0.137)

Verification:

  • wasm32 test11.wave and wasm64 test12.wave compile and return 0 under Node
  • cargo fmt --all --check
  • ./tools/check_std_policy.sh
  • targeted WebAssembly codegen regressions: 2 passed
  • commit includes DCO sign-off

@LunaStev LunaStev 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.

LGTM. The separate address-ordered free list and tail pointer remove the quadratic live-block traversal while preserving ownership validation, splitting, and adjacent coalescing. The wasm32/wasm64 regression coverage also exercises the intended no-free allocation path.

@LunaStev
LunaStev merged commit 23960cb into wavefnd:master Sep 26, 2026
25 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
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.

Avoid quadratic metadata scans during WebAssembly allocation

2 participants