Skip to content

video_core, service: avoid eager host allocations for descriptors, page tables, and shared fonts - #929

Open
nowhere02 wants to merge 3 commits into
nx2-experimentalfrom
perf/nx2-lazy-host-allocations
Open

nowhere02 wants to merge 3 commits into
nx2-experimentalfrom
perf/nx2-lazy-host-allocations

Conversation

@nowhere02

@nowhere02 nowhere02 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Avoids eagerly faulting ~288 MiB of anonymous host pages at title startup by switching large descriptor, page-table, and shared-font buffers to trivial/lazy/sparse initialization. This PR is standalone and safe on all host RAM sizes without runtime tuning tradeoffs.

Files changed:

  • src/video_core/renderer_vulkan/vk_update_descriptor.h: make DescriptorUpdateEntry trivially default constructible and explicitly zero .pad = 0 in AddBuffer / AddTexelBuffer so std::make_unique_for_overwrite does not fault the entire 120 MiB entry array upfront.
  • src/video_core/memory_manager.h, src/video_core/memory_manager.cpp: switch Tegra::MemoryManager::entries (~64 MiB) to Common::SparseLargeVector<u64> with write-if-changed GetAndFault.
  • src/video_core/texture_cache/descriptor_table.h: grow Refresh geometrically by powers of two from 4096 entries instead of pre-allocating ~16 MiB on tiny limits, preserving the 32-bit wrap-around for near-UINT32_MAX sentinels.
  • src/core/hle/service/ns/platform_service_manager.cpp: lazy-load shared_font on first font request via EnsureFontsLoaded (std::once_flag).

Part 1 of a 4-PR series reducing host RAM footprint on Switch 2 titles.

Assisted-by: Antigravity (RAM profiling, implementation, and verification)

Type of change

  • Bug fix
  • Game compatibility / game-support
  • Performance
  • New feature
  • Refactor / cleanup
  • CI / build
  • Documentation

Related issues

N/A

Testing

  • Tested on Windows
  • Tested on Linux
  • Tested on macOS
  • Tested on NVIDIA
  • Tested on AMD
  • Tested on Intel

Standalone branch build & unit tests:

  • ninja -C build -j10 yuzu eden-cli tests: passed cleanly.
  • ./build/bin/tests "[descriptor_table]": 81,566 assertions in 3 test cases passed.
  • ./build/bin/tests "[memory_manager]": 480,090 assertions in 2 test cases passed.

Games tested:

  • The Legend of Zelda: Ocarina of Time (NX2) & Mario Kart World: validated in-game on Linux (AMD Ryzen 5 Vega iGPU, 15.4 GiB RAM) as part of the combined 4-PR patchset before splitting.

Checklist

  • I built it locally and it compiles without new warnings
  • I did not add any copyrighted game data, keys or firmware
  • Docs updated if needed
  • I added AI Disclosure if one was used

Screenshots / logs

Eliminated the eager 120.01 MiB UpdateDescriptorQueue anonymous VMA from top-20 process VMAs in runtime /proc/<pid>/smaps snapshots; combined with the other 3 PRs in the series, OoT 240s non-JIT host RAM (heap_brk + anon_*) dropped from 3,141 MiB to 1,362 MiB (-56.6%) and system swap delta dropped from +5,570 MiB to +525 MiB (-90.6%).

Summary by CodeRabbit

  • Improvements
    • Shared fonts are loaded when needed and made available to font-data and shared-memory requests.
    • Memory and graphics resource handling has been updated, including more efficient descriptor sizing and memory-entry updates.
    • These changes improve resource handling while preserving existing font lookup and missing-file behavior.

PastaLaPate and others added 3 commits November 22, 2026 00:19
A manual dispatch gains a linux_arch choice (both, x86_64 or aarch64) that narrows the base Linux legs and the Nix linux systems, and a build_nix tick that skips the Nix job entirely. Defaults keep pushes, dailies, PR builds and untouched manual runs building both architectures with Nix on.

Cherry-picked verbatim onto nx2 and nx2-experimental so a rebase of nx2-experimental onto nx2 drops it as already applied.
`no` keeps the skip the boolean could express. `only` runs the Nix job for
the systems the Linux/macOS ticks (and linux_arch) select, and skips the
Linux, Windows and macOS jobs -- plus the release job, whose assets all come
from those legs, so publishing there would only fail on an empty artifact
set. Default stays `yes`: pushes, dailies, PR builds and untouched manual
runs are unchanged.
…ge tables, and shared fonts

Allocating large descriptor queues, full GPU page table vectors, oversized
descriptor table buffers, and all system shared fonts upfront faulted ~288 MiB
of anonymous host pages during boot even when titles barely touched them:

- Make DescriptorUpdateEntry trivially default constructible and omit eager
  zero-initialization in UpdateDescriptorQueue (avoids faulting the full 120 MiB
  in-flight entry buffer upfront).
- Back Tegra::MemoryManager::entries with Common::SparseLargeVector<u64> using
  write-if-changed updates (~64 MiB vector reserved lazily).
- Grow VideoCommon::DescriptorTable::Refresh by powers of two starting at 4096
  entries instead of jumping straight to 512K (~16 MiB), while preserving the
  32-bit sentinel wrap behavior tested by descriptor_table tests.
- Lazy-load ns::IPlatformServiceManager shared_font backing memory on first font
  service request via std::call_once (~34 MiB avoided when unused).

Assisted-by: Antigravity (RAM profiling, implementation, and verification)
@github-actions
github-actions Bot changed the base branch from nx2 to nx2-experimental November 22, 2026 03:34
@github-actions

Copy link
Copy Markdown

Retargeted to nx2-experimental for pre-build testing. It will be promoted to nx2 after validation.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 747e4c68-498f-4316-8004-8eff0f1c7503

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants