Stats panel: one GDI font per face per thread instead of one per text call #606

Open
HQasper wants to merge 1 commit from HQasper/Darner:pr/panel-fonts into Main
First-time contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: read from the code, then measured in game. Picture::with_face (crates/darner-gpu/src/host/font.rs) makes, picks and deletes a GDI font for every text it measures or draws. Each call pays a new font realization: about 80 us for a measured text, against about 4 us with a font that is kept. The panel's picture is made twice a second on the submitting thread, and with DARNER_PANEL=1 it took 8-9 ms at once: a frame-time spike every 500 ms.

A thread now keeps the fonts it made, by face (name, height, bold), at most 32 of them; past that a call makes its own font and deletes it after, as before. The fonts are made the way main makes them now: the face the host has (host_face), and a stand-in for Consolas drawn as wide as Consolas (stand_in_width). A kept font is deleted when its thread ends.

How it was tested

  • Tested revision: 7fd3479 (the same tree as 21c6849; only the commit message changed after the runs).

  • Commands and results:

    • cargo test -p darner-gpu --lib includes the new test a_face_s_font_is_made_once_a_thread, which passes.
    • The game A/B below.
  • Changes a default: no. The panel's fonts are made as on main; they are only kept instead of made again.

  • A/B result: the prison cell bench, 60-210 s after the world's first frame, the panel on (DARNER_PANEL=1), with DARNER_RANGE_LOCK=1, DARNER_ALIAS_SHARE=1, DARNER_VIEW_THREADS=8 and DARNER_SUBMIT_CORE_ALONE=1 in both. A is main at c8258f9, B is this branch. Two runs each, interleaved with a third build in one series (A, B, other, A, B, other). The first run of each build came right after its shader preload.

    A (main) B (this branch)
    median fps 46.6, 49.4 48.9, 49.8
    p99 frame time 31.6, 30.8 ms 28.7, 29.3 ms
    frame-to-frame variability 1.26, 1.47 ms 1.16, 1.21 ms
    longest gap 54.7, 63.5 ms 43.6, 82.0 ms

    The longest gaps of all runs fall where the world streams in, about 60-70 s after its first frame, with and without the change.

  • Gates run on 7fd3479:

    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed.
    • cargo test --workspace --locked: the first run failed 4 darner-gpu library tests. They were host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due and three host::watch_pipe::tests, while other builds loaded the PC. All four pass alone, and a second full run with --no-fail-fast passed: 3,521 passed, 0 failed. On main c8258f9 under the same load, cargo test -p darner-gpu --lib failed 1-2 tests in each of 3 runs (host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end, watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs). This change does not touch those tests' code.
  • Gameplay: RTX 5090, Series X profile, 1440p, DLSS Quality, frame generation off, hardware ray tracing.

  • Shader wave sizes tested: not relevant (no shader change).

  • Hardware dependence: likely general on Windows (GDI). Not tested under Wine/Proton; the fonts are made by main's own face lookup, which is what #353 added for Wine.

  • Coverage gaps: one PC; two runs per build; not tested under Wine/Proton.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #353 (merged; host fonts under Wine, the same file: this change keeps its face lookup). Open PRs that change font.rs too, for other reasons: #302 (launcher window), #154 (F1 menu new look).
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: read from the code, then measured in game. `Picture::with_face` (`crates/darner-gpu/src/host/font.rs`) makes, picks and deletes a GDI font for every text it measures or draws. Each call pays a new font realization: about 80 us for a measured text, against about 4 us with a font that is kept. The panel's picture is made twice a second on the submitting thread, and with `DARNER_PANEL=1` it took 8-9 ms at once: a frame-time spike every 500 ms. A thread now keeps the fonts it made, by face (name, height, bold), at most 32 of them; past that a call makes its own font and deletes it after, as before. The fonts are made the way main makes them now: the face the host has (`host_face`), and a stand-in for Consolas drawn as wide as Consolas (`stand_in_width`). A kept font is deleted when its thread ends. ## How it was tested - Tested revision: 7fd3479 (the same tree as 21c6849; only the commit message changed after the runs). - Commands and results: - `cargo test -p darner-gpu --lib` includes the new test `a_face_s_font_is_made_once_a_thread`, which passes. - The game A/B below. - Changes a default: no. The panel's fonts are made as on main; they are only kept instead of made again. - A/B result: the prison cell bench, 60-210 s after the world's first frame, the panel on (`DARNER_PANEL=1`), with `DARNER_RANGE_LOCK=1`, `DARNER_ALIAS_SHARE=1`, `DARNER_VIEW_THREADS=8` and `DARNER_SUBMIT_CORE_ALONE=1` in both. A is main at c8258f9, B is this branch. Two runs each, interleaved with a third build in one series (A, B, other, A, B, other). The first run of each build came right after its shader preload. | | A (main) | B (this branch) | |---|---|---| | median fps | 46.6, 49.4 | 48.9, 49.8 | | p99 frame time | 31.6, 30.8 ms | 28.7, 29.3 ms | | frame-to-frame variability | 1.26, 1.47 ms | 1.16, 1.21 ms | | longest gap | 54.7, 63.5 ms | 43.6, 82.0 ms | The longest gaps of all runs fall where the world streams in, about 60-70 s after its first frame, with and without the change. - Gates run on 7fd3479: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed. - `cargo test --workspace --locked`: the first run failed 4 darner-gpu library tests. They were `host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due` and three `host::watch_pipe::tests`, while other builds loaded the PC. All four pass alone, and a second full run with `--no-fail-fast` passed: 3,521 passed, 0 failed. On main c8258f9 under the same load, `cargo test -p darner-gpu --lib` failed 1-2 tests in each of 3 runs (`host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end`, `watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs`). This change does not touch those tests' code. - Gameplay: RTX 5090, Series X profile, 1440p, DLSS Quality, frame generation off, hardware ray tracing. - Shader wave sizes tested: not relevant (no shader change). - Hardware dependence: likely general on Windows (GDI). Not tested under Wine/Proton; the fonts are made by main's own face lookup, which is what #353 added for Wine. - Coverage gaps: one PC; two runs per build; not tested under Wine/Proton. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #353 (merged; host fonts under Wine, the same file: this change keeps its face lookup). Open PRs that change `font.rs` too, for other reasons: #302 (launcher window), #154 (F1 menu new look). - Replaces or overlaps: none found
Every text the panel measured or drew made, picked and deleted its own GDI
font, so each call paid a new realization: about 80 us a measured text
against 4 with a kept font. The panel's picture, made twice a second on the
submitting thread, took 8-9 ms at once, a frame-time spike every 500 ms with
DARNER_PANEL=1.

A thread now keeps the fonts it made, at most 32 faces; past them a call
makes its own as before. The fonts are made as main makes them (the face the
host has, a stand-in for Consolas as wide as Consolas). Measured against main
c8258f9 with the panel on (9950X3D, RTX 5090, hardware RT, DLSS Quality,
1440p, two runs each): p99 31.6 and 30.8 -> 28.7 and 29.3 ms, frame-to-frame
variability 1.26 and 1.47 -> 1.16 and 1.21 ms, median 46.6 and 49.4 -> 48.9
and 49.8 fps. Test: a_face_s_font_is_made_once_a_thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from [pr-performance] Stats panel: one GDI font per face per thread instead of one per text call to Stats panel: one GDI font per face per thread instead of one per text call 2026-12-06 03:26:23 +00:00
Owner

Test needed — commit 21c6849e; what to check:

  • The problem on main: read from the code, then measured in game. Picture::with_face (crates/darner-gpu/src/host/font.rs) makes, picks and deletes a GDI font for every text it measures or draws. Each call pays a new font realization: about 80 us for a measured text, against about 4 us with a font that is kept. The panel's picture is made twice a second on the submitting thread, and with DARNER_PANEL=1 it took 8-9 ms at once: a frame-time spike every 500 ms.

A thread now keeps the fonts it made, by face (name, height, bold), at most 32 of them; past that a call makes its own font and deletes it after, as before. The fonts are made the way main makes them now: the face the host has (host_face), and a stand-in for Consolas drawn as wide as Consolas (stand_in_width). A kept font is deleted when its thread ends.

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `21c6849e`; what to check: - The problem on main: read from the code, then measured in game. `Picture::with_face` (`crates/darner-gpu/src/host/font.rs`) makes, picks and deletes a GDI font for every text it measures or draws. Each call pays a new font realization: about 80 us for a measured text, against about 4 us with a font that is kept. The panel's picture is made twice a second on the submitting thread, and with `DARNER_PANEL=1` it took 8-9 ms at once: a frame-time spike every 500 ms. A thread now keeps the fonts it made, by face (name, height, bold), at most 32 of them; past that a call makes its own font and deletes it after, as before. The fonts are made the way main makes them now: the face the host has (`host_face`), and a stand-in for Consolas drawn as wide as Consolas (`stand_in_width`). A kept font is deleted when its thread ends. Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/panel-fonts:HQasper-pr/panel-fonts'
git switch 'HQasper-pr/panel-fonts'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'HQasper-pr/panel-fonts'
git switch 'HQasper-pr/panel-fonts'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'HQasper-pr/panel-fonts'
git switch 'HQasper-pr/panel-fonts'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'HQasper-pr/panel-fonts'
git switch 'Main'
git merge --squash 'HQasper-pr/panel-fonts'
git switch 'Main'
git merge --ff-only 'HQasper-pr/panel-fonts'
git switch 'Main'
git merge 'HQasper-pr/panel-fonts'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!606
No description provided.