Repository navigation
alias_take_over finds its candidates by pool cell instead of walking the sharing table: Mario Golf: Super Rush's All-Star Summit loads - #2229
Conversation
…r storage lies in instead of walking the whole sharing table: Mario Golf: Super Rush's All-Star Summit registers 134,400 textures and had not finished loading after 12 minutes Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ng the sharing table, so a scene that shares tens of thousands of textures loads: alias_take_over walked g_alias's whole capacity for every shared texture made, with a layout and a g_alias_seen lookup for each entry of the same pool, so the cost of each texture grew with the textures already shared. Mario Golf: Super Rush (0100C9C00E25C000, 4.0.0, issue #814) registers 134,400 textures for All-Star Summit and shares about 90,000 as the course loads: on main no frame in 5 minutes with the submit thread at 100 % in alias_take_over, with the index the first frame about 3 s after the start (the PR author's runs, MacBook Pro M1 Pro). The shared textures are now indexed by where their storage lies (alias_index, g_alias_cells: {pool, 64 KB cell} → the entries whose bytes reach into the cell, each with its end), and the takeover reads the new texture's cells only. It chooses from the same entries (same pool, another description, overlapping bytes, not looked up lately, held by no serial); when more than 16 qualify, which 16 go first follows the cells instead of the table's order. The index, the diagnosis and the measurements are PR #2229's. Added here: the table's keys have two writers, alias_put and alias_del, which keep the index, g_alias_set and g_alias_seen together (the PR called alias_index beside three writers, and t_alias_takeover's cost case, which inserted directly, passed with its entries hidden from the takeover); the image families' owner lookup (image_texture), which walked the table for each image made in a GPU-only pool, reads the one cell of its offset; tests and the reference entry (A storage takeover walked the sharing table for each texture made). Walks of the whole table remain where they run once per event: a pool's release, a texture's upgrade, the memory report and the census. Checked: t_alias_takeover (45 checks: an entry reaching in from an earlier cell, one in the same cell that ends before the new texture, a spanning entry taken once, another pool's entries, no cell left after a removal or a pool drop, and a takeover with 100,000 entries in the table in 0.0003 ms against 0.65 ms for main's walk, M6), t_image_alias (two families in one cell keep a heap each), make run in dm/gfx/tests, test_docs. regress.py check on Return of the Obra Dinn (M6, headless): the takeover alone PASS with 73 shared textures and 18 takeovers on both sides; the final code PASS in two of three runs (58.9 and 59.8 fps, no new red line), the third with two command buffers of about 8,500 failed by a GPU hang (kIOGPUCommandBufferCallbackErrorHang) and a moved screenshot, which four stored runs of this game from 7 and 8 November show too, one of them a baseline; its cause is not found. Not run: Mario Golf: Super Rush here, a game known to make image families (Luigi's Mansion 3, ASTRAL CHAIN), iOS, lint_c.py. Open: whether 90,000 live Metal textures for one course is what the game needs, and its memory on an iPhone (PR #2229) Co-authored-by: secretlemur28 <354896836+secretlemur28@users.noreply.github.com>
|
Landed on main as 352e4a6, with you as co-author. Thank you: the diagnosis, the cell index and the measurements are yours and are kept as posted. What was added on top:
Checked here: the graphics test suite, and |
…keover evicts the texture its view was made of: since PR seedds#1489 (0c7e88b) alias_take_over records the eviction as ser_note(0), which names none of the twin's IDs, so they kept the cached view on the fast path (tex_fast_rid) and the pool tables, patched or built whole, kept its resource ID, while the parent left the sharing table and, once the takeover's submission completed, the residency set (issue seedds#2125). The stale-view check in tex_mtl_ that the takeover's comment relied on ran only when something named the twin's texture object (a render target, a copy, a clear); before seedds#1489 the takeover's bare g_ser_gen++ sent every ID there. tex_mtl_'s twin path now lists the serial that took the view against its parent (g_twin_par, up to 8, under g_smu), only after checking under the same lock that the parent is still the sharing table's entry for its key; otherwise a takeover on another thread (tex_mtl_ also runs on the present thread and in mtl_read_texels) evicted it in between and found no list, so the view is dropped and the key looked up again. alias_take_over notes each listed serial of a texture it evicts, before alias_del removes its entry, so only those IDs take the slow path, where tex_mtl_ finds the view stale, and the tables are patched for them alone. A list that fills drops its finalized serials (a retired ID's view goes at the submission's end anyway), and one still full of live serials makes the takeover's bump a bare g_ser_gen++. alias_del, which 352e4a6 (PR seedds#2229) made the sharing table's one remover, drops the list of what it removes, so a pool's release (mtl_alias_drop_pool, whose bump already has no note) drops it too; the format-view upgrade, which replaces the texture in place and bumps with no note, drops it and lists the asking serial again for the view it makes on the upgraded texture. The reference entry (A storage takeover notes the serials of an sRGB / linear twin of what it evicts) says so. t_pool_notes's twin case (IDs 7 / 8 / 9) passed only because the note of ID 8's first resolution took ID 8 again in the takeover's walk: it now takes one walk between the two, as the issue proposes, which fails 2 of 83 checks on the old code, and its checks move one walk later, since the takeover's notes reach the walk after it; it keeps ID 8's first entry instead of reading that table's buffer again, which is used again once its submission completes. A new twin list case checks that a list that fills drops its finalized serials (only the live twin is noted) and that one full of live serials makes the bump bare. Checked on 352e4a6 and, after a rebase onto 8b55ebb (shader build tools and docs only), t_pool_notes, t_alias_takeover and t_feedback again there; M3 Max, macOS 26.7.2: t_pool_notes 119 checks, 0 failed, three runs (the twin case alone fails 2 of 83 on unmodified 352e4a6, three runs; taking the twins' notes out of alias_take_over fails 3, the bare-bump fallback 1); t_alias_takeover 45 checks and t_image_alias 337 with and without the encoder thread, 0 failed; make -k -C dm/gfx/tests GAME=0400486024DEC000 run: every test passes but, in some runs, t_feedback's check "with nothing running: a commit" (1 of 278), which fails as often on unmodified main and is unrelated (t_refl and t_rt_range_ro skip the reflection samples this Mac does not have); docs_symptoms.py --check; test_docs; the Mac host builds with main's 58 warnings. Not run: a game (no visible symptom is known, and Ocarina of Time, the only game on this Mac, was not built on main), regress.py (the reach is takeovers of a texture an sRGB / linear twin was made of), iOS
|
Thank you for taking it in, and for the tests and the Confirmed on One thing from the same build, not from this change: the script's pipeline prebuild step ended with |
What and why
Mario Golf: Super Rush (
0100C9C00E25C000, 4.0.0, #814) never finishes loading its All-Star Summit course: the submit thread stays at 100 % CPU inalias_take_over(tex_mtl_←tex_by_id←encode_args←draw) and no frame is presented.The course registers 134,400 textures and makes about 90,000 of them shared (
g_alias) as it loads.alias_take_overwalks the sharing table's whole capacity (131,072 slots) for every texture made, with a layout and ag_alias_seenlookup for each entry of the same pool. After 12 minutes the table held 88,513 entries and the load was still going.alias_take_overnow finds its candidates through an index of the shared textures by where their storage lies: {pool, 64 KB cell of the pool} → the entries whose bytes reach into that cell, each with its end (alias_index, kept by the three writers ofg_alias: the insert intex_mtl_, the take-over itself and the pool's release). The candidates are the same as before (same pool, another key, overlapping bytes, not looked up lately, held by no serial); only how they are found changes.Checked
mainat2f131edc(with A subsdk a provisional profile gains from the NRO collection also goes into its build rows #2215 and cra.py reads the 2021 layout of Camelot's archive (Mario Golf: Super Rush 4.0.0) #2216, which the game needs to build) the load stays at 100 % CPU inalias_take_overwith no frame presented (stopped after 5 minutes); with this change the first frame of the course comes about 3 s after the start, the flyover and the first tee draw, and frame time is p50 16.67 ms (GPU 9.8 ms). Bonny Greens, Blustery Basin and Spiky Palms also load and draw their first holes with it, on a branch that carries other changes too.regress.pyreport; iOS. The change is on a path every game with shared textures takes, so a run on Ocarina of Time or another game with many aliases would be worth having.Docs
docs/reference/if you want it with this.🤖 Generated with Claude Code