8.6 KiB
8.6 KiB
Optimizer agent report (branch ap/optimizer)
Task: a benchmark that finds the engine settings for the owner's minimums and one priority, with an overlay entry, result files the launcher can read, and a cheap headroom check from session stats.
What changed
| Area | Files |
|---|---|
| Search, verdict, result dict/file/text, measuring a span of the collector, headroom check, live Runner/Control, result card image | new engine/framegen/optimize.py |
Tests (no GPU, no window): parsing, verdict, search order, display ceiling, pruning, time budget, nothing-met report, delay priority, the result file, Runner with the real Collector and Settings (cancel restores exactly, apply saves, CLI quits), backlog wait, pipeline hook, Optimize tab, headroom |
new engine/tests/test_optimize.py (24 tests) |
Pipeline.driver: stepped once a tick, may ask for a restart or the end; optimize* commands forwarded |
engine/framegen/pipeline.py (+8 lines) |
Optimize tab rows (opt_min_res, opt_min_fps, opt_max_delay, opt_priority, opt_budget), specs_json()["optimize"] |
engine/framegen/settings.py (added block before _laid_out, one line in specs_json) |
| Optimize tab actions (Find my settings / Stop / Apply / Keep mine) and the headroom note | engine/framegen/menu.py (small additions) |
Countdown banner and result card drawn over the picture; Esc / Enter while it runs or the card is up; display_mode() |
engine/framegen/io.py (+~50 lines) |
--optimize, --optimize-budget, Machine from the session, result files, headroom in session summaries, --control commands optimize, optimize-cancel, optimize-apply |
engine/run.py, engine/framegen/remote.py (doc lines) |
| Format for the launcher | new docs/optimizer.md |
| README: status rows and an "Optimize: find my settings" section | README.md |
No Rust touched; nothing in compare.py or the launcher crates.
How it works (short)
- Candidates are engine settings only (
interp/hz,model,motion,engine,scaler,vsr_quality,output_res,aa). Bilinear, no upscaler and CAS are not tried (stated in the result). - Order: the cheapest configuration that meets the minimums (smallest multiplier, minimum size, FSR 1, Half motion, AA off). If it fails: 2x when it was "no frame generation", then VFG / TensorRT if available. Then the priority's ladder, one step at a time until a step fails, then the quality ladder in ranking order. Priority "delay" refuses steps that add more than 2 ms. A candidate at least as heavy in every dimension as one that failed on performance is skipped, with the reason. Each step's cost is estimated (7 s live, about 20 s with a restart). The search stops when the budget can't cover the next step, and says so.
- Restart settings (motion, engine, model) are changed one step at a time. A failed restart step means at most one restart back. "No frame generation" keeps the session's AI settings, so it needs no restart.
- Pass rule: see
judge()and docs/optimizer.md. One change from the task's wording: when the display's refresh rate is the minimum, no frame rate can be 10% above it, so the 1% low must reach 97% of the target and the 10% headroom moves to the frame budget (at most ~91% busy). - Live: settings are overrides (never saved) until Apply. Cancel and errors put back exactly the nine engine values as they
were (tested with the real
Settings, file untouched). At the end the best result is shown live under the card.
Verified, and how
cd engine && env -u PYTHONPATH /root/.cache/summit-venv/bin/python -m pytest tests -q: 233 passed, 1 skipped (main had 207 + 1 skipped). Each commit passed it.- GPU test VM, my own directory
/home/user/summit-optimizer(engine venv; Pillow copied from the host venv intopylib), X11 :0, 1920x1080 at 120 Hz monitor, a 1280x720 window, software OpenGL, RTX 3090 shared with another service,play60.mp4(a 720p 60 fps recording) played as a 30 fps game,--no-graph:--optimize "min=1280x720@60,priority=quality": nothing met. The base (2x, 720p, FSR, Half) measured an average of 59.97 fps, a 1% low of 34-37 fps, 21 ms delay and 20% busy; the 1% low must be 58. Cause: the VM's window paces 60 fps unevenly (the session's frame-to-frame jitter was 12.6 ms; vsync on did not help, 37 fps). Kept as the real "not met" example.--optimize "min=1280x720@30,priority=fps", three runs. Run A (screen locked, so no usable screenshots): 7 measured in 126 s. #1 2x + FXAA; 3x rejected (frames dropped); 900p rejected (only 3 frames, then a 10 s queue). Run B: same choice, 6 measured. Run C (screen unlocked; screenshots andreal-result-fps.json): 2x missed by 3 fps (1% low 30, needs 33), so #1 is no frame generation + SMAA. The same goal gave different winners on this shared VM: noise of the test machine, reported as measured.- In-session path, through
--controlon stdin:optimizestarted a run (banner seen),optimize-cancelstopped it ("settings put back", a cancelled result file written),optimizeagain ran to the card, andoptimize-applysaved #1. The settings file afterwards hadoutput_res 1600x900,aa off(wascas),interp false: exactly #1. - Session summaries from these runs contain
headroom(e.g. stateroom, 41% busy at 120 Hz).
- The first VM run found a real bug: after a restart, a file played in real time keeps a backlog for seconds, and the warm-up (one capture-wait reading) measured inside it. The fix: wait until no frame queued 50 ms for a whole second. Unsettled measurements are rejected with the queue length.
Screenshots (docs/media/optimizer/), all looked at
Real engine output, VM window (1280x720) grabbed from the root window and cropped to 1180 px wide to cut out KDE "Memory shortage" popups on the right:
real-cli-countdown.png:--optimizerunning; banner "Optimizing: about 2:21 left, 2 tried / 720p, 2x (60 fps)… / settling".real-cli-card.png: that run's card (run C,real-result-fps.json/.txt). It still says "card memory 20.9 GB" (all programs). The card now shows the engine's own memory; this screenshot is older than that change.real-cli-card-not-met.png: run 1, "your minimums weren't reached" (real-result-not-met.json/.txt).real-overlay-running.png,real-overlay-card.png: the in-session run started through--control(real-result-overlay-applied.json). The stats line shows a 6.5 s delay at that moment: the backlog left by the rejected 900p+FXAA step was still draining.headless-menu-optimize-tab.png: the Optimize tab rendered headless byMenu.render(). The headroom note on it is sample text.real-session-summary-with-headroom.json: a real summary withheadroom. It was written before suggestions got theirsetfield, and its first suggestion ("hz 60" with frame generation off) is the bug that change fixed.
Not done / untested / to know
- Not run on a real game, Remote Play, a capture card, Windows or Wayland. RTX VSR, NVIDIA VFG and TensorRT were not on the VM, so their steps (and VFG/TensorRT fallbacks) ran only in tests. Restart steps (Full motion) ran live only as the session's own motion "auto" -> "half" restarts. A climb that restarts to Full was not reached on the VM.
- Keys on the card (Enter/Esc) and the menu rows were not pressed live. My first attempt with XTest keys went to the
wrong windows: other agents' engine windows were open on the shared display, and some of my key presses (m, Tab, Down,
Return, Escape, around 07:2x VM time) probably reached another agent's test window. I stopped and used
--controlinstead. The menu rows and Enter/Esc handling are covered by tests and the headless render only. - "Most added delay" uses the pipeline's own real-frame delay (arrival to screen), not end-to-end input lag.
- With frame generation off, the screen still gets 60 presents a second (each game frame twice), so "average 60 fps" shows for a "30 fps" configuration. The pass rule uses the game's rate there.
- "Load" (pipeline busy) adds up AI-frame wall time and GL timer queries. On software OpenGL the upscaler's time is the CPU's.
- The Optimize rows also appear in the launcher's Settings page (the registry test requires every setting in
specs_json). The profiles agent can hide that section or use it to start a run (set opt_...+optimizeover--control). - The 1% low over 5 s is strict: one 25 ms hitch in 300 frames fails a 60 fps target on a 60 Hz display. That is deliberate (the owner asked for
lows, not averages). If it proves too strict on the owner's PC,
MEASURE_SorAT_TARGETare the knobs.