Skip to content

Jump tables for the Game Boy, MSX, SMS, PICO-8, Jedi Knight and NES cores (2-12% less CPU per frame) - #32

Merged
finger563 merged 1 commit into
mainfrom
perf/core-jump-tables
Nov 21, 2026
Merged

finger563 merged 1 commit into
mainfrom
perf/core-jump-tables

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

Turns jump tables back on for the Game Boy, MSX, SMS, PICO-8, Jedi Knight and NES cores. These are mostly interpreters whose opcode dispatch is a big switch.

  • ESP-IDF builds everything with -fno-jump-tables -fno-tree-switch-conversion, because a table in flash breaks code that runs while the cache is disabled.
  • The game cores run from their PSRAM overlay with the cache on. A switch's table goes into the function's .rodata, which moves into the overlay with the core's other read-only data.
  • Genesis, GBA, SNES and MGS were already built this way.

Measurements (Tab5)

The game thread's CPU per presented frame over the same 15 s scene, from PC sampling on both cores:

Core Before Jump tables
Game Boy 7.29 ms 6.43 ms -12%
MSX 9.11 ms 8.24 ms -10%
SMS 8.82 ms 8.11 ms -8%
PICO-8 3.79 ms 3.53 ms -7%
Jedi Knight (menu) 15.20 ms 14.47 ms -5%
NES 6.69 ms 6.57 ms -2%
Doom / Dark Forces / Star Trek within 1% (left out)

Memory:

Testing

  • Built; the overlay check passes; the flags reach every file of the six cores and none of the others (checked in compile_commands.json).
  • Played each core during the measurements above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

…ores

ESP-IDF builds everything with -fno-jump-tables -fno-tree-switch-conversion:
a table in flash breaks code that must run while the cache is disabled.
The game cores run from their PSRAM overlay with the cache on, and a
switch's table moves into the overlay with the core's other read-only
data (Genesis, GBA, SNES and MGS were already built this way).

Measured on the Tab5, the game thread's CPU per presented frame over the
same 15 s scene (gprof, PC sampling on both cores):

  Game Boy    7.29 -> 6.43 ms  -12%
  MSX         9.11 -> 8.24 ms  -10%
  SMS         8.82 -> 8.11 ms   -8%
  PICO-8      3.79 -> 3.53 ms   -7%
  Jedi Knight 15.20 -> 14.47 ms -5% (main menu)
  NES         6.69 -> 6.57 ms   -2%

Doom, Dark Forces and ScummVM measured within 1% and are left as they
were. The MSX member of the overlay grows by 76 KB (285 KB); the overlay
stays the size of its largest member, MGS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit 426c383 into main Nov 21, 2026
1 check passed
@finger563
finger563 deleted the perf/core-jump-tables branch November 21, 2026 04:27
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