Skip to content

chore: bump napi: cache resolved guest callback functions to stop unbounded Store growth - #6850

Open
Arshia001 wants to merge 1 commit into
fix/foreground-task-queue-drainfrom
chore/bump-napi-funcref-cache
Open

chore: bump napi: cache resolved guest callback functions to stop unbounded Store growth#6850
Arshia001 wants to merge 1 commit into
fix/foreground-task-queue-drainfrom
chore/bump-napi-funcref-cache

Conversation

@Arshia001

Copy link
Copy Markdown
Member

Summary

  • Bumps the lib/napi submodule to pick up fix: cache resolved guest callback functions to stop unbounded Store growth napi#51, which fixes a real host-side memory leak found while load-testing edgejs: Function::from_vm_funcref (invoked via Table::get) unconditionally appends a new entry to the Store's function arena on every call with no dedup, and napi's callback trampoline (call_guest_callback/call_guest_callback2) was hitting this path on every single guest↔host callback invocation, growing the Store's functions Vec unboundedly for the life of the process.
  • The napi-side fix caches the resolved Function by the guest's stable __indirect_function_table index instead of re-resolving through the table on every invocation.

Test plan

  • Rebuilt (ENABLE_NAPI_V8=1 make build-wasmer) and reran a 90,000-connection raw-socket load test against edgejs with host RSS polling: RSS went from linear/unbounded growth (~4-5KB/connection, no plateau) to flat after initial warmup (394MB → 406MB over the first ~44s, then +0.7MB over the remaining ~72s covering the bulk of the 90k connections).

Stacked on #6845.

…ounded Store growth

Fixes a real host-side memory leak found while load-testing edgejs:
Function::from_vm_funcref (via Table::get) unconditionally pushes a new
entry into the Store's function arena on every call with no dedup, and
napi's callback trampoline was calling it on every single guest<->host
callback invocation, growing the Store's functions Vec unboundedly for
the life of the process. See wasmerio/napi#51.
@Arshia001
Arshia001 requested a review from syrusakbary as a code owner August 4, 2026 13:56
@Arshia001
Arshia001 force-pushed the chore/bump-napi-funcref-cache branch from 6fa4ba5 to 095b9cc Compare August 4, 2026 13:56
Copilot AI lite review requested due to automatic review settings August 4, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the lib/napi git submodule to a newer wasmerio/napi commit that fixes a host-side memory leak by caching resolved guest callback Functions (keyed by __indirect_function_table index) instead of re-resolving them through Table::get on every guest↔host callback.

Changes:

  • Bump lib/napi submodule from 07190b8 to 1ee2b32.
  • Pull in napi fix that avoids unbounded Store function-arena growth by caching resolved guest callback functions.

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.

2 participants