Skip to content

PGO release builds: the committed profiles no longer match the hottest functions (664 dropped on Windows and 1,231 on Linux at build 399) #2526

Backlog

Description

@danieljesus

The -pgo release builds apply profiles that are committed to the repository (lichii-windows.profdata, eglantine.profdata). As nx2 moves, LLVM drops the profile of every function whose control flow changed since the profile was trained, and those are mostly the functions being worked on, which are the hot ones.

Windows, from the public CI log. Run 45106098730 (build 393, nx2 136b9a6, 23 Nov), job "windows-x86_64-pgo binary", prints 655 function control flow change detected (hash mismatch) … count discarded [-Wbackend-plugin] warnings; 334 of them discard a non-zero count. Run 45319474804 (build 399, nx2 107ce81, 24 Nov) prints 664, 336 non-zero. lichii-windows.profdata was last committed on 17 Nov (fb5f22f). The largest discarded counts in build 393:

function discarded count
VideoCommon::GpuSplit::BackLoop 1,095,161,927
Common::HostMemory::TrimZeroPages 901,548,098
Tegra::Engines::Maxwell3D::FrontWrite 424,244,671
VideoCommon::GpuSplit::WaitFor 355,552,573
Tegra::DmaPusher::CallMethod 226,627,270
Maxwell3D::WriteBoundConstantBuffer 182,395,773
GpuSplit::Drain 180,090,370
GpuSplit::Execute 147,198,951
Maxwell3D::WriteStateRegisters 136,704,435
RasterizerVulkan::FlushRegion 76,692,825

By file: vk_rasterizer.cpp 91, vk_buffer_cache.cpp 24, vk_texture_cache.cpp 19, maxwell_3d.cpp 16, kepler_compute.cpp 14, vk_pipeline_cache.cpp 13, gpu_split.cpp 12. So the GPU command front end and the split's back loop are compiled without a profile in that build.

Linux: the same, but hidden. The Linux PGO step passes -Wno-backend-plugin (the Windows step uses -Wno-error=backend-plugin), so the log shows nothing. eglantine.profdata, which linux-x86_64-pgo and linux-aarch64-pgo use, was last committed on 31 October (919368b). Building nx2 107ce81 with the workflow's flags and the same compiler (Ubuntu clang 23.1.6 from apt.llvm.org), with only that warning turned back on, drops the profile of 1,231 functions, 621 of them with non-zero counts: src/video_core 415 (279 non-zero), src/core 400 (170), src/dynarmic 249 (78). The largest:

function discarded count
Maxwell3D::FrontRunMacro 41.93 G
Maxwell3D::FrontWrite 32.97 G
Maxwell3D::CallMethod 17.88 G
DmaPusher::CallMethod 16.25 G
GpuSplit::BackLoop 10.46 G
Shader::Maxwell::Decode 10.25 G
BufferCacheRuntime::TickFrame 8.67 G
MemoryManager::GpuToCpuAddress 7.64 G

The profile's maximum function count is 37.2 G, so the two hottest functions in it are among the dropped. (Built without the Qt frontend, so its files are not counted. One file, vk_texture_cache.cpp, was compiled with #2478's two-line rename applied, because our configure had ENABLE_WERROR at its default and clang rejects the shadowed device there; 24 of the 1,231 come from that file.)

What it costs, measured. Steam Deck OLED (RADV), Ocarina of Time, Kokiri Forest, one tree (our fork's build 7, 81aaf9c), one compiler (clang 23.1.4), interleaved runs, standing / panning fps:

profile standing panning functions dropped (with counts)
trained that day on that tree 19.51 15.69 5 (1)
trained 8 days earlier (15 Nov) 18.57 15.41 770 (366)
none (build.ninja has no fprofile) 17.90 14.43 –

The first two rows are four rounds in rotated order in one session; the third is six runs of a no-profile build over two sessions the next morning, two of them interleaved with the fresh-profile build (16.85 / 14.46 and 17.96 / 14.50 against 19.78 / 15.99 and 19.46 / 15.93). So a profile that matches the code is worth about 10 % on this machine, standing and panning, and after eight days it had lost about half of that standing: 5.1 % against the fresh one. The dropped functions were the same family as in the lists above (FrontWrite, FrontRunMacro, GpuSplit::BackLoop, Backoff, Execute, Drain, WaitFor, DmaPusher::CallMethod).

Not measured: the fps cost on Windows or NVIDIA, and other games.

Suggestions.

  • Make the count visible in both jobs: -Wno-error=backend-plugin instead of -Wno-backend-plugin on Linux, then count the hash mismatch lines (and those not "up to 0 count") from the build output into the job summary, with a ::warning:: above a threshold. Our two data points: 5 after a retrain, several hundred after a week; about 50 with non-zero counts would be a reasonable alarm.
  • Retrain the profiles on the tree being released, or on a schedule; a profile older than a few days of nx2 no longer covers the GPU thread.
  • We can send the workflow change as a PR, and release-binaries: give linux-x86_64-pgo a profile trained on Ocarina of Time #1909 (a Linux profile trained on Ocarina of Time) will need its profile retrained before it is worth merging: it is as old as the one measured above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

Activity

  1. danieljesus commented on Nov 24, 2026

    @danieljesus
    ContributorAuthor

    A follow-up on the size of the gain. Above I wrote "about 10 %" for a profile that matches the code, from six no-profile runs spread over two sessions. A tighter measurement since then, on a newer tree of our fork with a profile trained on that tree (same Steam Deck, same scene, same clang 23.1.4, four interleaved pairs, standing / panning fps):

    standing panning
    with the profile 19.48 / 19.49 / 19.73 / 19.53 — mean 19.56 15.78 / 16.08 / 15.78 / 15.65 — mean 15.82
    no profile 18.63 / 18.03 / 18.60 / 18.59 — mean 18.46 14.97 / 14.96 / 14.66 / 14.51 — mean 14.78

    That is +6.0 % standing and +7.0 % panning, the profile ahead in all four pairs, with 5 dropped functions in that build (1 with a count). So "about 6 to 7 %" is the better figure for what a matching profile is worth on this machine; the comparison of a fresh profile against an eight-day-old one (5.1 % standing, 770 dropped) is as posted.

    Thank you for #2527.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

  2. capy-ai commented on Nov 24, 2026

    @capy-ai
    Contributor

    Which fork commit did you use for the four interleaved pairs in this follow-up? The issue already names the revision for the earlier comparison. The newer SHA would let us tie the 6–7% result to the exact build. No rerun needed.

  3. danieljesus commented on Nov 24, 2026

    @danieljesus
    ContributorAuthor

    Both arms were built from the same commit of our fork, danieljesus/Lichii 753a5f3, with nothing local on top, using clang 23.1.4 and lld: one with no profile at all, the other with a profile trained on that commit. That profile is the lichii-linux.profdata committed in e4c59be on the branch wip/deck/b8-linux-pgo, two commits further on; the commit in between changes a test file only.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions