Skip to content

Turing: add small-BAR1 Metal rules and optional kext patch tool - #179

Open
Golopmoui3 wants to merge 1 commit into
nullmoth:mainfrom
Golopmoui3:fix/turing-stutter-optimization
Open

Golopmoui3 wants to merge 1 commit into
nullmoth:mainfrom
Golopmoui3:fix/turing-stutter-optimization

Conversation

@Golopmoui3

@Golopmoui3 Golopmoui3 commented Nov 14, 2026 •

Copy link
Copy Markdown

What was wrong
On Turing GPUs (TU104/TU106/TU116) with a 256 MB BAR1 window, WindowServer dragging can stutter, drop surfaces, or show black window rectangles when Metal buffer pooling and VRAM headroom exhaust the aperture. On driver 3.0 (macOS 15), NVRMFB also hits a 256 MB vramGrant cap (0x21ea3) and NVAccel triggers idle surface eviction (gSurfGpuOn at 0x251e0) and sticky VM churn (gVmSticky at 0x23f1c).

What this changes

  • mac/Resources/nullmoth-rules.json: adds turing-bar1-stutter-optimization matching {"arch": ["turing"]} so nullmoth-setup.sh writes the nvrm610.conf Metal knobs (NVMTL_VRAM_HEADROOM_MB=48, NVMTL_NO_SURFACE_PAGEOFF=0, disabled reuse/grace pools, NVMTL_GSUB_HOSTPTR_LIFT=1, etc.) through the standard per-system rules block without altering signed or SHA-256-pinned kext binaries.
  • tools/apply-turing-fix.sh: moves the optional NVRMFB / NVAccel binary patches into a standalone opt-in script (--check, --apply, --conf-only, --revert) instead of patching kexts inside nullmoth-setup.sh. Verifies root, SIP filesystem status, macOS 15, driver 3.0, Turing PCI ID (1e00..21ff), 64-bit Mach-O headers, optional --accel-sha256 / --fb-sha256 pins, and exact target bytes before touching files; stores SHA256SUMS-checked backups under /Library/NullMoth/turing-backup/ and checks kmutil inspect with automatic rollback on failure.
  • docs/TURING_OPTIMIZATION.md: documents the BAR1 Metal rules and optional tool usage.
  • tests/test_turing_stutter_rules.py: verifies rule matching/knob formatting, confirms nullmoth-setup.sh does not modify kext binaries, and checks the standalone tool's version/checksum/rollback guards.

How I tested it

  • Hardware run: AMD Ryzen 5 5600 + NVIDIA GeForce RTX 2060 SUPER 8 GB (10de:1f06, TU106, 256 MB BAR1) on macOS 15.8.3 (x86_64): window dragging runs smoothly at 60 FPS with no black surfaces or WindowServer hitches and working NVENC.
  • On this commit: sh -n tools/apply-turing-fix.sh, tools/apply-turing-fix.sh --help, and python -m unittest -v tests.test_turing_stutter_rules tests.test_nvenc_rule_generations tests.test_every_option_has_a_place tests.test_driver_optins_have_a_home (16/16 passed). Full tests/ discovery ran on Windows (1144 tests: 0 failures, 8 skipped, 7 Windows-environment errors from missing C compiler / symlink privileges). mac/tools/ and mac/build.sh were not run locally (no macOS host).

@Golopmoui3
Golopmoui3 requested a review from nullmoth as a code owner November 14, 2026 19:55
Golopmoui3 added a commit to Golopmoui3/Golopmoui3 that referenced this pull request Nov 15, 2026
Turing GPUs (TU104/TU106/TU116) with a 256 MB BAR1 aperture can stutter
or drop WindowServer surfaces under Metal buffer pooling and VRAM
headroom exhaustion.

- Add turing-bar1-stutter-optimization to mac/Resources/nullmoth-rules.json
  so nullmoth-setup.sh applies the nvrm610.conf knobs through the standard
  per-system rules path without altering signed or SHA-256-pinned kexts.
- Move the optional NVAccel/NVRMFB binary patches into standalone
  tools/apply-turing-fix.sh with macOS 15, driver 3.0, Turing PCI ID,
  SIP, Mach-O, byte-pattern, and SHA-256 backup verification plus AuxKC
  rollback on failure.
- Add technical notes in docs/TURING_OPTIMIZATION.md and unit tests in
  tests/test_turing_stutter_rules.py.

Tested on AMD Ryzen 5 5600 + NVIDIA GeForce RTX 2060 SUPER (TU106,
10de:1f06) running macOS 15.8.3.

Signed-off-by: Golopmoui3 <200087690+Golopmoui3@users.noreply.github.com>
@Golopmoui3
Golopmoui3 force-pushed the fix/turing-stutter-optimization branch from 0287bf4 to 4151054 Compare November 28, 2026 07:21
@Golopmoui3 Golopmoui3 changed the title Fix Turing (TU106/TU104/TU116) WindowServer dragging micro-stutter & 256MB BAR1 budget drops Turing: add small-BAR1 Metal rules and optional kext patch tool Nov 28, 2026
@Golopmoui3

Copy link
Copy Markdown
Author

Rebased onto the latest main, added DCO sign-off, and updated the PR to match CONTRIBUTING.md and the signed-driver security model:

  • Removed direct binary patching from nullmoth-setup.sh so signed/SHA-256-pinned kexts remain untouched.
  • Routed the safe Metal knobs through mac/Resources/nullmoth-rules.json.
  • Isolated the optional macOS 15 / driver 3.0 kext patcher into standalone tools/apply-turing-fix.sh with pre-flight checks, SHA-256 backups, and AuxKC rollback.

Ready for CI approval and review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant