Repository navigation
Mega batch of performance improvements: phones and desktop, benched before and after. - #948
Merged
Merged
Conversation
The reports that named "the lifted function entered most recently" from Ctx::fn (unknown SVC, svcBreak, unmodelled system registers, failing exclusive stores) now look the function up from the host return address with guest_function_of, the lookup the crash report already uses. guest_svc keeps its host return address in a thread-local for the SVC reports. A freeze report of a thread that cannot be suspended names the function of its guest lr. This lets the lifter drop the c->fn store from every lifted function (next commit).
Every lifted function began with c->fn = <entry>: a 40-bit constant built in three or four instructions and a store, on every call. Only reports read it, and they now find the function from the host pc. On a Google Tensor G2 the store's instructions held about 1 % of the samples of the hot lifted code, and the game library's text is 2.2 MB smaller. Ctx::fn stays for the layout. The lifted code changes, so players run Set up again once (saves and shaders are kept).
…Android The guest kernel takes an SRW lock on every sync SVC (g_k), every handle lookup and every write-watch fault. The shim built it from a pthread mutex plus a condition variable: a mutex round trip per call and a condition broadcast per release. bionic's broadcast always enters the kernel (glibc's skips it when nobody waits), so on a phone every lock release was a futex system call, and every release woke every thread waiting for the lock. About 20 % of the game process's CPU time on a Google Tensor G2 was kernel time. Linux and Android now use musl's rwlock algorithm on the lock's own storage (an uncontended acquire or release is one compare-and-swap; a release wakes only when somebody sleeps: one thread after the last shared holder, all after the exclusive holder) and a sequence-word condition variable that enters the kernel only when it has sleepers (os_posix_futex_sync.cpp). macOS keeps the pthread version in os_posix_sync.cpp. The lock follows musl's pthread_rwlock (MIT); musl's notice is in runtime/THIRD_PARTY_NOTICES.md and tools/release/licenses/LICENSE.musl.MIT.txt, and the APK's licence list carries it.
The guest's core pinning does nothing on Android (SetThreadAffinityMask is a no-op in the POSIX shim), so the job workers, the game thread and the render thread float over every core. Each runs at 20-40 % of a core, so the scheduler keeps them on the little cores at low clocks while the frame waits on them: on a Google Tensor G2 the job workers spent 60-77 % of their run time on the A55s. An Android performance hint session (ADPF, API 33+, looked up at run time) now holds every thread that used 5 % of a core or more in the last second (re-checked each second, setThreads on API 34+), with the phone's 30 fps limit as the target and every presented frame's interval reported. The platform raises their clocks and core class only as far as the frame needs and lowers them when frames beat the target. Timing only. Google Tensor G2 / Mali-G710, Res 15 uncapped, hot-swap A/B, 10 pairs: shown fps 16.84 -> 19.09 (+13.4 %, p 0.0005), median frame 58.5 -> 51.4 ms (-12.2 %, p 0.0002). Snapdragon 8 Gen 3 / Adreno 750, 9 ABBA pairs: fps +4.6 %, median frame -3.6 % (p < 0.0001). [sched] phone_hint = false turns it off.
…ones spin 50 us first The shim's condition variable woke a waiting guest thread with the kernel lock held, so the woken thread slept a second time on that lock before it could run, and on a phone each wake also paid the little cores' latency. Linux and Android now default to [kernel] sync_wait = address (the futex: the waker sets the thread's flag under the lock and wakes it after the release, and the woken thread returns without the lock), and phones to [kernel] sync_spin_us = 50 (the thread watches its word for 50 us before it blocks: most wakes come within that). Windows, and so Proton, keeps cv. Snapdragon 8 Gen 3 / Adreno 750, Res 15, live A/B, 12 pairs: shown fps +14.5 % (95 % CI +13.1..+16.0 %, Wilcoxon p 0.0005), median frame -12.8 %, process CPU per frame -4.5 % (p 0.03). A Zen 3 laptop (RADV) under Linux, address alone, 4 runs ABBA: +3.3 % fps; wake to running for condition-variable waits p90 80 -> 30 us.
host_import resolves its import id on every call. Desktop checked the symbol's name (a load from the module's symbol table, another cache line) before the answer cache; phones already read the cache first. The name is now read on a miss only; a cached answer implies a named symbol, so the result is the same. import_resolve was about 0.7 % of the guest threads' CPU samples on the desktop outdoors.
On desktop every nvnCommandBufferBarrier ended the pass and recorded a full all-commands barrier. barrier_bits (with tex_keep and barrier_dedupe) keeps a pass open across ordering and texture invalidation when its draws wrote only their attachments, and narrows or drops the barrier after transfers or when nothing was recorded since the last one; the GPU work record (vk_work_track.h) now wraps the Vulkan commands everywhere. A Zen 3 laptop (RADV), 1080p, live A/B in one run (14 windows of 10 s): full barriers 278 -> 157 a frame, render passes -16 %, GPU time -0.6 % (paired t -3.1), render thread -0.1 ms. [nvn] barrier_bits = false keeps the old path.
prepare_textures ended the pass and then recorded one vkCmdPipelineBarrier2 per image whose layout changed before a draw. When nothing there uploads, phones already collected them with the pass end into one barrier (barrier_batch); desktop now does the same. The merge is exact: each image barrier keeps its own masks and layouts inside the one dependency. A Zen 3 laptop (RADV), 1080p outdoors, live A/B in one run (12 + 6 paired windows of 10 s): render thread 14.7 -> 14.45 ms a frame (-1.7 %, paired t -3.1 and -2.0), GPU time unchanged (+-0.1 %). The A/B name barrier_batch switches it off.
…platform The stencil is 8 bits, so only the low byte of a ClearDepthStencil mask counts. Desktop compared the whole word with 0xff, so a full mask of 0xffffffff counted as partial and the clear became a full-screen depth and stencil draw in a pass of its own (log: "ClearDepthStencil with a partial stencil mask ... ffffffff"), as on phones before. Both now take the mask's low byte: a full one is a vkCmdClearAttachments (or a folded LOAD_OP_CLEAR), a zero one clears no stencil bit. A Zen 3 laptop (RADV), 1080p outdoors, live A/B in one run (8 paired windows of 10 s): GPU -0.8 % (paired t -3.9), render thread -0.26 ms, game thread -0.25 ms (t -9.4), frame rate +1.1 %.
A storage buffer a shader may write is recorded as written in full, and the landing copied all of it back into guest memory at the end of its submission, although a shader often writes little of it. The landing now compares each page of a record of more than a page first (one fault guard) and lands only the runs that differ: no copy, no write-tracker protection change and no write-watch write for a page that already holds the GPU's bytes. The bytes in guest memory are the same. Google Tensor G2 / Mali-G710, Res 15 uncapped, live A/B in one run (12 pairs): 0.56 % of the landed pages differed; landing thread 4.95 -> 4.47 ms a frame, game thread -0.65 ms (p 0.022). [nvn] pool_land_diff = false keeps the full copy.
A bind scans every page of its range in its pool copy, and a page the write tracker found current cost three loads (one acquire) and a tracker call at every bind of every submission. Such a page is now marked as serving every submission queued so far, the same as a copy made at that moment (pool_copy_once_queued), so later binds test one word until the game queues a newer submission. A GPU write recorded through another copy lowers the mark as it lowers a copy's. Google Tensor G2 / Mali-G710, Res 15 uncapped, live A/B in one run (12 pairs): render thread -0.83 ms a frame (-3.2 %, p 0.11), pcopy_touch and ptrack_current 0.64 -> 0.56 % of all CPU samples. [nvn] pool_touch_mark = false keeps the old scan; A/B name touch_mark.
Images with VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT (RGBA8 and sRGB, BGRA8, the 32-bit integer and float formats) are now created with a VkImageFormatListCreateInfo holding exactly the formats format_view_ok allows: the format and its sRGB/UNORM partner, or the format and its float/uint/sint aliases. Without a list a driver has to assume any format of the size class: Turnip on Adreno 7xx then turns UBWC off for the image (tu_image.cc, is_mutable path), and RADV and Mali can lose DCC/AFBC. The views are the same either way. [gfx] format_list = 0 goes back to no list.
… is compressed With [prof] image_compression = 1 the device enables VK_EXT_image_compression_control (when offered) and every image created with colour or depth attachment usage (64 wide or more, the first 400) logs its size, format, usage, flags, view format list and whether the driver compresses it (UBWC on Turnip, AFBC on Mali, DCC/HTILE on RADV). Off by default; no change otherwise.
Every uncompressed 2D colour image was created with storage usage in case it is bound as a storage image (NVN's IMAGE flag is set on render targets that are never stored to). Storage usage costs the image its framebuffer compression on several GPUs (RADV DCC, Mali AFBC). [gfx] storage_lazy (default on): a 2D colour image gets storage usage when prepare_textures first binds it as a storage image; it is remade then with the usage (the feedback-loop remake, shared as remake_with_usage: same shape, every level and layer copied, old image freed after the GPU is done). Only a handful of images are remade, once each. 3D images keep storage usage at creation.
… on by default game::Render::cs_variants names compute programs the back end may run as a variant with bit-identical results, made at pipeline creation as the module of a second pipeline (the shader cache is untouched, no shader is translated again): - Retile (spirv_retile): a smaller workgroup over the same grid. Only when the module derives its cell solely as WorkgroupId * LocalSize + LocalInvocationId in x and y and has no other built-in, shared memory, barrier or subgroup operation; the dispatch gets proportionally more groups (within maxComputeWorkGroupCount). [nvn] cs_retile (default off), [nvn] cs_retile_size (default 8x8). - VoteAllFalse (spirv_vote_all_false): the module's one subgroup all-vote becomes false, for a program whose lanes never share the address the vote compares, so the per-lane atomic it falls back to adds the same values. [nvn] cs_vote. The game layer names one program of each kind (pkp_render_info.cpp). [nvn] cs_vote defaults on where the hardware subgroups are at least 32 wide. Byte for byte against the original program on the same inputs: Snapdragon 8 Gen 3 / Adreno 750 58 of 58 results identical, a Zen 3 laptop (RADV) 237 of 237 (and 472 outputs of the retiled program). On Google Tensor G2 / Mali-G710 (16-wide subgroups under the 32-lane emulation) one result in 6 differed and the dispatch showed no gain, so Mali keeps the original program. Snapdragon 8 Gen 3, live A/B, 6 clock-clamped pairs: GPU cycles per frame -3.35 %, fps +3.5 %.
…ult on phones A game whose shadow map is a square depth-only target holding a near and a far cascade, one per horizontal half, can say so (game::Render::shadow_halves, with which half is the far one); the game layer opts in. [gfx] shadow_half = 1 then keeps the far cascade from the previous frame every other frame: the clear covers only the near half and the far half's draws are skipped, while those draws looked the same in the two frames before (their number, programs, viewports and scissors, in any order) and the camera block the G-buffer draws bind was byte-identical in those frames (read only when no GPU write is in flight over it; unreadable counts as a change). Any change draws it every frame again; a far caster that moves is at most one frame late. Not bit-exact. A game without shadow_halves never takes this path. It defaults on on a phone (host_is_phone) and stays off on a desktop. The choice is controls.ini [display] shadow_half (auto, on, off; auto means phones only), with a "Far Shadows" row in the game's Settings > Graphics: Every Frame / Every Other Frame (Faster), next start. It becomes [gfx] shadow_half at start unless the ini or the environment already set that key, so an existing ini value keeps winning. Snapdragon 8 Gen 3 / Adreno 750, 7 ABBA pairs: about 2.9 % fewer GPU cycles a frame. CONFIG.md and controls_schema.json come from the settings doc tool; the [gfx] shadow_half row of CONFIG.md is written by hand.
The shader cache's SHA-1 (the Sha1 class: the portable loop and the CPU's SHA instructions) moves from nvn_shaders.cpp to nvn_sha1.cpp, with the intrinsics headers only it uses; sha1_hex and shader_hash stay. The code is unchanged. nvn_shaders.cpp was over 100 KB and keeps the reflection, the harness records and the runtime cache.
…beside it Reflecting the preload pack's shaders walks all of their SPIR-V after decompressing it, on every launch. <dir>.preload.pack.refl holds reflect_spirv's result (before the resources record) for the entries of one pack generation, identical records stored once, keyed to the pack index's FNV-1a digest, size and entry count and a schema number, with an FNV trailer, bounds-checked lengths and range-checked enums. A preload hit reads no SPIR-V at all; a miss, a stale entry or an unreadable file takes the parser as before, and the first run with a new pack writes the catalogue when its preload is done (atomic rename). The catalogue lives in nvn_shaders_refl.cpp; the file helpers it shares with the cache (read_file, pack_path, fnv1a64, widen, now_ms) are declared in nvn_shaders_internal.h. [nvn] refl_catalogue = 0: never read or written. [nvn] refl_catalogue_verify = 1 (diagnostic): every answer is also reflected by the parser and compared. A Zen 3 laptop, RADV (12 alternating launch pairs to the title): process CPU -8.7 CPU-s (-13.1 %, paired t p = 0.0007, Wilcoxon p = 0.012), elapsed -1.95 s median; a verify run found no mismatch.
…2 MiB of spare shadows A pool copy shadow is a whole cell, so a bind that touches a few pages of a cell holds the whole cell in GPU memory: with 2 MiB cells, 440 MiB of shadows were live outdoors and only 145 MiB of them held a copy. Phones that copy pools without AHardwareBuffers (pool_ahb off) now default to 512 KiB cells and a stock of 32 MiB of spare shadow buffers (128 MiB before); desktops and pool_ahb keep their defaults. [nvn] pool_copy_cell_kb (256 to 1048576, a power of two, wins over pool_copy_cell_mb) sets cells below 1 MiB; the start line logs the cell size in KiB. Google Tensor G2 / Mali-G710, outdoors: Graphics memory -562 MB, private dirty -530 MB, the same fps, CPU time and frame tails, and the house to outdoors load no longer ends in a low-memory kill.
… use logged Each submission slot has an 8 MiB upload ring (36 slots: 288 MiB of GPU memory); an upload that does not fit takes a staging buffer of its own. [nvn] upload_slot_kb (64 to 8192, default 8192) sets the ring size. Every 5000 submissions the log has the ring use per submission (p50, p90, p99, max, and the share over 2, 3, 4 and 6 MiB) and the staging uploads it caused and their CPU time. The default size is unchanged. The rings' size, buffer usage and statistics live in nvn_gpu_upload_ring.cpp; the slots that own the rings stay in nvn_gpu.cpp.
…pages back to the kernel Off by default. On Linux and Android a zero fill of at least 1 MiB gives the whole host pages inside it back to the kernel instead of writing zeros into them, so they read as zero without being resident. A section heap ([memory] heap_section, the phones' default) is a shared mapping, so MADV_REMOVE punches the pages out of it; private memory takes MADV_DONTNEED, after which any page that kept its contents gets the plain memset. The write tracker is told first, as for a file read into guest memory, so the result is the memset's in every case. Decommitted pages, of the section heap and of the host mapping, leave memory too (a later commit reads zeros, as on Windows); before, they stayed resident. A Zen 3 laptop (RADV) with the phone memory profile (section heap): resident memory at the title -0.51 GB, outdoors -0.29 GB.
…wapchain at screen size Off by default. On a phone whose low-memory profile caps the render targets below 100 %, [gfx] small_targets = 1 keeps the 3D targets at the player's percent as under present_scale while the swapchain stays at the screen's size, so the 2D ([gfx] ui_native) stays at the screen's resolution.
…le_s) The report's one-frame pass sample (GPU timestamps between the render passes of a frame) was only taken on discrete GPUs, from the GPU-bound verdict. On a phone, [prof] pass_sample_s = N now takes one every N seconds and logs every pass kind (64 rows instead of 10), without the frame trace, whose writer falls minutes behind on a phone. Off by default; desktop objects keep the 10 rows.
…y measured time [gfx] vulkan_driver_env = NAME=value;NAME=value is set in the game's own process before the custom Vulkan driver loads. Mesa reads its options from the environment before the system properties, so Turnip's TU_DEBUG, TU_AUTOTUNE_ALGO and driconf options can be tried without touching anything on the phone (TU_DEBUG=perf logs why LRZ or GMEM was turned off). The default is TU_AUTOTUNE_ALGO=profiled: Turnip chooses GMEM or direct rendering for each render pass by the GPU time it measured for both, instead of its bandwidth estimate. Adreno 750 (Mesa 26.3.1) at its thermal clamp (231 MHz, GPU busy 97-99 %), cold starts at one spot, profiled against the default in turns: GPU Mcycles per frame 7.65 / 7.78 / 7.59 against 7.91 / 7.89 / 7.95 / 7.83 (about -3 %), 29.58 / 29.23 / 29.12 fps against 28.90 / 28.63 / 28.78 / 28.60. The render mode does not change the picture. Tried the same way and left out: tu_allow_concurrent_binning (28.57 fps, 8.01 Mcycles), tu_independent_icache_miss (within the noise).
…next used (edge_lazy) The phone edge guard copies the scene part's last column and row into the band past it after every pass whose viewport is the part: two full barriers, a move to GENERAL and back, and the copies, many times a frame. Most such targets are drawn by several passes in a row, and only the last guard counts. The guard of a target now waits until the target is used another way (a layout change: sampled, copied, cleared on its own, its image remade, through the clear carry's touch hook), until a pass on it may draw past the part, or until the end of the command buffer. A pass that lets a guard wait must keep to the part: a later draw or clear past it ends the pass, and the guard goes before the next one. A pass that begins the target with LOAD_OP_CLEAR drops the waiting guard (the clear covers the band). Same picture: nothing writes the band between the pass and its guard, and every reader of the band comes after it. [gfx] edge_lazy (default on) turns it off. Adreno 750 at its thermal clamp (231 MHz), hot-swap A/B at one spot, 14 adjacent pairs of 30 s: guards 20 a frame fewer, GPU Mcycles per frame -2.1 % (t -1.9), fps +1.7 % (t 2.8); a null A/B on the same setup moved -0.7 %. The right edge of the picture is the same on and off.
On a Tensor G2 the call glue between lifted code and the runtime was about 10 % of the process's CPU samples: dispatch_call alone 4.4 %, the dynamic linker's TLS resolver 1.6 %, then import_resolve, count_import and hle_leaf_fn. - The Android lifted code keeps a cache per call site (recomp/native/nx_native_call.h). An indirect call site remembers the slot of its last target in the runtime's function table (nx_fn_slots, nx_fn_index) and calls it directly while the slot still holds that address. A site with several targets stops looking after 8 misses. An import stub keeps its leaf handler (nx_import_leaf) for as long as the import epoch is unchanged. - The context caches of dispatch_call and host_import probe 4 slots. A context whose hash slot was taken had fallen back to the thread_local cache: two TLS resolver calls per indirect call. - dispatch_call's hit path needs no stack frame (the rest is out of line). - Phones no longer count imports or hook-site calls per thread (thread_local, a resolver call each; the counts only fed a summary line). Desktop builds are unchanged. The two new runtime exports are only used by the Android lifted code.
Three mid hooks in the game layer let an idle job worker yield and then nap on phones while it has nothing to claim; guest state is never written. About +30 % process CPU saved in some long sessions on a Tensor G2.
The live A/B switches of the measured changes are removed, each answering its default as before: barrier_batch and barrier_dedupe (always on), barrier_bits ([nvn] barrier_bits), land_diff ([nvn] pool_land_diff), touch_mark ([nvn] pool_touch_mark), cs_vote and cs_retile ([nvn] cs_vote, [nvn] cs_retile) and edge_lazy ([gfx] edge_lazy). The ini keys stay. Without [diag] ab_name set to one of these names the code does exactly what it did; the upload_ring switch never landed (the upload rings keep one size for the whole run). Still switchable: tex_keep, pool_ring, ro_store_none and dr_thermal (upstream's).
[memory] zero_reclaim, [gfx] small_targets, format_list and storage_lazy, [nvn] refl_catalogue, refl_catalogue_verify, cs_vote, cs_retile, cs_retile_size, pool_copy_cell_kb and upload_slot_kb, and [prof] image_compression get their rows; the pool_copy_cell_mb and pool_copy_spare_mb rows give the phone defaults.
An Unreleased entry for players: smoother and faster to load on phones, less graphics memory on phones without AHardwareBuffer pools, the Far Shadows row; Set up again once, no shader rebuilt.
[memory] zero_reclaim now defaults on on a phone whose guest heap is a shared section (a memfd or file-backed heap, heap_has_section: the low-memory profile of phones such as the Tensor G2 ones), where MADV_REMOVE gives the pages of a zero fill or a decommit back to the system. It stays off on phones with a private heap (the Snapdragon 8 Gen 3 profile) and on desktops. An ini or environment value still wins. The decision is mem::zero_reclaim_on() (nxrt/memory.h), read by the zero fill, the heap decommit and the POSIX shim's VirtualFree; it takes no lock, so the heap decommit can ask it under the heap lock. The CONFIG.md row and the CHANGELOG line say so. Google Tensor G2 / Mali-G710, outdoors, 3 pairs: no fps or CPU cost, PSS about -150 MB (not significant), private dirty and Graphics memory flat. A Zen 3 laptop (RADV) with a shared-section heap: resident memory -0.29 GB outdoors to -0.51 GB at the title.
Collaborator
Author
|
Hey @featureJosh this PR took about 3 days of work and testing. It was both Codex+Claude challenging each other on crazy optimizations. On my tests the performance on the Mali phone went up +50% (or more, in some places it doubled the FPS), on the Snapdragon +20/25% and on an AMD laptop +7%. The startup time of the game also got shorter ~3 to 15 seconds shorter depending on the device. I did not notice any regression or anything breaking, but of course, there is a chance. I played a few hours on this only. There is another +10% CPU optimization that I'll be opening as a follow up PR but it will be opt-in only because it makes the build time increase by ~x2.5, so it's a trade-off but totally worth it for midrange phones or low-end laptops. |
On a Mali-G710 (vendor ARM, 0x13b5), creating colour images without storage usage and remaking them on the first storage bind brings tile-shaped garbage at the right edge of the picture at low render resolutions, worst while the camera moves, and no speed gain was measured there. Default off on Mali GPUs; Adreno (Qualcomm) and desktop GPUs keep it on (Adreno 750: -1.14 % GPU cycles per frame with the format lists). [gfx] storage_lazy in the ini still wins.
On phones, the end of a pass and the layout changes that follow it can be collected into one barrier command (barrier_batch). The edge guard runs from a layout change's touch hook or at the end of a pass, inside such a batch, and recorded its vkCmdCopyImage at once while its memory barrier and its change to GENERAL were still held for the batch: the copy ran before the pass that drew the target was made visible, with the image still in its attachment layout. With compressed targets ([gfx] storage_lazy) a Mali-G710 then wrote corrupt blocks into the band right of and below the scene part, shown as black, pink, blue, cyan and yellow tiles at the right edge of the picture at low resolutions, worst while the camera moved. Uncompressed targets hid it. The touch hook and the guard now record the barriers collected so far, then their own commands with their barriers, and open the batch again (BarrierBatchPause). The touch hook's carried clears get the same order. A standalone probe of the guard's copy with correct barriers matches every pixel on the Mali-G710, compressed or not.
This reverts commit 2ee1acb. The right-edge tiles on a Mali-G710 came from the edge guard's copies running before their barriers (fixed in the commit before), not from the compression itself. [gfx] storage_lazy is on by default on every GPU again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters (TL;DR)
The game spends a surprising amount of every frame waiting: threads sleep on locks and wake late, the phone's scheduler keeps the CPU at low clocks because nobody tells it a game is running, and on phones the GPU memory copies cost hundreds of megabytes. This PR fixes those, plus a set of smaller CPU and GPU savings, and measures all of it together against upstream main on real phones. On a Snapdragon 8 Gen 3 it plays about 25 % smoother at the resolution people actually use (1 % lows +40 %), loads into the world about 20 % faster, and needs 12 % fewer CPU cycles per frame. Nothing changes how the game looks on desktop; on phones, distant shadows may update every other frame while the camera stands still (Settings > Graphics > Far Shadows).
What it changes
Waits and scheduling
[sched] phone_hint): the game's busy threads report their frame work, so the scheduler raises clocks for them instead of guessing from load.CPU
c->fnstore at every lifted function's entry: crash reports name the function from the host pc; lifted code 2.2 MB smaller.GPU
[gfx] storage_lazy; on everywhere);[prof] image_compressiondiagnostic.[gfx] vulkan_driver_env);[prof] pass_sample_sdiagnostic.[gfx] shadow_half, Settings > Graphics > Far Shadows): for a game that describes its shadow map (this game's layer opts in), the far cascade is redrawn every other frame while it and the camera stand still. Not bit-exact (a distant shadow can lag one frame), so it is on by default only on phones; desktop keeps every frame. The finals below were measured with it off.Start-up and memory
[nvn] refl_catalogue): pipeline reflection is stored next to the preload pack instead of recomputed at every launch.[nvn] upload_slot_kb, with their use logged.[memory] zero_reclaim: large zero fills and decommitted pages go back to the kernel; on by default on phones whose guest heap is a shared section, off elsewhere. The finals below were measured with it off.[gfx] small_targetskeeps the low-memory 3D targets with the swapchain at screen size.Results
Every number below is BEFORE = upstream main
c03698f2, AFTER = this PR (the measured phone game library was also built with a local profile-guided layout, worth about 10 % CPU cycles per frame on the Snapdragon 8 Gen 3; that part is not in this PR and comes as its own opt-in build option), everything at its default (soshadow_halfandzero_reclaimoff), cold launches in block ABBA order, same save and spot, no walking.Snapdragon 8 Gen 3 / Adreno 750 (Turnip), hot, 3 pairs per setting
fps columns use the two clock-matched pairs (both builds at the same throttled clock); cycles per frame use all three pairs. No crashes on either build.
Google Tensor G2 / Mali-G710, outdoors, 3 pairs per setting
The phone ran hotter during the AFTER legs (big-core cap 1.5-2.3 GHz against 2.8 GHz for BEFORE), so the fps rows understate AFTER rather than flatter it. No crashes. Indoors (3 more pairs per setting): +146 % fps at Res 15 (display limit), +75 % at Res 100, +22 % at Res 50 (at the cap), 35-58 % less CPU time per frame.
Zen 3 laptop (RADV), desktop build, outdoors, 3 pairs per setting
Every mean favours this PR on desktop, but with 3 pairs the differences are within the noise (p 0.24 to 0.36); the phone-only parts (performance hint, phone pool defaults) do not apply here.
Per-change measurements
Each change was also measured on its own, with larger paired samples, before it went into the stack.
c->fnstorezero_reclaim(on by default on shared-section heap phones)For players
CHANGELOG.md## Unreleasedhas an entry (Before / Now / Still not)c->fnstore at function entry) and the runtime is relinked; saves and shaders are keptPros
Cons