/batocera:batocera-tuningfrom batocera
Use when a Batocera cabinet feels slow, laggy, or stuttery, or when tuning performance: EmulationStation menu/carousel lag, a slow-since-boot frontend, CPU governor stuck in powersave, overclock or CPU-speed core options that seem to do nothing, run-ahead / input latency, joystick polling rate (usbhid.jspoll, 1000 Hz) on arcade encoders, framerate that drops the longer the machine runs, or a 3D-heavy game (PSX/PS2/Dreamcast/N64 class) that crashes or stutters — Vulkan errors in emulator logs, picking a rendering resolution or graphics backend the hardware can afford. Covers the diagnostic order (check the throttle first), the v43 governor-at-boot failure, the emulator-name vs rom-dir-name overclock scoping trap, ES event-hook frame cost, and hardware-tier detection (batocera-info / batocera-vulkan). Not for shader visual quality (batocera-display).
Ships in batocera. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Performance: why the frontend or a game runs slow, and how to fix it. Assumes
the connection pattern and batocera.conf model from batocera-ops. The theme
throughout: diagnose the machine state before blaming config, themes, or
gamelists. Most "it got slow" reports are a throttle or a leak, not the thing
the user suspects.
Work down this list; each step is one command and rules out a whole class:
powersave:
SSHB "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
If it says powersave despite system.cpu.governor=performance, see the
governor fix below. This is step 1 because it's the most common cause and the
cheapest check.system-selected hook
fires on every carousel tile change and can add permanent per-frame cost.
Audit /userdata/system/scripts/ and
/userdata/system/configs/emulationstation/scripts/. Because hooks are global
(not theme-scoped), this masquerades as a "theme-independent ES bug" — the
tell is that it accumulates per tile visited. See below.MaxVRAM in es_settings.cfg (e.g. to 1024) can help, but measure — on some
builds the GPU floor and MaxVRAM make no difference and the real cause is
#1 or #2.Measure, don't assume: a framerate overlay (DrawFramerate=true in
es_settings.cfg) plus the batocera-ops screenshot loop lets you read fps on
a specific tile remotely. Turn it back off when done.
Load average is a poor idle signal on these boxes. It counts threads in uninterruptible sleep, and a display driver worker that waits for a page flip (for example with the TV off) holds it near 1.0 while the CPU does nothing. Measure the real state:
SSHB 'head -1 /proc/stat; sleep 10; head -1 /proc/stat' # idle column vs total
SSHB 'ps -eo stat,args | awk "\$1 ~ /^D/"' # who is in D state
SSHB 'f=/sys/class/powercap/intel-rapl:0/energy_uj; a=$(cat $f); sleep 10; echo $(( ($(cat $f)-a)/10000 )) mW'
SSHB 'cat /sys/devices/system/cpu/cpu0/thermal_throttle/package_throttle_count'
A package that draws a few watts and still reads hot has a heat-path problem
(dust, old paste, a closed cabinet), not a software one. The throttle count is
the number that matters: zero growth during normal play means the cooling is
enough. Many mini PCs expose no fan sensor and no fan control to Linux (look
for pwm* and fan* files under /sys/class/hwmon/); the firmware owns the
fan curve and only the firmware setup screen changes it.
Do not drive these tests with synthetic input (see batocera-ops doctrine).
Ask the human to navigate, and read results from logs / screenshots / /proc.
Also note: a governor re-assert (below) may fire ~60–90s after boot, so the first
minute can feel slow even when fixed — don't let anyone judge inside that window.
On some v43 builds, system.cpu.governor=performance fails to apply at every
boot: the init script (/etc/init.d/S18governor) runs but its sysfs write
silently fails (redirected to /dev/null), leaving intel_pstate's default
powersave (~1.5 GHz vs the chip's ~3.4 GHz). A reboot does not fix it — every
boot lands in powersave.
Fix: re-assert the governor from a boot service after userspace is up, and
periodically thereafter. In /userdata/system/services/custom_service (the v43
replacement for custom.sh; see batocera-maintenance), add a loop that runs
/etc/init.d/S18governor start ~60s after boot and then hourly. Verify across a
reboot:
SSHB "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" # after ~90s uptime
Bonus hazard covered by the same hourly re-assert: batocera-shutdown's
fake-suspend can save the governor state such that a repeated fake-suspend strands
the machine in powersave permanently. The periodic re-assert covers that too.
Overclock and CPU-speed core options are keyed on the emulator/core context,
which is not always the rom directory you think you're affecting. Example: a
fbneo.fbneo-cpu-speed-adjust=200% key applies to launches in the fbneo core
context — it does not reach games launched out of a different rom directory
(e.g. neogeo) even though they run on the same underlying core. If Neo Geo games
still run at 100% after you "set the fbneo overclock," that's why: they need a
neogeo.<key> of their own.
To find the right scope, launch the game and read
/userdata/system/logs/es_launch_stdout.log for the system/emulator/core it
actually used, then key the override on that name. And remember the .opt
exception (batocera-ops → batocera-conf): a per-game .opt replaces global
core options, so a game with an .opt takes its CPU value from inside the .opt,
not from batocera.conf — set it there for that game.
Expanding on step 2: an installed ES event hook (say, a home-automation
integration that pings a server on system-selected) executes on every carousel
move. Even a fast-looking script can leave a couple of milliseconds of permanent
per-frame cost that accumulates per tile visited until ES is restarted, dragging
a 60 fps menu down to single digits after a while. Diagnosing it:
es.customsargs=--debug in batocera.conf,
picked up on a plain kill -9 restart of ES, no reboot needed): you'll see the
hook fireEvent → executing: line on every tile change.Graphics tuning only pays off on 3D systems whose emulators expose rendering levers. 8/16-bit libretro systems render native-res for pennies — they have no resolution or backend knobs worth touching, and "tuning" them means frameskip or the overclock keys above. Don't burn a session tuning a 2D system.
Know the hardware before proposing values. One command each:
SSHB "batocera-info" # CPU model/cores, RAM, display resolution
SSHB "batocera-vulkan hasVulkan; batocera-vulkan hasDiscrete; batocera-vulkan listDevices"
An iGPU-only box (hasDiscrete false) and a discrete-GPU box want different
defaults; find out which you're on before copying settings from a forum post.
The two levers, in order:
duckstation_resolution_scale, pcsx2_resolution,
flycast_render_resolution, …). Each step multiplies fill-rate cost; on an
iGPU, 1x-2x native is realistic and forum-copied 4x+ is not.Discover the exact key names and accepted values per emulator in
es_features.cfg (batocera-ops → batocera-conf reference) rather than
guessing — values can be opaque enums (PCSX2 OpenGL is
ps2.pcsx2_gfxbackend=12).
Crash and slowdown patterns in the emulator logs under
/userdata/system/logs/ (read es_launch_stdout.log first to see which
emulator/core actually ran):
| Log pattern | Likely cause | First fix |
|---|---|---|
VK_ERROR_*, vkQueueSubmit failure, device lost | Vulkan instability, esp. on Intel iGPUs | Switch that emulator's backend to OpenGL |
std::bad_alloc, OOM-killer hit in dmesg | Resolution scale / texture cost beyond memory | Drop resolution scale one step |
| Slowdown or audio crackle, no crash | GPU fill-rate saturated | Drop resolution scale before reaching for frameskip |
Scope fixes per game where one heavy title is the problem
(psx["Game (USA).chd"].duckstation_gfxbackend=…) rather than degrading the
whole system for it.
Run-ahead hides emulation input latency by simulating N frames ahead each frame —
great feel, but it multiplies CPU cost (each run-ahead frame is a full re-emulate)
and needs a core that supports save-states. Enable modestly
(<system>.retroarch.run_ahead_frames=1) on systems where the CPU has headroom;
back off if it introduces audio crackle or drops frames. On a weak cabinet iGPU,
prefer 1 frame and reserve it for the systems where latency matters most (fighters,
shmups) rather than globally.
"Set usbhid.jspoll=1 for 1000 Hz" is common advice for arcade encoders. On
many cabinets it changes nothing. Measure first; it takes ten seconds and no
input.
Read the real rate. Most cheap encoders (the DragonRise "zero delay" board,
USB id 0079:0006, is the usual one) answer every poll with a report, even
with hands off the controls. Count the reports on hidraw:
SSHB 'python3 - <<EOF
import os, time, select, collections, glob
for dev in sorted(glob.glob("/dev/hidraw*")):
fd = os.open(dev, os.O_RDONLY | os.O_NONBLOCK); ts = []
end = time.monotonic() + 3.0
while time.monotonic() < end:
if select.select([fd], [], [], 0.2)[0]:
try: os.read(fd, 64); ts.append(time.monotonic())
except BlockingIOError: pass
os.close(fd)
if len(ts) < 3: print(dev, "no reports while idle"); continue
gaps = collections.Counter(round((b - a) * 1000) for a, b in zip(ts, ts[1:]))
print(dev, "%.1f Hz" % ((len(ts) - 1) / (ts[-1] - ts[0])), "gap ms:", sorted(gaps.items()))
EOF'
This is a passive read: it changes nothing and sends nothing. A gap of 8 ms is
125 Hz, 1 ms is 1000 Hz. Do not trust the interval file in sysfs or Ivl=
in the USB device list: both show what the device asks for, not what the host
does. A device that reports only on change prints "no reports while idle"; for
that one, read event timestamps while a person moves the stick.
Why the setting often does nothing. jspoll changes the interval that the
usbhid driver requests. An xHCI (USB 3) host controller ignores that request
and takes the interval from the device's own endpoint descriptor. A low-speed
encoder that asks for 10 ms gets 8 ms there, with or without jspoll. The
setting only works on host controllers that honour the request (EHCI ports,
some single-board computers), which is why reports of success are real and
still do not transfer to your box. Check both facts before you spend time:
SSHB 'for d in /sys/bus/usb/devices/*/idVendor; do p=${d%/idVendor}; echo "$(cat $p/idVendor):$(cat $p/idProduct) speed=$(cat $p/speed) $(basename $p)"; done'
SSHB 'dmesg | grep -iE "new (low|full)-speed USB device.*using"' # xhci_hcd or ehci-pci
SSHB 'cat /sys/module/usbhid/parameters/jspoll' # 0 = not set
speed=1.5 is a low-speed device. If the encoders sit on xhci_hcd, expect no
change. A two-minute test without a reboot settles it: write 1 to the
jspoll parameter file, unbind and bind the encoder's interface under
/sys/bus/usb/drivers/usbhid/, and run the measurement again. Do it at the
menu, not in a game, because the joystick nodes go away for a second. Write
0 and rebind to undo it. Make the kernel command line change only after that
test shows 1 ms gaps: the boot file edit is lost at every upgrade, and a bad
line there can stop the boot.
How much it is worth when it works. Published measurements of this encoder class put the gain from 1000 Hz polling at about 3 to 4 ms on average, with the spread unchanged, because the board's own scan and debounce loop is the larger delay. One frame at 60 Hz is 16.7 ms. A real improvement at the encoder needs a board that requests 1 ms in its own descriptor, which xHCI does honour.
Spend the effort here first, in this order:
SSHB "grep -E 'runahead|run_ahead' /userdata/system/batocera.conf".What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub t3chnaztea/batocera-skills --plugin batocera5 skills in this plugin
/batocera-displayUse when working on how games look on a Batocera cabinet: CRT and other shaders, shaderset resolution and per-game shader overrides, bezel/overlay artwork and alignment, generating missing .info sidecars, filtering unusable bezels, seasonal bezels and boot splash clips, pinning the display resolution, or diagnosing moire and cropped/misaligned game viewports inside bezels. Covers why a shaderset seems invalid, why .info top values are not alpha coordinates, and why Mega-Bezel per-game art fails. Not for performance/framerate tuning (batocera-tuning)./batocera-maintenanceUse when keeping a Batocera cabinet healthy over time: running scripts or scheduled jobs at boot and on an interval without cron, the custom_service boot-service pattern (which replaced custom.sh in v43), backing up /userdata to another machine over SSH, and upgrading between major Batocera versions (v42 to v43 and similar) including the ROM-directory renames and post-upgrade checklist, a daily thermal throttle log, and a monthly health check that alerts only on an out-of-range value. Covers why there is no crond, the backup-before-upgrade doctrine, and catch-up scheduling. Not for performance tuning (batocera-tuning)./batocera-opsUse when connecting to or operating a Batocera arcade/retro-gaming cabinet over SSH: establishing the connection, understanding its read-only rootfs and /userdata layout, finding config/log/ROM paths, applying changes safely, verifying a display/config change end-to-end without a controller, or diagnosing why a setting reverts to its default on every launch (configgen). Foundation for the other batocera-* skills (roms, display, tuning, maintenance). Covers sshpass, batocera.conf, EmulationStation, the ES HTTP API, and batocera-screenshot. Not for game recommendations./batocera-romsUse when working with ROMs and gamelists on a Batocera cabinet: figuring out which directory a system's ROMs go in, why a game does not appear in the menu, which file formats and extensions a system accepts, curating a large library by hiding rather than deleting, editing gamelist.xml safely, cleaning up multi-disc games, or verifying dumps against No-Intro/Redump DATs. Covers extensionless-ROM-in-zip failures, the 3DO/Opera no-m3u trap, cave3rd, and the es_systems_custom.cfg landmine. Not for shaders/bezels (batocera-display), or ROM directories renamed by a Batocera version upgrade (batocera-maintenance).