Repository navigation
Description
Summary
In METAL GEAR SOLID 4 (PPSA18194) on the Kyty backend, about 19 % of kytyGpuExecute's time is memory tracking in user code (MappedPrefix, GuestReadLog::StillValid, Shim::IsBacked, IsRegionCpuModified), and another 2–4 % is write-tracking faults, mprotect and the TLB-flush interrupts they cause. Binding and descriptor work is about 14–15 %.
A suggested design is below the measurements.
Measurements
Linux (CachyOS, kernel 7.3), Ryzen 7 7800X3D, RTX 4090 (NVIDIA 620.70.06). AnyKyty at 177ca381a1 plus #19, #23 and #27. Act 1, standing still, two spots, 30 s each, warm shader and pipeline caches. Uncapped: ANYPS5_VBLANK_HZ=360 KYTY_VBLANK_FREQUENCY=360 ANYPS5_FPS_LIMIT=360 APS5_UNPACED_FLIPS=1 KYTY_PRESENT_MODE=Immediate, and the game's own frame limiter patched out (its wait period set to 0) so the frame rate is not held at the game's target.
| MGS4 Act 1 | FPS (mean) | FPS (median) | 1% low | Worst frame | GPU busy |
|---|---|---|---|---|---|
| Spot A | 199.5 | 204.0 | 130 | 8.31 ms | 78 % |
| Spot B | 173.6 | 176.6 | 130 | 7.90 ms | 69 % |
kytyGpuExecute, 10 s perf record at 3 kHz:
| Share of samples | Spot A | Spot B |
|---|---|---|
Waiting for work (SpscQueue::WaitForElement) |
14.8 % | 11.6 % |
| Memory tracking, user code | 19.3 % | 19.5 % |
| Kernel | 6.8 % | 4.1 % |
Binding and descriptors (CommitBindings, RebindBuffers, templates, push descriptors) |
13.7 % | 15.2 % |
| Other draw work | 39.1 % | 43.0 % |
| libc, clock | 5.7 % | 6.0 % |
Memory tracking at spot B: MappedPrefix 7.5 % (about half from ClampRangeSize on buffers that reach past mapped memory, the rest from IsFullyMapped), GuestReadLog::StillValid 5.1 %, Shim::IsBacked 4.5 %, IsRegionCpuModified 1.0 %.
Kernel, resolved against /proc/kallsyms (spot A / spot B): mprotect 2.4 % / 1.0 %, TLB-flush interrupts (sysvec_call_function) 1.6 % / 1.5 %, write-fault handling and signal delivery 0.9 % / 0.3 %.
Page faults (perf stat -e page-faults, 5 s): spot A 6,250/s on kytyGpuExecute and 20,400/s for the process; spot B 2,730/s and 17,300/s.
Suggested design
A general direction, not a finished plan; the details depend on what each existing check guards.
- One owner record per guest range. A single table, keyed by fixed-size blocks (for example 64 KiB), says who owns each range and how much of it is mapped: CPU, a pending GPU write, a render target or depth surface, or nothing. The per-draw checks that now ask separate questions (
Shim::IsBacked,MappedPrefix,IsRegionCpuModified) read this one record instead, including the mapped length thatClampRangeSizerecomputes for the same buffers on every draw. Readers do not take a lock; writers publish changes. - Versions instead of re-checking. Each block has a version that any write to it bumps (CPU write fault, GPU write, unmap). A cached draw, template or resource keeps the versions of the blocks it read. To revalidate, it compares those versions; only on a mismatch does it run the full check that
GuestReadLog::StillValiddoes today. A version moves only when the block's state changes, so repeated writes to an already-dirty block cost nothing. - Fewer fault round trips. A write fault marks the block dirty, bumps its version and leaves the block writable. Dirty blocks are re-protected in one batch when their contents are next consumed (at submission or the next revalidation), and only then read, so a write that lands after the re-protection faults again and is not lost. This also cuts the TLB-flush interrupts each
mprotectsends to other cores. It is the smaller part here (2–4 % ofkytyGpuExecute). - A verify mode. A switch that runs the old checks next to the new answers and stops on any difference, so each step can be validated in game before the old path is removed.
Steps, each measured like the tables above: owner record behind a switch with verify mode; versions for draw and template revalidation; batched re-protection; then remove the old checks the record replaces. The adaptations would live in the shim or under #if defined(ANYPS5_KYTY), so the imported files stay re-importable.
Method and limitations
- AnyPS5's trace capture (
APS5_TRACE_DIR,aps5-summary.jsonl,tools/trace_digest.py) is stubbed out in the Kyty backend (KytyShim/src/EntryHost.cpp,AgcDriverTraceRecordingreturnsfalse), so these numbers come from MangoHud andperfinstead. - FPS, 1% low and worst frame come from a MangoHud log at 100 ms intervals, so the 1% low and worst frame are approximate.
- Shares are self time per function, grouped by name; the groups are approximate.
- One session, two spots; the spots differ in scene, so the two columns show the range, not a controlled A/B.
- The game executable was patched only in its frame limiter.
Activity
[-]perf(kyty): memory tracking takes up to 40 % of kytyGpuExecute in MGS4[/-][+]perf(kyty): memory tracking takes about 20 % of kytyGpuExecute in MGS4[/+]Raghav314 commentedon Nov 17, 2026
Corrected the description. The first version put
kytyGpuExecute's kernel time (up to 24 %) down to write-tracking faults. Resolving the kernel samples showed it was almost allwrite()calls from the per-draw clamp message inClampRangeSize. #27 fixes that: at spot B it goes from 124 to 174 fps. The numbers above are measured again with #27: memory tracking is about 20 % ofkytyGpuExecute, not up to 40 %.simnJS commentedon Nov 17, 2026
Thanks, these numbers line up with what we measure on Subnautica. Two pieces of this are already in progress on our side, so here they are to avoid overlap:
feat/kyty-eager-readbackstops protecting, faulting and reading back, on every frame, the ranges a compute pass writes and the CPU then reads. Instead it reads them back ahead of the CPU, before the label. The ceiling measured on Subnautica is +15.7 % fps. It's under review and not merged yet.Your read-path part, the owner record per block with
MappedPrefix,IsBacked,StillValidandIsRegionCpuModifiedanswered from it plus a verify mode, is not covered by either, and it's the biggest share in your profile. If you want it, it's yours; we'll keep to faults/readback and Resolve. Behind a switch with the verify mode, as you describe, is exactly what we'd want.Raghav314 commentedon Nov 17, 2026
Thanks for laying that out. I'd rather you take the read-path part as well. It touches the same page state as your readback and Resolve work, so having one owner keep the owner record, the versions and the protection in step seems simpler than splitting them between us. One thing worth deciding up front: the page versions in your Resolve prototype could be the same versions the owner record keeps, so there is one version table rather than two. I'm happy to test any of it on MGS4 and title A with the same measurements as above.
(edited by maintainer)
simnJS commentedon Nov 17, 2026
Fair enough, we'll take the read-path part too, with a single page-version table shared with the Resolve work, as you suggest. It'll start after the current batch lands; we'll ping you for MGS4 and title A runs when there's something to test.
simnJS commentedon Nov 18, 2026
We measured the ceiling before building the registry. A throwaway prototype answers every check from memoized results with no validation at all (
IsBacked,MappedPrefix,IsFullyMapped,ClampRangeSize,FindBackingPointer,IsRegionCpuModified). It gains nothing in our games:Memory tracking is about 7% of
kytyGpuExecutehere, against 19.5% in your MGS4 profile, and Execute is not the stage that limits these games.What looks specific to MGS4 is the slow path of
ClampRangeSizeon buffers that run past the mapped range:MappedPrefixis walked twice, andFirstClamptakes a lock and astd::seton every call. None of our games takes that path, so we're not building the full registry for now.If MGS4 is still slow there, a targeted fix of that path (cache the clamp result per buffer range until an unmap) should get most of it. Happy to share the ceiling prototype if you want to check it on MGS4 first.
Raghav314 commentedon Nov 18, 2026
Thanks for measuring the ceiling first. I think the difference is which stage limits the game, and title A is limited by the one your games aren't.
Title A, story mode, fixed spot, RTX 4090,
simnJS/AnyKytywith native RT plus two local fixes, heap off:kytyGpuExecutekytyGpuRecordkytyGpuResolveSo Execute is a bottleneck here: 67.9 fps, p50 14.7 ms, with the GPU waiting on it. A 10 s profile of
kytyGpuExecute(inclusive shares) shows:BufferCache::ObtainBufferReadMemoryAsync→UpdatePageWatchers→mprotectGuestReadLog::StillValidThat's about 13% of the limiting thread. Neither part is on the
ClampRangeSizeslow path: Title A doesn't take it. Your ceiling list also doesn't includeStillValidor the watcher re-protection. That is where title A spends its time:This is why I think the version model is needed rather than a per-path fix:
StillValidwould become one version compare per block instead of a walk over the logged reads.ReadMemoryAsync.In title A the protection side is what costs. So the shared page-version table is the part that matters; the memoized read checks alone wouldn't show it.
The test that would settle it is your ceiling prototype run on title A and MGS4, ideally with
StillValidand the watcher updates answered from memo too. If you can share it, I'll run both games at the same spots and post before/ceiling numbers in the same format as yours.(edited by maintainer)
simnJS commentedon Nov 18, 2026
Fair point, and thanks for the profile: if Execute is the wall in title A, our two games can't settle it, and
StillValidand the watcher re-protection weren't in our ceiling.We're extending the ceiling prototype to cover both:
StillValidanswered from a memo, andUpdatePageWatchersskipping the re-protection. Each part gets its own switch, plus one switch for everything. We'll publish it as a branch on top of the currentAnyKyty, with the switches and how to read the results, so you can run title A and MGS4 at the same spots. I'll post the link here, probably in a few hours.simnJS commentedon Nov 18, 2026
Thanks for the profile, it was very useful. Here is a ceiling build that covers
GuestReadLog::StillValidand themprotectcalls of the memory tracker, so you can measure on title A and MGS4 what they would give at most.Branch
proto/memory-tracking-ceiling: one commit on top of AnyKyty52f1faa881. Build it like AnyKyty on Linux (-DANYPS5_GPU_BACKEND=kyty, targetskyty_gpu libs relinker). The commit message lists every switch and every log line.This is a measurement build, not for playing. The levers answer from stale data on purpose: frames can be wrong, the scene can change, and a game can hang. Stray hangs while loading if write protection is skipped from the start;
KYTY_CEIL_START_S(below) avoids it.Switches (environment variables):
KYTY_REG_CEIL=all-abturns everything on and off every 10 s in the same session; this is the one to run first.allkeeps it on.on/abare the first prototype (unvalidated memo of the address queries:IsBacked,MappedPrefix,IsFullyMapped,ClampRangeSize,FindBackingPointer,IsRegionCpuModified;StillValidskipped).statsonly counts.KYTY_STILLVALID_CEIL=memo|skip:memochecks a read log once per period and then answers from a per-thread memo, with no byte comparison, noMayFaultOnGpuReadand no descriptor refresh;skipalways answers valid. (The first prototype already skippedStillValidinon/ab; it now has its own switch.)KYTY_REARM_CEIL=protected|skip: the write protection the tracker puts back after an upload (SynchronizeBuffer→ForEachUploadRange→UpdatePageWatchersForRegion→mprotect).protectedskips the call when the pages already have that protection;skipnever puts it back, so later CPU writes go unseen (the protections are applied again when a period turns off).KYTY_CEIL_AB=1alternates any of these every 10 s;KYTY_CEIL_START_S=60keeps everything off for the first 60 s after the first draw, so the game loads normally.Reading it: the
[reg] periodlines on stderr give, every 10 s,on=0|1,fps,draws_per_frame, and the CPU µs per draw and busy share of the Resolve, Execute and Record threads. Compare on=1 with the neighbouring on=0 periods, at the samedraws_per_frame. The[reg] countslines give, per thread, everymprotectof the page manager by kind with its cycles:rearm(write protection put back after an upload),wunwatch(removed after a CPU write),rwatch/runwatch(no-access protection put on GPU-written pages, and removed after a readback),otherprot. OnkytyGpuExecute, cycles ÷ draws of the period is the time Execute spends inmprotectper draw, without skipping anything.One thing we found: in the code,
ReadMemoryAsync→ReleaseReadback→UpdatePageWatchers→mprotectis the removal of a read watcher (a page the GPU wrote and the CPU then read), not the write re-protection. Read watchers cannot be skipped: when we tried, Stray stopped at once ("unknown op", the command processor read commands the GPU had written) and so did Subnautica. So this build only counts them (rwatch/runwatch). If they are what Execute pays on title A, the counters will show it, and the answer is a different design (fewer protection changes for GPU-written pages), not a ceiling.Our numbers (Ryzen 9 7950X3D, RTX 4080 SUPER, Linux, uncapped,
all-abwithKYTY_CEIL_START_S=50, 11 periods of 10 s):protectednever fires on our games (0 % of re-protections skipped): the watcher counts already avoid redundant calls.mprotectcalls cost Execute 0.07 µs per draw.mprotectcosts Execute 0.47 µs per draw (13 % of its time): 0.35 for read watchers, 0.075 for write re-protection.mprotectcosts 2 to 14 µs here (60+ threads in the process).On our games Execute is not the stage that sets the frame time, so even a ceiling gives little. Your case is different (Execute at 97 %), which is why your numbers on title A and MGS4 matter more than ours. If you can, please post the
[reg] periodlines of oneall-abrun and the[reg] countslines ofkytyGpuExecute.Raghav314 commentedon Nov 18, 2026
Thanks, I'll run all-ab on MGS4 first, then title A. I can't find
proto/memory-tracking-ceilingthough: https://github.com/simnJS/AnyPS5/tree/proto/memory-tracking-ceiling returns 404 and it isn't ingit ls-remote(only its base, 52f1faa, is reachable). Could you push it?simnJS commentedon Nov 18, 2026
@Raghav314 pushed back:
proto/memory-tracking-ceilingis at b2c87bb again (same commit, on its original base 52f1faa). It merges cleanly into the current AnyKyty.Raghav314 commentedon Nov 19, 2026
MGS4 and GTA V (uncapped, RTX 4090, Linux) on proto/memory-tracking-ceiling. MGS4 ran b2c87bb on 52f1faa as is; GTA V ran it cherry-picked onto the current AnyKyty (32b1173, applies cleanly), because on 52f1faa GTA V runs at 35 fps at this spot instead of ~115, with the GPU at 50 %, and the levers were flat there (on 34.4/34.7, off 35.2/33.6).
GTA V (Performance RT,
KYTY_REG_CEIL=ab, standing still)abgives about +6 % in GTA V, and every on period beats its neighbours. Draws per second at 2,890-3,110 draws per frame:Over all three in-game on periods (the first, 368.4 k, follows a loading period) and three off periods: 365.9 k vs 346.6 k draws/s (+5.6 %), 123.2 vs 115.5 fps (+6.7 %). Memo hits as in MGS4: clamp 48-50 %, cpumod 62 %, backed 7 %, findback 3 %, fullmap and mayfault 0 %; the address queries per draw drop from 16.4 to 10.9, mostly the StillValid → MayFaultOnGpuRead calls. So this is again mostly the StillValid ceiling.
mprotect on kytyGpuExecute in GTA V: ≈ 0.20-0.26 µs per draw (≈ 7-9 % of the 2.9 µs of wall time per draw), without skipping anything:
Unlike MGS4, GTA V pays on Execute for read watchers (removal after a readback) and otherprot (textures, image heap, strict watch), the case you describe as needing fewer protection changes for GPU-written pages rather than a ceiling. Rearm is small.
MGS4 (Act 1)
all-ab hangs MGS4 the moment it turns on, twice. With
KYTY_CEIL_START_S=60(still loading) and with=180(in game, standing still): the log stops at the firston=1period and the GPU hangs about 2 s later (Xid 109, CTX SWITCH TIMEOUT). Everyon=0period before that is clean, so there is no on period to compare. WithKYTY_REG_CEIL=ab(no write-protection skip) it runs, so the hang is the rearm skip.abin game: within the scene's drift, and the memo mostly misses. Draws per second, the throughput of the saturated Execute thread, on vs the neighbouring off periods at the same draws per frame:The later periods moved with the scene (1,830-2,490 dpf), so they don't pair. Hits per call in the on periods: StillValid skipped 100 %, clamp 60-67 %, cpumod 11 %, backed 4 %, findback 2 %, fullmap, prefix and mayfault 0 %. Skipping StillValid also takes MayFaultOnGpuRead from ~23 M to ~4.5 M calls per 10 s. So in MGS4
abis mostly a StillValid ceiling: worth about 0-1.5 % here. The per-thread address memo barely hits, so it says little about what an owner-record design could save on the other ~14 queries per draw.mprotect on kytyGpuExecute is not the cost in MGS4. 14 in-game
on=0periods, 2,450-2,980 draws per frame, 152-195 fps:About 4.7 µs per wunwatch call. At about 2.1 µs of wall time per draw, that's about 1 %.
The re-protection happens on the game's threads instead:
rearm144-157 k calls and 3.2-3.4 G cycles per 10 s (≈ 0.8 s of CPU), andwunwatch153-168 k calls (≈ 0.7 s), ≈ 5 µs each. That doesn't set the frame time here.What Execute does call is the address queries, about 15.5 per draw: mayfault 4.7, cpumod 2.8, backed 1.6, fullmap 1.6, clamp 1.6, findback 1.6, stillvalid 1.0, prefix 0.6. The counts lines carry no cycles for these in off periods, so their cost needs the
abperiods.One note on reading the period lines:
*_busyand*_us_per_drawcome from thread CPU time, and Resolve, Execute and Record spin while they wait on their queues, so all three read 94-99 % busy and their µs per draw are just busy × wall time per draw (Execute 2.073 = 0.979 × 2.117 at 472 k draws/s). They follow fps and can't show which stage limits. Our perf profiles are what put MGS4 on Execute. The same probably applies to the Stray figures (2.78 µs, 83 %).simnJS commentedon Nov 19, 2026
@Raghav314 thanks for the measurements. We tried the safe part of
ab: branchperf/addr-validity(f3f1146, on AnyKyty 17b0abc). Each thread keeps the answers ofMayFaultOnGpuReaduntil the set of GPU-written pages changes (one global generation), and nothing is skipped.KYTY_GPU_OWNER_MEMO=0turns it off.What we measured on our RT bench title (Fidelity 4K, RTX 4080 SUPER, Linux):
MayFaultOnGpuReadcalls per draw (83 %);So the +6 % of
abprobably doesn't come from these calls. It comes from whatabskips without checking: the byte comparison inStillValid, and the mapping queries (ClampRangeSize,IsBacked,FindBackingPointer,IsFullyMapped). Those mapping queries could use the same scheme, with a generation bumped on map, unmap and protect. Skipping theStillValidcomparison safely would need a write guard on the journal pages, which is a protection change.Since your Execute is saturated, an A/B of this branch on your side (
KYTY_GPU_OWNER_MEMO=0vs the default, same scene) would tell us whether it helps there. We won't merge it without a measured gain.simnJS commentedon Nov 19, 2026
Update, with a clearer picture of where the memory-tracking cost comes from and what the console does.
On our RT bench title (Fidelity 4K, busy city), write faults cost ~19 s of game-thread CPU per 10 s. 89 % of them land in one structure: the game's pool of command-buffer segments (PM4 packets plus dynamic constants copied in by
memcpy), which the game rewrites every few frames.What we established about the console driver's behaviour:
sceAgcDriverSubmitDcb/Acb/Multi*hand the GPU (address, size) pairs and do nothing else with the buffer memory: no copy, no cache flush, no barrier, no per-page tracking.REWIND), and nothing in the driver orders that.RELEASE_MEM, whose cache write-back is chosen by the game).So per-page write tracking of that pool is work the console never does. In progress: take that memory as-is when the GPU uses it, with the addresses a
WAIT_REG_MEMpolls still read live. Expected around −4 to −6 ms per frame on the critical path in that scene, to be A/B-measured before it lands. This should help MGS4's case too, if its tracked writes are the same kind; worth re-measuring once it's in.simnJS commentedon Nov 20, 2026
Status at
AnyKytyde0fa04, against the design above.What landed, on the write-fault side:
KYTY_WRITE_FAULT_BLOCKS(88eb2573eb, narrowed byda2947c57d, withb3f9a4a0d5keeping GPU-written pages out of an opened block): a guest write fault in command-buffer memory opens the whole 64 KiB block with one protection change, and a block opens only where the command processor read a command buffer or libSceAgc wrote packets. On our RT bench title: 724,000-840,000 guest write faults per 10 s down to 231,000-234,000, 53.5 to 56.0 fps, buffer uploads 11.8-12.1 down to 9.7-9.9 GiB per 10 s.[kyty-write-blocks]counts the faults by owner.d2b599b8b3), the shader resource table walk reads GPU-owned pages without one (31c6c4aedc), and faulted reads are replayed on the backing view (e36fbe6707,6cb0cb2a4a,0832a8bc2e). Hot-page write watching exists but stays off by default (f394e912fb).These act on the guest threads. Your MGS4 numbers put the re-protection there too and the fault handling at 0.9 % and 0.3 % of Execute, so we do not expect them to move the 19 %.
What did not change: the read path that is that 19 % (
MappedPrefix,Shim::IsBacked,GuestReadLog::StillValid). Yourabceiling on MGS4 was 0 to 1.5 %, the owner-record redesign is not built, andperf/addr-validity(a memo ofMayFaultOnGpuRead) is not merged because it showed no gain.Still open for MGS4: the slow path of
ClampRangeSizewe named above.MappedPrefixis walked twice, andFirstClamptakes a mutex and astd::seton every clamped call. #130 removes the second walk (draft, in-game trace pending);FirstClampis untouched. Reading command-buffer memory as-is when the GPU uses it, from the previous update, is not on the head yet.@Raghav314, a re-measurement would settle what is left: spot B, a 10 s
perf recordofkytyGpuExecute, on the current head, once as is and once with #130's branch. The "memory tracking, user code" and kernel shares of both, in the same format as your tables.[-]perf(kyty): memory tracking takes about 20 % of kytyGpuExecute in MGS4[/-][+]perf(kyty): memory-tracking reads cost about 19 % of Execute in METAL GEAR SOLID 4 (MappedPrefix, IsBacked, StillValid, FirstClamp)[/+]simnJS commentedon Nov 22, 2026
Status at
AnyKytya4b4360d66:5411bd8c03(a partially mapped buffer range is no longer scanned twice inClampRangeSize).FirstClamptakes a mutex and astd::setlookup on every clamped call, and the read path itself (MappedPrefix,Shim::IsBacked,GuestReadLog::StillValid) is unchanged.The open question is still the one above: how much of the 19 % is left on the current head. Spot B, a 10 s
perf recordofkytyGpuExecute, with the "memory tracking, user code" and kernel shares in the same format as the first tables, would settle it. A change toFirstClampis a goodmediumtask once those numbers are in; measure it with an in-runKYTY_ABA/B (how).mrfelek commentedon Nov 23, 2026
@simnJS a title where the
ClampRangeSizeslow path is most of the frame: Star Wars Galactic Racer (PPSA28416, Unreal Engine). I'd like to take the targeted fix you suggested above ("cache the clamp result per buffer range until an unmap"); here is the measurement and a prototype.Setup: Linux, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), AnyKyty
945dc287bc,KYTY_GPU_SPIN_US=0, warm caches. The game is driven byAPS5_PAD_INPUT_FILEinto an Arcade race on Jakku, and every number is from the race.Execute is the wall. A busy-wait added before every operation on the execute thread:
The frame grows by as much as Execute's busy time (slope about 1.0), at roughly 1,800–2,000 operations per frame, so about 80 µs per operation. The GPU is about 40 % busy.
Where it goes.
perf record -gofkytyGpuExecutefor 30 s: 74 % of its samples are inMappedPrefix, called fromClampRangeSizeinRenderExecutor::FindBuffers(DispatchIndirect40 %,PrepareGraphicsBindings23 %,DispatchDirect11 %).A temporary counter in
ClampRangeSizeandPageTable::Store, per 10 s:IsBacked.2^31bytes), every one only partly mapped, soMappedPrefixwalks the mapped part (~570 MB, ~35,000 pages of 16 KiB) each time: ~1.0 billion page-table loads per 10 s.Prototype. A per-thread 256-entry memo in
ClampRangeSize, keyed by (address, size) and valid whileg_probe_epochandg_backing_epochare unchanged.OnViewChangebumps the first before it stores the pages and the second after, andOnProtectionChangebumps the first, so a result is stored only when neither moved whileMappedPrefixran. A hit also skipsFirstClamp. It sits behind a temporary switch,KYTY_CLAMP_MEMO, measured withKYTY_AB=20:KYTY_CLAMP_MEMO KYTY_AB_SETTLE=5 KYTY_AB_START=250sin the race,tools/kyty_ab_report.py:So +89 % fps in that race with the memo, with the picture unchanged.
Plan for the PR, branched off the current
AnyKyty:ClampRangeSizeas above, and the same lookup inClampRangeSizeOrZeroandIsFullyMappedif you agree, since they callMappedPrefixon the same ranges;MappedPrefixafter each;Does that fit what you have in mind, or would you rather have the result kept per buffer in the buffer cache?
AI-assisted.
mrfelek commentedon Nov 23, 2026
@simnJS the fix from my comment above is ready, but I can't open a pull request for it:
simnJS/AnyPS5is no longer in the fork network ofboykopovar/AnyPS5, so GitHub refuses a pull request frommrfelek/AnyPS5("head invalid"). How would you like to receive it? Meanwhile, the branch is here:mrfelek/AnyPS5perf/kyty-clamp-memo, two commits onAnyKyty7de61e3451.c558edf4e6is the change behind the temporary switchKYTY_CLAMP_MEMO, and56a8b0fdabremoves the switch after the A/B.git fetch https://github.com/mrfelek/AnyPS5.git perf/kyty-clamp-memoClampRangeSizekeeps, per thread, a 256-entry table of (address, size) → mapped length, used only whileg_probe_epochandg_backing_epochare unchanged. It adds 20 lines inMemoryBacking.cppand a check inkyty_shim_memory(commit, reset and recommit inside a clamped range, on two threads).A/B on the branch (
KYTY_AB=20:KYTY_CLAMP_MEMO, warm caches,tools/kyty_ab_report.py, A = remembered, B = walked):7de61e34517de61e3451(non-regression)945dc287bc, 8 + 8 phasesOn
7de61e3451the walked arm of the race is slower than on945dc287bc(5.5 vs 6.9 img/s), so something else on the head costs this scene too, and the gain shows less there than the +89 % above.Shim suite with the validation layer, serially, on
7de61e3451and on the change: 109 of 110 on both, layer inserted 25 times and never missing, 0VUID-. The same two don't pass on both:kyty_shim_memory_sparse_reads_switchtimes out andkyty_shim_rt_corpusis skipped.check_conventions.pyandcheck_kyty_settings.pypass.PPSA21564, PPSA03912, PPSA02015, PPSA03671 and Ghost of Yōtei never log
clamped buffer rangehere, and neither did PPSA22408 in three minutes of menus, so they don't take this path.The full pull-request description, in the template's format, is ready to paste wherever you prefer.
AI-assisted.
simnJS commentedon Nov 26, 2026
@mrfelek sorry for the wait, and thank you: without the memo that race runs 27 % to 47 % slower, so 20 lines is a very good trade, and the non-regression run on the other title is clean. Yes, the memo in
ClampRangeSizeis what we had in mind. Keep it per thread as you did, not in the buffer cache, and with the switch removed as in56a8b0fdab.About the pull request: GitHub refuses it because your fork belongs to upstream AnyPS5's network, and this repository isn't in it any more. Fork
simnJS/AnyPS5itself (pick another name, for exampleAnyKyty, since you already havemrfelek/AnyPS5), pushperf/kyty-clamp-memothere and open the PR againstAnyKytywith the description you have ready. If that doesn't work for you, tell us and we'll carry the branch as a PR with your authorship, as was done for #292.The walked arm being slower on
7de61e3451than on945dc287bc(5.5 against 6.9 img/s on the same race) is worth its own issue, if you can profile both on the same scene.mrfelek commentedon Nov 26, 2026
@simnJS thanks. We'd rather not keep a second fork, so please carry it as a PR with my authorship, as you did for #292. The branch is
mrfelek/AnyPS5:perf/kyty-clamp-memo, head56a8b0fdab(switch removed), on7de61e3451. The description and numbers are in my comment above: race 7.23 against 5.46 img/s, ASTRO BOT 18.6 against 18.2 fps as the non-regression run. If it no longer applies cleanly on the currentAnyKytyhead, say so and I'll rebase the branch.I'll open a separate issue for the walked arm being slower on
7de61e3451than on945dc287bconce I have both profiled on the same scene.AI-assisted.
mrfelek commentedon Nov 26, 2026
@simnJS change of plan, so you don't have to carry it: I made the fork after all (
mrfelek/AnyKyty) and opened the PR there: #333. Same head56a8b0fdabas above; it merges cleanly on the currentAnyKytyhead90a48455d2.AI-assisted.