Files
unkernel/test
Pooya Parsa bc8ac778da js: send worker-mode sound through a shared PCM ring and reuse one MessageChannel for yields (#18, #19)
With shared memory, the worker's PCM goes to the owner through a
single-producer, single-consumer SharedArrayBuffer ring (sound-ring.ts)
instead of a message per chunk: the owner drains it into the sink's
onChunk on coalesced "sound-wake" messages, or hands it to the new
SoundSink.onRing for a reader of the sink's own (an AudioWorklet).
State changes are records in the ring as well as messages, numbered
alike, so a sink sees states and PCM in the kernel's order however late
the messages are. The delay the kernel reports is the sink's answer plus
the frames still in the ring, reset with each stream. A full ring drops
the newest PCM, which the owner logs. shared: false keeps the
"sound-chunk" and "sound-queued" messages.

yieldToEventLoop() without setImmediate (browsers) reuses one
MessageChannel, with one message, so one task, per waiting yield.

Idle waits of 1 to 4 ms also wait on a timed Atomics.waitAsync where a
SharedArrayBuffer exists: browsers raise a nested setTimeout below 4 ms
to 4 ms (about 5 ms between wakes in Chrome and Safari workers, against
2.5 ms, measured 2026-11-24).

Co-authored-by: Adam Meghji <566793+adammeghji@users.noreply.github.com>
2026-11-24 15:41:39 +00:00
..
2026-11-22 23:19:14 +00:00
2026-11-22 23:19:14 +00:00
2026-11-15 23:27:04 +00:00
2026-11-19 16:04:15 +00:00
2026-11-15 23:27:04 +00:00
2026-11-15 23:27:04 +00:00
2026-11-15 23:27:04 +00:00
2026-11-15 23:27:04 +00:00