Skip to content

Replace JS worker's rendezvous channel with unbounded queue#4704

Merged
joshua-spacetime merged 2 commits intomasterfrom
joshua/js-worker-queue
Apr 6, 2026
Merged

Replace JS worker's rendezvous channel with unbounded queue#4704
joshua-spacetime merged 2 commits intomasterfrom
joshua/js-worker-queue

Conversation

@joshua-spacetime
Copy link
Copy Markdown
Collaborator

@joshua-spacetime joshua-spacetime commented Mar 24, 2026

Description of Changes

Previously, a module’s JS worker thread was fed through a zero-capacity channel. That made every request handoff a rendezvous between the async producer task and the single JS worker thread. Under high concurrency, that synchronous handoff showed up as hot flume/lock/wakeup stacks on the critical path - the JS worker thread.

This patch brings V8 execution in line with WASM which also uses an unbounded request queue.

Changing that handoff to an unbounded queue decouples request producers from the JS worker. Producers can enqueue work without synchronizing directly with the worker on every request, and the worker can continue draining queued requests without paying the rendezvous cost each time. This shortens the critical path, reduces scheduler/locking overhead and increases throughput.

API and ABI breaking changes

None

Expected complexity level and risk

2

Testing

Manual performance testing

@joshua-spacetime joshua-spacetime changed the title test: make js worker queue unbounded Replace JS worker's rendezvous channel with bounded queue Mar 25, 2026
@joshua-spacetime joshua-spacetime marked this pull request as ready for review March 25, 2026 06:49
@joshua-spacetime joshua-spacetime changed the title Replace JS worker's rendezvous channel with bounded queue Replace JS worker's rendezvous channel with unbounded queue Mar 25, 2026
Base automatically changed from joshua/v8-heap-metrics to master March 25, 2026 22:37
@Centril Centril self-requested a review March 27, 2026 11:31
@Centril
Copy link
Copy Markdown
Contributor

Centril commented Mar 27, 2026

On phoenix nap, using the rust client, I get:

  • TS module: 156.5k TPS
  • Rust module: 168.5k TPS

The difference with this PR is at 12k TPS 🚀

@coolreader18
Copy link
Copy Markdown
Collaborator

I'll review after the changes requested by Mazdak are made

@joshua-spacetime joshua-spacetime force-pushed the joshua/js-worker-queue branch 3 times, most recently from 6c005a6 to 77faa0d Compare April 4, 2026 18:41
Copy link
Copy Markdown
Collaborator

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

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

LGTM

@joshua-spacetime joshua-spacetime dismissed Centril’s stale review April 6, 2026 21:09

Address review comments

@joshua-spacetime joshua-spacetime added this pull request to the merge queue Apr 6, 2026
Merged via the queue into master with commit 7acbe7b Apr 6, 2026
34 of 35 checks passed
@joshua-spacetime joshua-spacetime deleted the joshua/js-worker-queue branch April 6, 2026 22:11
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