mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:50:51 +01:00
[PR #2220] runtime: record the order of first pipeline requests (LEONIDA_PIPELINE_ORDER_LOG=1, RT-PIPELINE-PREWARM-ORDER phase 1) #2224
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2224
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2220
Author: @MoonEyes
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:feat/pipeline-order-recorder📝 Commits (7)
40e94ebruntime: pipeline order recorder and replay request hook (RT-PIPELINE-PREWARM-ORDER, phase 1)7a4d1f7runtime: record the order of first pipeline requests behind LEONIDA_PIPELINE_ORDER_LOG=1cdbbb39Merge remote-tracking branch 'origin/main' into feat/pipeline-order-recorderdcdcaderuntime: address review of the pipeline order recorder0babd17Merge remote-tracking branch 'origin/main' into feat/pipeline-order-recorder4263427Record the library entry of each compute pipeline in the order log6b281fcMerge remote-tracking branch 'origin/main' into feat/pipeline-order-recorder📊 Changes
9 files changed (+1759 additions, -0 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+24 -0)📝
runtime/CMakeLists.txt(+13 -0)📝
runtime/README.md(+1 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+123 -0)➕
runtime/src/pipeline_order.h(+653 -0)📝
runtime/src/vulkan_replay.h(+9 -0)➕
runtime/test/pipeline_order_test.cpp(+714 -0)➕
runtime/test/replay_pipeline_order_hook_test.cpp(+213 -0)📝
tests/test_docs_env_vars.py(+9 -0)📄 Description
Claimed in the coordination issue as: RT-PIPELINE-PREWARM-ORDER, phase 1 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7176167646)
What and why
Nothing builds graphics or mesh pipelines ahead of their first draw today, and the compute warm-up orders by module size, not by what the title asks for first. Before proposing any reordering, this measures how much lead time the title gives: a passive recorder, off unless
LEONIDA_PIPELINE_ORDER_LOG=1.runtime/src/pipeline_order.h: for each pipeline and variant (the unbound-slot mask of a graphics pipeline, 0 for compute) that a dispatch or draw names for the first time in a run, one line is appended topipeline_order.logbesidepipeline_cache.session.bin: the PSO's description key (a SHA-256, with a mesh pipeline's MS folded in), the variant, creation and first-use times in milliseconds since the process started, the build time, and whether the handle was ready already. Each line ends with an FNV-1a checksum; a cut or damaged line is skipped on read. At most 8192 lines per run; a file past 8 MiB is set aside aspipeline_order.log.prev.runtime/src/vulkan_replay.h:ComputePipelineandGraphicsPipelineget arequestedcallback, called where a submission is prepared, also for a handle that exists already. Null when the variable is unset, so a run without it carries no hook.try_lockin the readiness callbacks, on the first request of a pipeline and of a variant. A thread of its own appends every 250 ms.[rt] pipeline-order: requested N, already ready M, median lead X ms -> <path of the file>.runtime/README.mdanddocs/d3d12_vulkan.md;tests/test_docs_env_vars.pychecks that the variable is read and named in both.Queuing builds in the recorded order is a follow-up that I will only propose if the recorded numbers show a gain.
Tested
Windows 11, MSVC (Visual Studio 2022), RelWithDebInfo, at
0babd17b8:mainmerged in ata73a57e13(which has #2098), full clean rebuild. No game files needed.pipeline_order_test(new, CPU only, 21 test functions): passes.replay_pipeline_order_hook_test(new, no GPU): passes.ctest -R "compile|pipeline" -j 4: 22 tests selected, 22 passed, 0 failed.d3d12_compile_teardown_testpasses with the variable unset (nopipeline-orderline printed) and withLEONIDA_PIPELINE_ORDER_LOG=1(the counts line is printed after the exit cache write).python -I tests/test_docs_env_vars.py: 5 tests, OK.python -I scripts/check_no_game_data.pyon the 9 changed files: clean.git diff --check: clean.main(atdcdcade32), three mutants ofpipeline_order.hwere replayed on a throwaway copy, and each is caught: no newline written after a cut file (test_cut_file_then_new_session), the writer skipping an unpublished slot (test_flush_stops_at_unpublished), the session version not checked (test_unknown_session_version).pipeline_order.hand its test did not change in that merge.The merge of
mainhad three conflicts: theLEONIDA_ASYNC_PIPELINESparagraph ofdocs/d3d12_vulkan.md(main's text kept, this paragraph after it), the test list inruntime/CMakeLists.txt(both kept) andbuild_computeinruntime/shims/d3d12_vulkan_device.cpp, where the recorder now gets its build time from #2098'sComputeBuild::ms.Not tested: the full ctest suite; a GCC or Clang build (CI will tell); the order of the log close relative to the exit cache write has no automated test (seen in the test's output only); a compute build with #2098's compile helper (
LEONIDA_COMPILE_HELPER=1, off by default): the build time recorded is that of the call that returned the pipeline, so it leaves out the helper's own compile, whether the build was answered as deferred and finished later or waited for. For every compute build the time is nowComputeBuild::ms, which also counts the wait for the compile gate and the journal write, not only the driver's create. No recorded numbers from the title are quoted here.GPUs tested: NVIDIA GeForce RTX 4060, driver 610.88, Windows 11
AI-assisted: yes (Claude Code, Claude Fable 5.2, wrote the code and tests; a second agent replayed mutants and reviewed it)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.