ScarletNX / ScarletNX documentation / Graphics pipeline libraries · ← previous · next →
Measurement
The goal is the stall of a new shader in a frame, and how often it occurs. Measure the same scene and script on the
build before the change and after it, three times each, with empty caches and with warm caches. Run without the
validation layer for times.
- The slow pipeline log:
pipe_slow_say (one second or more) gets a line for each kind of make:
a pipeline library took N ms (pre-rasterization, vs ...), a pipeline link took N ms, and
an optimized pipeline took N ms. The last kind is not a stall, so the line says that it was in the background.
Count the lines that name a stall: grep -c 'took .* ms to make' games/<id>/<id>.log for the build before, and the
library and link lines for the build after.
- Tracy zones: "pipeline make" stays for the whole pipeline. The new zones are "pipeline library make" (with the
part and the stage hashes), "pipeline link" and "pipeline optimize". "pipeline wait" stays on the recording thread.
In a capture, the sum and the largest "pipeline wait" are the stall. The
mcp__tracy__compare_captures tool
compares two captures.
- The stats line:
vk_pipeline_stats gets the parts made, their cache hits, the links, the link ms, and the
optimized pipelines made. The wait ms (g_pipeline.pipe_wait_ns) is the number to compare.
- The stalls in each run: the count of "pipeline wait" zones over 50 ms, and the largest. On the Ounce game with
empty caches, the build before waits 6 to 10 s for each new pipeline of a large vertex program. The build after
must wait that long only one time for each vertex program (its PR part), and only a link for each new state of it.
With the shipped programs warmed, it must wait for no compile of a shipped program.
- The GPU time: a draw on the fast link can be slower on the GPU than on the optimized pipeline. Compare the GPU
frame time (
gpuprof.c) over a scene after the optimized pipelines are ready. It must be the same as the build
before.
Results
The menus of an Ounce game, 760 frames with one press each 20 frames, on the RTX 2080 (NVIDIA 615.78.08). Each
build had a warm-up run first. The runs are few and the game's path through the menus changes from run to run, so
the numbers show the mechanism, not a mean.
- Parts with cold caches (the first run of the library build, under the validation layer): 245
pre-rasterization parts (40.8 s in all) and 339 fragment shader parts (47.9 s) for 469 pipelines. The 469 links
took 122 ms in all. The 469 optimized pipelines took 85.8 s, on the workers, which no draw waited for.
- The large vertex programs (1,716 to 1,736 KB of SPIR-V) took 4.2 to 6.8 s each as a part, one time each. Two
pipelines of one of them waited for its one part (4.2 and 4.3 s) and then linked. On feat/ounce each such
pipeline compiled the program again (3.9 s for one with a warm cache of everything else). The optimized pipeline
of each compiles it again in the background (4.0 to 5.0 s each).
- Warm caches (the measured run after the warm-up): 237 of 240 and 339 of 346 parts from the pipeline cache;
478 links in 20 ms (Tracy "pipeline link": mean 39 us, max 3.9 ms); 552 optimized pipelines (Tracy "pipeline
optimize": mean 17 ms, max 238 ms). "pipeline wait" was 70 waits, 5.8 s in all, of which 3.5 s were one new
pre-rasterization part (608 KB) that the warm-up run had not met.
- feat/ounce with warm caches: one whole pipeline of a 1,721 KB vertex program took 3,909 ms in one measured
run, and none in another. Its traced run had 2 "pipeline wait" zones (19 ms), on a shorter path through the menus.
- Frames over 1 s: 10 to 12 in a measured run on both builds (the longest 6.4 s with the libraries, 11.7 s
without). They come mostly from texture uploads and loads, not from pipelines.
- Validation: no new kind of message from the dynamic state. The library path adds two messages of
VUID-RuntimeSpirv-OpEntryPoint-08743 at a link (see the open questions).
- GPU frame time: not measured. The Tracy tools here do not read the GPU zones.
The bound of optimizing workers, measured
The menus with cold pipeline caches (vk_pipeline_cache=0, NVIDIA's disk cache off), one run each of 200 s:
| Optimized pipelines | Frames | Frames over 1 s | The draws' new pipelines' waits for a worker |
| none | 760 | 12 | 385 pipelines, 32.6 s in all, the longest 933 ms |
| one worker at most | 755 | 12 | 356 pipelines, 40.4 s in all, the longest 911 ms |
| no bound (six workers) | 529 | 27 | the run ended before its stats line |
With one optimizing worker the cold run behaves like a run with no optimized pipelines. With no bound the game made
fewer frames and more than twice as many frames over 1 s. The runs take different paths through the menus, so
these are single runs, not means. The renderer now uses one worker at most (PIPE_OPT_WORKERS).
The warm-up of the shipped programs, measured
- A cache hit of a pre-rasterization part of a 1.7 MB vertex program took 54 to 136 ms (6 hits).
- A part with no cache entry took 164 ms on average before rasterization (313 parts, 51.5 s) and 128 ms for the
fragment stage (379 parts, 48.4 s). The large vertex programs took 3.4 to 4.2 s each.
- The pipeline cache of a cold run with only parts (no optimized pipelines) held 38.1 MB for 746 parts: about 51 KB
for each part.
- The shared
vk_pipelines.bin of this game is already 716 MB, and every start reads all of it.
So the warm-up of all 7,403 shipped programs would cost about 18 minutes of worker time in a first run and add about
380 MB to vk_pipelines.bin, for programs that a session mostly does not use (540 of 7,403 in these menus). The
numbers do not allow it. A warm-up of the large programs only (the few of hundreds of KB of SPIR-V, whose parts take
seconds) would cost little, and it is the next step: make their pre-rasterization parts from the shipped modules on
the lowest queue, and keep them in the table of parts, so that a draw links them at once.
← previous · next →