Repository navigation
Conversation
Native mode (the game's own code on the CPU), tuned for one device: Helio G95 (2x A76 @ 2.05 GHz + 6x A55 @ 2.0 GHz), Mali-G76, 8 GB RAM. No UI, name or resolution changes; everything is internal. - runtime/g95_perf.c (new): detects the SoC (mt6769/mt6785), finds the A76 cluster from cpufreq, pins the render thread to it, sets a uclamp.min floor (512) for every runtime thread, advises the game's code and stubs resident (madvise WILLNEED). No-op on any other SoC. - runtime/native.c: the guest counter scaled into the Switch's 19.2 MHz tick (64.64 fixed-point, runtime's read path only - no rewriter change), so game clocks and the frame pacer keep console time on a Helio counter rate; native mode on by default (the menu toggle still wins). - runtime/nvn/vulkan/exec.c: GPU progress waiter thread on by default for Mali (a timeline value read blocks in the kernel until the GPU catches up - the render thread stalled after every submission); transient ring 32 MB chunks on Mali (no device-local memory). - platform/android.c: the render thread pin and the shared uclamp call go through the G95 profile first. - CMakeLists: -O3, -march=armv8.2-a -mtune=cortex-a76, -ffp-contract=fast for the runtime; march stays at plain v8.2 (no +lse/+fp16/+dotprod) so every instruction also runs on the little A55 cores - no SIGILL. - version 0.4.2 (versionCode 42); README.md / README.pt-BR.md removed.
…t build, minutes not hours) + background -O1 upgrade from the played session's own hot list - Package rename everywhere: applicationId/namespace com.zbotw.recomp, java package and the 21 JNI names (Java_com_zbotw_recomp_*), shortcuts.xml, ACTION strings, the run scripts' adb paths. - gamebuild: fast mode (GameBuildOpts.fast) - everything at -O0, no cold scan; up to 6 compilers at once (the 2-job cap was measured against -O1 memory) with 512/768 MB floors; LARECOMP_GAMEBUILD_MAX. - The generator (single-threaded Python, the other half of the wait) pinned to the A76 cores on a Helio G90 family SoC (g95_pin_pid_big), where the -O0 compilers don't need them. - After the first play session: fnprof (the project's own profiler) records the functions the player's game entered; the next start screen rebuilds the game code at -O1 in the background with that list (hot at -O1, the rest optnone) - full frame rate, no waiting. LARECOMP_NO_UPGRADE=1 off.
…lickering The pass barrier was ALL_COMMANDS -> ALL_COMMANDS at every pass boundary, the most expensive thing to ask of a tiler between two render passes (Mali-G76: it drains the whole pipeline, hundreds of times a frame). LARECOMP_VK_NO_PASS_BARRIER=1 measured its cost - a large fps gain - at the price of flickering: passes read targets whose stores were not yet visible and wrote ones still being sampled. - pass_barrier (begin_pass): what the previous pass / dispatch / copy wrote, made visible with narrow stage / access masks (attachment stores -> attachment loads, sampling, tests, vertex / index reads; compute -> the same + indirect; transfer -> the same) - the same dependencies, none of the drain. Nothing written since the last barrier: no barrier at all. - Writers tracked in the main command buffer: pass stores (vk_end_pass), dispatches, texture copies / blits / resolves / uploads, readbacks, feedback snapshots, alias and arena copies, the post passes. Reset by a full barrier there and by a waited-on submission; kept across the async chunk submissions inside a frame (that missing link was the flickering). - LARECOMP_VK_PASS_BARRIER: 0 none (as NO_PASS_BARRIER), 1 scoped (default), 2 the old full barrier. versionCode 44.
|
Thanks for sharing all this work on the Helio G95. As it is, I can't merge it: besides the conflicts, the package rename and the README removal are things upstream keeps as they are, and a few changes would break other phones. Some of the ideas are worth having, though, as separate small PRs on current main: Would be welcome as their own PR:
Won't come in:
If you send any of the first three, please base it on current main and include the measurements. |
|
Thank you for taking the time to go through it in that much detail - the counter-scaling factor inversion, the MT6769/G95 mix-up and the uclamp note were all news to me, and the jobs point about the 2-vs-6 calibration was exactly right. Understood on the rename, the README removal, the version bumps and the NCE-by-default: they're gone. #417 is closed - I'll keep my fork's package name local to it. The three you said would be welcome, redone on current main as separate PRs:
All three carry the measurements from the G95. If you'd rather have any of them smaller (say, the barrier PR without the dchain change, or the fast build without the launcher wiring), say so and I'll split them. |
Note for the maintainer (please read first)
com.botwrecomp.android→com.zbotw.recomp, so my fork installs beside the original app instead of over it. The final name is yours to pick.scripts/rename_package.sh(added in this PR) does the whole rename in one command — applicationId/namespace, the java source dirs, the 21 JNI symbol names,shortcuts.xml, the ACTION strings and the run scripts'adbpaths. SetNEW_ID/NEW_Jat the top and run it with whatever name you want for upstream, or tell me the name and I'll rebase this PR with it. If you'd rather have the rename as its own commit, say so and I'll split it before you merge.README.md/README.pt-BR.mdare removed in my fork (commit d0ae3f8). If you want them kept upstream, I'll restore them in this PR.Summary
Two commits on top of 0.4.1-beta, all tuned for one device — Helio G95 (2x Cortex-A76 @ 2.05 GHz + 6x Cortex-A55, Mali-G76, 8 GB RAM). No UI, app-name or resolution changes; everything is internal.
The 0.4.3 problem in detail: the import compiled every generated function at
-O1up front, under a 2-compiler cap, plus a cold scan — all before the player could reach the title screen. The fix: build everything at-O0first so play starts in minutes, record which functions the player's session actually runs (the project's own fnprof profiler), then quietly rebuild just those hot functions at-O1in the background while the game is not being watched.What's changed
0.4.2 — Helio G95 performance build (native / NCE tuning)
runtime/g95_perf.c(new) — detects the SoC (mt6769 / mt6785), finds the A76 cluster from cpufreq, pins the render thread to it, sets auclamp.minfloor (512) on every runtime thread, and advises the game's code and stubs resident (madvise WILLNEED). A no-op on every other SoC;LARECOMP_NO_G95=1restores stock behavior.runtime/native.c— the guest counter scaled into the Switch's 19.2 MHz tick (64.64 fixed point, runtime read path only, no rewriter change), so game clocks and the frame pacer keep console time on a Helio counter rate. Native mode (NCE) is on by default; the menu toggle still wins.runtime/nvn/vulkan/exec.c— the GPU progress waiter thread is on by default for Mali (a timeline value read blocks in the kernel until the GPU catches up — without it the render thread stalled after every submission); the transient ring uses 32 MB chunks on Mali (no device-local memory).runtime/platform/android.c— the render-thread pin and the shared uclamp call go through the G95 profile first.CMakeLists— the runtime is built with-O3 -march=armv8.2-a -mtune=cortex-a76 -ffp-contract=fast; march stays at plain v8.2 (no+lse/+fp16/+dotprod) so every instruction also runs on the little A55 cores — no SIGILL.0.4.3 — Fast game import + package rename
Fast first build (
GameBuildOpts.fast,runtime/gamebuild.c)-O0and the cold scan is skipped entirely — play starts in minutes.-O1memory, and-O0jobs are far lighter; memory floors drop to 512 / 768 MB to match.LARECOMP_GAMEBUILD_MAX=<n>caps it.g95_pin_pid_biging95_perf.c) on Helio G90-family SoCs, where the-O0compilers no longer need them.Background -O1 upgrade (
runtime/ui/launcher.mm)-O1, the restoptnone— while the currently-loaded library stays untouched until the new one is complete; a failed upgrade changes nothing.LARECOMP_NO_UPGRADE=1disables the whole scheme (the fast library is then simply kept).Package rename — see the maintainer note above:
com.zbotw.recompeverywhere (applicationId/namespace, java package, the 21 JNI names,shortcuts.xml, ACTION strings, run scripts' adb paths), plusscripts/rename_package.sh.versionCode 43.
Why this shape
-O0everywhere would cost too much performance long-term;-O1everywhere is what made imports take an hour and a half. Profiling the actually-played session (instead of a synthetic cold scan) gives exactly the small set of functions that need-O1.-O0jobs have a much smaller memory footprint than-O1jobs, so the old 2-job ceiling — calibrated for-O1— left the SoC idle during import.-O0the compilers stop competing for those cores; the single-threaded generator was the serial bottleneck.Compatibility
LARECOMP_NO_G95=1LARECOMP_GAMEBUILD_MAX=<n>LARECOMP_NO_UPGRADE=1-O0library, never auto-upgradeTesting
libmain.so.run_boot.sh,run_burst.sh,run_frames.sh, …) were updated to the newadbpackage paths.PR stats
2 commits, 37 files, +579 / −496 (395 of the deletions are the two removed READMEs).