upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/measuring_fps.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/measuring_fps.md')
-rw-r--r--docs/measuring_fps.md82
1 files changed, 82 insertions, 0 deletions
diff --git a/docs/measuring_fps.md b/docs/measuring_fps.md
new file mode 100644
index 000000000..e97fe2a9e
--- /dev/null
+++ b/docs/measuring_fps.md
@@ -0,0 +1,82 @@
1# Measuring frame rates of the D3D12 runtime
2
3How to find out whether a change or a switch moves the frame of the Rust D3D12 runtime (`d3d12/`), and how not to fool
4yourself. It is about method; the measurements are in [d3d12/docs/findings.md](../d3d12/docs/findings.md) and the list
5of switches in [d3d12/docs/switches.md](../d3d12/docs/switches.md).
6
7## 1. Look first
8
9Search [findings.md](../d3d12/docs/findings.md) for the switch or the function you have in mind, on a fresh `main`.
10Many switches have been measured there, with the card, the scene, the method and the spread. On the night of
112026-11-29 several runs on two PCs went into `LEONIDA_COPYBACK_ELIDE`, whose entry already said "not usable here".
12
13## 2. Turn the switch inside one run
14
15`LEONIDA_AB=<seconds>,<switch>[,<switch>..]` turns switches on and off every so many seconds while the title runs, so
16both sides are measured in one scene, at one cache temperature, beside the same programs
17([`ab.rs`](../d3d12/crates/leonida-gpu/src/ab.rs)):
18
19- It needs a build with `diagnostics` (the one `d3d12/scripts/build-nvidia.ps1` makes) and more than one second a phase.
20- Up to eight switches; switch number *n* is on in the phases whose number has bit *n*, so every combination comes round.
21- A switch named there no longer goes by its own variable. Only switches the code reads that way follow it; for any
22 other name the phases are logged and nothing changes, so check the name in [switches.md](../d3d12/docs/switches.md)
23 or the code before you believe a "no difference".
24- Not every switch may be turned in play: `findings.md` has one that ends the title (`LEONIDA_ASYNC_SUBMIT`).
25- Each phase ends with a line `A/B phase <n> bits <b> on [...]`: frames, mean, median, p90, draws a frame, the card's
26 idle and busy time a frame and the submitting thread's work a frame. The first second of a phase is left out.
27
28Phases of 3.5 to 4 s worked there. The idle camera goes round views of about 24 s with different draw counts, so phases
29of 15 s measured the views rather than the switch. Standing, `findings.md` cuts the phases into stretches where the draw count
30jumps, leaves out the first phase of a stretch and fits a level for each stretch; walking, it takes the mean of the differences of
31neighbouring phases. Give the effect **with its standard error**. The scripts it names for this (`ab_pair.py`, `ab_eff.py`) are not in
32the repository.
33
34That gave about 0.2 to 0.8 ms of spread for a standing run of some minutes and 1 to 2 ms for a walking one. Two separate
35runs of one setting differed by 7 ms in one of its tables (75.0 and 82.1 ms).
36
37## 3. When only separate runs will do
38
39A change of code, or a switch that cannot be turned in play, needs separate runs:
40
41- The same save for every start. The title rewrites its autosave, so keep a copy and put it back before each start
42 (and the player's own back afterwards).
43- Alternate (A B B A), in one sitting, with a throwaway run first: one PC's first measured run after a warm-up came out slowest
44 in both series it was looked for in (2026-11-30; not explained).
45- After a translator change, or on a new build, play a while first. Until its pipelines are made, a run measures that.
46- The same programs in the background, and nothing heavy beside it: no compiler, no test suite. `findings.md` has one build at 16.2 to 17.3
47 and then 12.8 frames a second; what had changed was the programs that start with Windows.
48- Check every run for the state you think it was in: it reached the world, it did not stay in the menu, it did not end early. A run
49 that stayed in the menu shows 60.
50- With two runs a side, do not claim a difference smaller than the spread between runs of the same side.
51
52## 4. Which number means what
53
54- **Frame time, not only frames a second.** The line `leonida_gpu::host: <n> fps, <ms> ms/frame (...)` counts rendered
55 frames. With frame generation the screen shows more; say which you mean, or measure with `-NoFrameGen`.
56- Report the median and a low percentile, and leave the menu and the loading out.
57- **A sum over all threads is not a part of the frame.** "All threads", "list calls ... ms", the process's CPU time and
58 a whole-process profile add up work that runs side by side. They can exceed the frame many times over.
59- **A thread that waits because it has nothing to do costs nothing.** The relay line says its thread waits "beside the
60 submitting thread"; what other threads lost to it is in the line about *settles*.
61- Draws "left out on purpose" are not missing pipelines; the line gives both counts.
62- The frame stands at the longest of its walls (the card, the submitting thread, the title). Work taken off another one
63 does not show. Cards and CPUs differ: say the card, driver, CPU, memory, profile, resolution, scene and commit.
64
65## 5. Where a frame goes
66
67All in builds with `diagnostics`; each costs something, so do not read frame rates from the same run.
68
69| Tool | What it answers |
70|---|---|
71| `LEONIDA_TIMELINE=<file>` (with `LEONIDA_TIMELINE_AT`, `LEONIDA_TIMELINE_FRAMES`) | A trace of a few frames for `chrome://tracing` or Perfetto, and a text summary with **the chain of work and waits each present came out of**: the tool for "what does the frame wait for". |
72| `LEONIDA_PROFILE=<from>,<to>,<ms>,<file>` (with `LEONIDA_PROFILE_ONLY=<thread name>`) | Stack samples by thread, waits included, from inside the process. Do not name the title's own threads: `findings.md` has a run that ended that way. |
73| `LEONIDA_GPU_TIMING=1` | The commands' time on the card. |
74
75Windows Performance Recorder works too (it needs an administrator). Wait until it says that the trace was saved before you open the file.
76
77## 6. Before you report a cause
78
791. Write the prediction and what would refute it before the run.
802. Say **MEASURED** (with *n*), **READ IN CODE** or **ASSUMED**.
813. Try to refute it: if this were the cause, what else would have to be true? Is it on the submitting thread's chain?
824. Post numbers only: no logs, captures, shader or pipeline names that are not already in the repository, addresses of the title, or other game data.