Repository navigation
[Do not merge] Fiber-await measurement tooling for node 18 (on #6) - #11
Draft
jbaczuk-qualia wants to merge 3 commits into
Draft
jbaczuk-qualia wants to merge 3 commits into
jbaczuk-qualia wants to merge 3 commits into
Conversation
Instead of a new hidden fiber per dispatched job, keep one long-lived hidden dispatch fiber. After each job it runs the dispatchable jobs queued right behind it (Fiber.__runNextDispatchable, needs the matching node patch), so a chain of awaits in fibered code costs one switch onto the fiber and one back instead of two per await. A job that blocks keeps the fiber and the next dispatch starts a new one; a fiber that was parked and later resumed never pulls in other jobs. FIBERS_AWAIT_REUSE=0 restores one new fiber per job. Fiber.microtasksBatched counts jobs run without a switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diagnostics for the reusing dispatcher: Fiber.microtaskDrains (default queue checkpoints, including empty ones), Fiber.drainsWithDispatch (drains that switched onto a dispatch fiber) and Fiber.redispatches (further switches within the same drain, i.e. an untagged job between two tagged ones sent us back to the main stack). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a branch of its own so it never ships; build fibers from it only where you want to measure: - fiber-await/test.js: behaviour checks (await then block, ALS across the hop, Promise.all overlap, Fiber.current still hidden, fiberless code untouched, ...), with FIBERS_AWAIT_REUSE / FIBERS_AWAIT_DISPATCH switches for comparison. - fiber-await/bench.js: switch round trip, chained / I/O-style / interleaved awaits in a fiber, fiberless awaits, drains, park cycles. Runs on stock node + fibers too. - fiber-await/app_stats.mjs: sample a running app from a Meteor shell (share of promise callbacks tagged, share of untagged that caused a switch, drains with dispatch, batched share, in-process switch cost). - fiber-await/README.md: how to run and read all of it, with reference numbers. Also keep Fiber.microtasksBatched on the shared native module, so it reads correctly when an app loads more than one copy of fibers_async.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jbaczuk-qualia
changed the base branch from
jbaczuk/fiber-await-v18-reuse
to
jbaczuk/fiber-await-v18
October 9, 2026 18:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Do not merge. Measurement tooling for the node 18 fiber-await prototype, stacked on #6 so it never ships; build fibers from this branch only in environments you want to measure. The node 24 version is #10.
src/fibers.cc:Fiber.microtaskDrains,Fiber.drainsWithDispatch,Fiber.redispatchescounters (plusmicrotasksDispatched/microtasksBatchedfrom Run await continuations from fibers on one reused hidden dispatch fiber (needs node#7) #6).fiber-await/test.js,fiber-await/bench.js,fiber-await/app_stats.mjs,fiber-await/README.md: behaviour checks, microbenchmarks, live-app sampling from a Meteor shell, and how to read them, with reference numbers.fibers_async.js:Fiber.microtasksBatchedkept on the shared native module so it reads correctly when an app loads two copies of fibers (qualia does). Diagnostics only; Run await continuations from fibers on one reused hidden dispatch fiber (needs node#7) #6 still has the per-copy counter.In local qualia this measured, over 88 s of clicking: 13.7% of promise callbacks tagged, 3.2% of untagged callbacks causing a switch, 71% of tagged callbacks batched; ~4,700 switches at ~20-45 us each (~0.1-0.25% of a core).
🤖 Generated with Claude Code