Files
darling-lol/tools/riot-metal-bind-model/extract-bind-tracking.py
T
lucannez64andClaude Opus 5.5 4370f375cd Cut Darling overhead in League fights and add passive match capture
Game process (ARAM Hexgate: 84 -> 127 FPS average, slowest stretches ~110):
- Local pthread mutexes, condition variables and Mach semaphores are on by
  default in the game process only, with /tmp/rclol-no-local-* opt-outs.
  The main thread's darlingserver waits fell from 1.36 to 0.10 ms per frame.
- Local semaphores: the count and the slot generation change in one
  compare-exchange, a destroy leaves a negative marker, the table is reset
  after fork, and names the table did not create go to the server.
- Metal: drop identical re-binds (keyed on the Indium object, depth-stencil
  retained), pass blit resources by reference, and stop resetting vertex
  descriptors twice.
- Core isolation of the main thread is opt-in (/tmp/rclol-core-isolation);
  it lowered FPS in its only match.
- Optimized libc/libc++/Foundation overlays, AVX2 string primitives, real CPU
  topology and their installers and offline checks.

Tools and docs:
- tools/riot-match-capture: passive /proc sampler, user-space IP profiler and
  reports, plus a comparison against the game's netstats.
- tools/riot-lsem-model and tools/riot-metal-bind-model: host models that
  extract the shipped code and check it.
- tools/install-riot-metal-pair.sh installs Metal and Indium together.
- Status, setup, testing and troubleshooting docs updated with the measured
  matches and the switch table; manifest file counts match the patches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 16:48:34 +02:00

28 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""Extract the bind-tracking helpers from the Metal wrapper verbatim, for the host model.
The model test (bind-dedup-model.cpp) must exercise the code that ships, not a copy of
it: this pulls the region from `struct MTLBindObjectSlots` to the diagnostic counter out
of src/Metal/MTLRenderCommandEncoder.mm and writes it as a C++ include fragment.
Run it before compiling the model; it fails loudly if the markers moved.
"""
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
ROOT = HERE.parent.parent
SOURCE = ROOT / 'build/darling-src/src/external/metal/src/Metal/MTLRenderCommandEncoder.mm'
OUT = ROOT / 'build/riot-metal-bind-model/bind-tracking.extract.inc'
OUT.parent.mkdir(parents=True, exist_ok=True)
text = SOURCE.read_text().splitlines(True)
start = next((i for i, line in enumerate(text) if line.startswith('struct MTLBindObjectSlots')), None)
end = next((i for i, line in enumerate(text) if line.startswith('// Diagnostic (guest flag /tmp/metal-debug-binds')), None)
if start is None or end is None or end <= start:
sys.exit('bind-tracking markers not found in %s' % SOURCE)
region = ''.join(text[start:end]).rstrip() + '\n'
OUT.write_text('// Generated by extract-bind-tracking.py from %s (lines %d-%d). Do not edit.\n%s'
% (SOURCE.name, start + 1, end, region))
print('wrote %s (%d lines)' % (OUT, region.count('\n')))