Skip to content

emscripten: mirror native run-loop pacing, uncap fast forward - #16269

Open
holub wants to merge 1 commit into
mamedev:masterfrom
holub:em-loop
Open

holub wants to merge 1 commit into
mamedev:masterfrom
holub:em-loop

Conversation

@holub

@holub holub commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

The emscripten main loop advanced the scheduler by a hardcoded 1/60s of guest time per browser frame, capping unthrottled speed at RAF_hz/60 and skewing paced emulation on displays faster than 60Hz. Mirror the native run loop instead: a paced machine steps guest time matching the real callback interval (clamped to [1/240, 1/15]s), and an unthrottled machine spends the whole callback emulating so speed is CPU-bound as on desktop. The unthrottled branch probes the wall clock every 128 slices rather than per slice: osd_ticks() crosses into JavaScript and timer-saturated guests run thousands of tiny timeslices per budget, where a per-slice probe rivalled emulation cost.

assisted: GLM-5.3

The emscripten main loop advanced the scheduler by a hardcoded 1/60s of
guest time per browser frame, capping unthrottled speed at RAF_hz/60
and skewing paced emulation on displays faster than 60Hz. Mirror the
native run loop instead: a paced machine steps guest time matching the
real callback interval (clamped to [1/240, 1/15]s), and an unthrottled
machine spends the whole callback emulating so speed is CPU-bound as on
desktop. The unthrottled branch probes the wall clock every 128 slices
rather than per slice: osd_ticks() crosses into JavaScript and
timer-saturated guests run thousands of tiny timeslices per budget,
where a per-slice probe rivalled emulation cost.

assisted: GLM-5.3
@holub

holub commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author
image vs image

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.

1 participant