Repository navigation
Conversation
warm_worker compiles one MSL library at a time; with a cold system Metal cache only one MTLCompilerService is busy and the other cores sit idle (first launch: 9360 libraries, ~35 min on an M4 Pro). warm_precompile now compiles the same sources with the same options on every core, in the order warm_worker visits them, and drops the results, so warm_worker's own compiles become system-cache hits. warm_worker, its order, progress and counts are unchanged. TOTK_WARM_PARALLEL=0 turns it off. Measured on 400 real seed shaders (M4 Pro, macOS 27): 232 ms each cold and serial, 27.8 ms each in parallel, ~0 ms each once cached. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Merged
Contributor
|
Tested on an M4 Pro Mac (12 cores, macOS 27.0.1, TOTK 1.4.3), with #3 and #12. 👍 I compiled the same 96 real seed shaders, renaming the entry points each pass so nothing came from the cache, two runs per setting:
That's about 6.7× faster than one worker and 2× faster than four, with no failures. With a full cache, in-game warm-up is unchanged: 5.69 s, against 5.75 s with four workers. This measures library compilation only, not a full cold startup. |
This was referenced Oct 18, 2026
This was referenced Oct 18, 2026
tvc97
added a commit
to tvc97/MacNativeGames
that referenced
this pull request
Oct 19, 2026
…05010419#30) Brings in upstream ly05010419#29 (bounded pipeline prediction without translation, stale guesses reclaimed) and ly05010419#30 (in-game libraries and pipelines in the background, plus the present residency and compile-options fixes). Conflict resolution in nvn_mtl.m / hle_nvn.c: took the branch side, re-applied what main has since ly05010419#29's base (ly05010419#13 warm_precompile, ly05010419#17 compact HUD), and kept main's prebuilt-library hit/miss diagnostic. Our earlier prediction-table drain (pso_pend_drain into g_pso, prog_get_cached, mtl_pp_stats and its log line) is replaced by ly05010419#29's version. It no longer skips pso_user.tsv for drained pipelines. Checked: make runtime-v143 (58 warnings, none new), 38 source tests, probe-gfx pass, 3 empty-cache async boots without a GPU fault. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tvc97
added a commit
to tvc97/MacNativeGames
that referenced
this pull request
Oct 19, 2026
…y05010419#38) Conflicts resolved toward the refreshed PR branches: nvn_mtl.m from perf/async-shader-loading (ly05010419#30 on current upstream) plus ly05010419#13's parallel warm-up and the precompiled-library hit/miss log; prepare_shader_seed.py from perf/parallel-shader-seed (ly05010419#27); runtime/cheats.c kept in every runtime target and in loader.c. AGENTS.md stays tracked here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Closing: this is covered by 35606fe ("compile the background warm-up's shader libraries on several threads"), which parallelizes the same warm-up compiles directly in warm_worker. Thanks for picking it up. |
nik-2002
added a commit
to nik-2002/MacNativeGames
that referenced
this pull request
Nov 2, 2026
…r picture mode The renderer's per-frame update (main+0x581f58) compares the display mode it wants with renderer+0xcd0 only when bit 13 of renderer+0xca4 is set (main+0x581434 tbnz w9, ly05010419#13). render_reread wrote -1 to the mode byte but left that bit to the game, so the size was read again only when the game happened to set it: started in 720p, gone to 1080p, then 720p render and 720p + MetalFX kept the 1920x1080 scene (the overlay and the upscale's source said 1920x1080). render_reread now sets the bit too, and a short-lived thread sets it again (the game writes that word with plain loads and stores) until the mode byte is no longer -1, for up to 10 s, logging the outcome. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014gG6xb2wdBKczP1NgMQwBU
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.
Summary
warm_workercompiles the warm-up shader libraries one at a time on its own thread. With a cold system Metal cache, only oneMTLCompilerServiceis busy (about 100% of one core) and the rest of the machine sits idle. On a first launch with 9,360 seed shaders, that's roughly 35 minutes before the first frame on an M4 Pro.This PR adds
warm_precompile, called at the start ofwarm_worker. On a background queue it compiles the same MSL sources with the same options (totk_precise_opts()) on every core, usingdispatch_applywithshouldMaximizeConcurrentCompilation = YES, in the orderwarm_workerwill visit them. The results are dropped, as inwarm_light. Only the system Metal shader cache gets filled, sowarm_worker's ownnewLibraryWithSourcefor each shader becomes a cache hit.warm_workeris otherwise untouched: same order, progress, counts, priority gate andNvShaderloading.warm_shaderwould skip (double,unsupported_GLSLstd450) are skipped here too.totk_precise_opts()is created on the calling thread first, because its lazy initialisation isn't thread-safe.TOTK_WARM_PARALLEL=0turns it off. iOS is unaffected (#if !TARGET_OS_IPHONE).docs/first-launch-shaders.md.Measurements (Mac mini M4 Pro, 14 cores, macOS 27.0.1)
Compiling 400 real seed shaders from the user cache in a standalone process:
dispatch_apply, 14 compile tasks)In the game (on top of #11, which macOS 27 needs to start at all):
并行预编译完成:9360 个着色器库,0 个失败,用时 148.3 s管线预热完成:着色器 9362 个 … 后台用时 148844.8 ms, thenfirst presented frameat 158 s.Caveat: the system Metal cache wasn't cleared before the in-game run, so about 4,200 of the 9,360 shaders were already cached from that earlier launch. The remaining ~5,100 cold compiles in 148 s (~29 ms each) match the standalone parallel figure. A fully cold run should take about 4–5 minutes on this machine instead of ~35.
中文摘要:预热线程逐个编译着色器库,系统 Metal 缓存全冷时只有一个编译进程在忙。本 PR 在后台按预热顺序用全部核心预编译同一批 MSL(同选项,结果丢弃,只填系统缓存),预热线程随后即为缓存命中;顺序、进度、计数不变,
TOTK_WARM_PARALLEL=0关闭。M4 Pro 实测冷编译 232 ms/个 → 并行 27.8 ms/个。🤖 Generated with Claude Code