Benchmark routes: VICTORY_BENCH_ROUTE=downtown|drive #554

Manually merged
github merged 114 commits from github-bot/gh-554 into main 2026-12-05 20:24:25 +00:00 AGit
Owner

@⁠jackonick on GitHub · 2026-12-05 03:05 UTC · original
jackonick:bench-routes → main · +2141 −14 · 10 files · 2 commits · merged 2026-12-05 20:22 UTC

Two fixed benchmark routes built into the layer, so anyone can benchmark the same places the same way, with no mods. Results are comparable across machines and builds (game 1.0.2.1).

Usage

./run.sh play VICTORY_BENCH=nort VICTORY_BENCH_ROUTE=downtown
./run.sh play VICTORY_BENCH=rt   VICTORY_BENCH_ROUTE=drive
./run.sh play VICTORY_BENCH_ROUTE=drive    # just watch, no recording

VICTORY_BENCH_MINUTES still sets the length. With VICTORY_BENCH, timing starts when the route starts, and bench_stats.txt names the route.

Routes

  • downtown: a noclip flight in a Blista around a 2400 m square with its corner at (-2600, -1000).
    • 30 m/s, 40 m above the ground (smoothed), with the camera sweeping 60° each way.
    • That is the city's densest area, found by a frame-rate scout over the whole map. One lap takes about 5 min 20 s.
  • drive: the game's own AI drives a Blista around a loop on the roads in the hills, starting at (-2556, 6948), with traffic. About 3.5 min a lap.
    • The waypoints are points the AI was seen to reach on the road. Off the road network its route finding stalls.
  • Both routes start 15 s after the player appears in the world. They set 12:00 with the clock paused, hold sunny weather, allow no wanted level, and make the player invincible.

How it works

crates/victory-loader/src/bench_route.rs is a minimal script-native caller:

  • Finding natives: the 26 natives it uses are found by their 1.0.2.1 offsets, and each one is checked by the native id its handler writes. It also checks the build and PLAYER_PED_ID's prologue. If anything doesn't match, it logs and does nothing.
  • Per-frame tick: PLAYER_PED_ID's handler is hooked for a per-frame tick on one elected game script thread (the approach of ViceHook, MIT).
  • Fault guard: every call goes through an SEH-guarded stub, so a fault stops the route, not the game.
  • Car spawning: a port of ViceHook's spawn path.
  • Off by default: nothing is hooked unless VICTORY_BENCH_ROUTE is set.
  • ViceHook: don't combine the routes with ViceHook, since both hook the same native. The README says so.

Testing

  • Builds: this branch, based on main, builds clean, and the route unit tests pass.
  • In game: both routes were run on an RX 7600 8 GB under Linux/RADV. That was a downstream build with the same route code (main's shader cache would have needed a full rebuild here).
    • downtown: flies the square and laps.
    • drive: completes laps on the road with traffic.
  • Not run in game: recording through VICTORY_BENCH on this exact branch.

🤖 Generated with Claude Code

**@⁠jackonick** on GitHub · 2026-12-05 03:05 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554) `jackonick:bench-routes` → `main` · +2141 −14 · 10 files · 2 commits · merged 2026-12-05 20:22 UTC Two fixed benchmark routes built into the layer, so anyone can benchmark the same places the same way, with no mods. Results are comparable across machines and builds (game 1.0.2.1). ## Usage ```sh ./run.sh play VICTORY_BENCH=nort VICTORY_BENCH_ROUTE=downtown ./run.sh play VICTORY_BENCH=rt VICTORY_BENCH_ROUTE=drive ./run.sh play VICTORY_BENCH_ROUTE=drive # just watch, no recording ``` `VICTORY_BENCH_MINUTES` still sets the length. With `VICTORY_BENCH`, timing starts when the route starts, and `bench_stats.txt` names the route. ## Routes - **`downtown`**: a noclip flight in a Blista around a 2400 m square with its corner at (-2600, -1000). - 30 m/s, 40 m above the ground (smoothed), with the camera sweeping 60° each way. - That is the city's densest area, found by a frame-rate scout over the whole map. One lap takes about 5 min 20 s. - **`drive`**: the game's own AI drives a Blista around a loop on the roads in the hills, starting at (-2556, 6948), with traffic. About 3.5 min a lap. - The waypoints are points the AI was seen to reach on the road. Off the road network its route finding stalls. - **Both routes** start 15 s after the player appears in the world. They set 12:00 with the clock paused, hold sunny weather, allow no wanted level, and make the player invincible. ## How it works `crates/victory-loader/src/bench_route.rs` is a minimal script-native caller: - **Finding natives:** the 26 natives it uses are found by their 1.0.2.1 offsets, and each one is checked by the native id its handler writes. It also checks the build and PLAYER_PED_ID's prologue. If anything doesn't match, it logs and does nothing. - **Per-frame tick:** PLAYER_PED_ID's handler is hooked for a per-frame tick on one elected game script thread (the approach of ViceHook, MIT). - **Fault guard:** every call goes through an SEH-guarded stub, so a fault stops the route, not the game. - **Car spawning:** a port of ViceHook's spawn path. - **Off by default:** nothing is hooked unless `VICTORY_BENCH_ROUTE` is set. - **ViceHook:** don't combine the routes with ViceHook, since both hook the same native. The README says so. ## Testing - **Builds:** this branch, based on `main`, builds clean, and the route unit tests pass. - **In game:** both routes were run on an RX 7600 8 GB under Linux/RADV. That was a downstream build with the same route code (main's shader cache would have needed a full rebuild here). - **downtown:** flies the square and laps. - **drive:** completes laps on the road with traffic. - **Not run in game:** recording through `VICTORY_BENCH` on this exact branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two fixed, reproducible routes built into the layer, so every machine
benchmarks the same places the same way without mods (game 1.0.2.1).

- victory-loader bench_route: a minimal script-native caller. Handlers
  are found by their 1.0.2.1 offsets and each checked by the id its cold
  block writes; PLAYER_PED_ID's handler is hooked for a per-frame tick in
  one elected game script thread (the approach of ViceHook, MIT). Every
  call goes through an SEH-guarded stub: a fault stops the route, not the
  game. Nothing is hooked without the variable.
- downtown: a noclip flight over a 2400 m square at (-2600, -1000), 30 m/s,
  40 m over the smoothed ground, camera sweeping, in a Blista: the city's
  densest blocks (found by a frame-rate scout over the map).
- drive: the game's AI drives a Blista around a loop on the roads in the
  hills from (-2556, 6948), with traffic (about 3.5 min a lap).
- Both set 12:00 (clock paused), held sunny weather and no wanted level.
- With VICTORY_BENCH, the run is timed from the route's start (nothing
  skipped) and bench_stats.txt names the route; run.sh does not carry
  the route over into the restart after a benchmark.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 03:08:28 +00:00
Author
Owner

@⁠Widget9337 on GitHub · 2026-12-05 06:27 UTC · original · edited 2026-12-05 06:34 UTC

Thanks for this, a fixed route is exactly what I was missing for test runs.

Tried both routes on an RX 9070 XT 16 GB (Ryzen 9 7950X3D, 64 GB RAM, CachyOS, this repo's Mesa and vkd3d-proton), game 1.0.2.1, Series X, 1080p with FSR 4 Balanced, ray tracing on. The PR merged cleanly onto main b581f7e (plus #428 and #445), release build. I used VICTORY_BENCH_ROUTE on its own with my usual settings, without VICTORY_BENCH.

downtown: works

All 25 natives checked, the flight started 15 s after Jason appeared, and the laps logged at 320 s and 640 s. One thing made the laps differ: with no input, the idle camera starts and takes over the view.

I got around it locally with a stick nudge: during the route, the first pad's right stick is set to 0.5 for 0.2 s every 10 s, in pad() in gameinput.rs, next to the benchmark's Enter:

if slot == 0 && route_nudge() && pad.right_x.abs() < 0.1 {
    pad.right_x = 0.5;
}

route_nudge() is true for the first 0.2 s of every 10 s when VICTORY_BENCH_ROUTE=downtown. Since the flight sets the camera's direction every frame (SET_CAM_RELATIVE), the nudge never shows. With it, the idle camera didn't start once over a full lap.

That only works with a controller connected, though. Two ways it could work for everyone:

  • Nudge the keyboard's stand in pad as well (the FALLBACK device, whose right stick is I/J/K/L), so it works the same with no pad connected.
  • Better, if you can find its handler in 1.0.2.1: call the game's own idle camera reset (INVALIDATE_IDLE_CAM, and INVALIDATE_VEHICLE_IDLE_CAM for the car) each frame next to SET_CAM_RELATIVE. That wouldn't need any input at all.

A warning about using a key instead: I tried F15, assuming nothing was bound to it, and it opened the phone (first person, half the screen) and reopened it every 10 s.

drive: two problems

1. The teleport did nothing here. The first try ended with stopped: the ground at the start did not load in 60 s, and Jason never left the house. teleport() is the only place SET_ENTITY_COORDS is used, and on this build it left Jason where he spawns. So the ground at (-2556, 6948) never streamed in, because he wasn't there. Switching teleport() to the flight's call fixed it:

call(SET_ENTITY_COORDS_NO_OFFSET, &cells_of(&[&e.0, &v, &[0, 0, 0, f(0.0)]]))

The start then took about 1 s. Separately, when the route stops there, he stays frozen in the air. A freeze(me, false) on the way out would help.

2. Leg 2 ends in a tree, every time. Two runs, with no input at all in the second:

run 1 run 2
leg 0 to (-2399, 7172) 43 s 44 s
leg 1 to (-2566, 7202) 29 s 29 s
leg 2 back to the start stuck at (-2563, 7191) stuck at (-2560, 7191)

About 11 m past waypoint 1, heading for the start 243 m away, the AI drives into a tree and gets stuck on it. Since it's the same spot both times, I'd guess waypoint 1 is just off the road, so the AI has no road to follow back and goes straight at the start. Maybe an extra waypoint between 1 and the start, on the road, would fix it.

**@⁠Widget9337** on GitHub · 2026-12-05 06:27 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554#issuecomment-7433358108) · edited 2026-12-05 06:34 UTC Thanks for this, a fixed route is exactly what I was missing for test runs. Tried both routes on an RX 9070 XT 16 GB (Ryzen 9 7950X3D, 64 GB RAM, CachyOS, this repo's Mesa and vkd3d-proton), game 1.0.2.1, Series X, 1080p with FSR 4 Balanced, ray tracing on. The PR merged cleanly onto `main` `b581f7e` (plus #428 and #445), release build. I used `VICTORY_BENCH_ROUTE` on its own with my usual settings, without `VICTORY_BENCH`. ## downtown: works All 25 natives checked, the flight started 15 s after Jason appeared, and the laps logged at 320 s and 640 s. One thing made the laps differ: **with no input, the idle camera starts** and takes over the view. I got around it locally with a stick nudge: during the route, the first pad's right stick is set to 0.5 for 0.2 s every 10 s, in `pad()` in `gameinput.rs`, next to the benchmark's Enter: ```rust if slot == 0 && route_nudge() && pad.right_x.abs() < 0.1 { pad.right_x = 0.5; } ``` `route_nudge()` is true for the first 0.2 s of every 10 s when `VICTORY_BENCH_ROUTE=downtown`. Since the flight sets the camera's direction every frame (`SET_CAM_RELATIVE`), the nudge never shows. With it, the idle camera didn't start once over a full lap. That only works with a controller connected, though. Two ways it could work for everyone: - **Nudge the keyboard's stand in pad as well** (the `FALLBACK` device, whose right stick is I/J/K/L), so it works the same with no pad connected. - **Better, if you can find its handler in 1.0.2.1:** call the game's own idle camera reset (`INVALIDATE_IDLE_CAM`, and `INVALIDATE_VEHICLE_IDLE_CAM` for the car) each frame next to `SET_CAM_RELATIVE`. That wouldn't need any input at all. A warning about using a key instead: I tried F15, assuming nothing was bound to it, and it opened the phone (first person, half the screen) and reopened it every 10 s. ## drive: two problems **1. The teleport did nothing here.** The first try ended with `stopped: the ground at the start did not load in 60 s`, and Jason never left the house. `teleport()` is the only place `SET_ENTITY_COORDS` is used, and on this build it left Jason where he spawns. So the ground at (-2556, 6948) never streamed in, because he wasn't there. Switching `teleport()` to the flight's call fixed it: ```rust call(SET_ENTITY_COORDS_NO_OFFSET, &cells_of(&[&e.0, &v, &[0, 0, 0, f(0.0)]])) ``` The start then took about 1 s. Separately, when the route stops there, he stays frozen in the air. A `freeze(me, false)` on the way out would help. **2. Leg 2 ends in a tree, every time.** Two runs, with no input at all in the second: | | run 1 | run 2 | |---|---|---| | leg 0 to (-2399, 7172) | 43 s | 44 s | | leg 1 to (-2566, 7202) | 29 s | 29 s | | leg 2 back to the start | stuck at (-2563, 7191) | stuck at (-2560, 7191) | About 11 m past waypoint 1, heading for the start 243 m away, the AI drives into a tree and gets stuck on it. Since it's the same spot both times, I'd guess waypoint 1 is just off the road, so the AI has no road to follow back and goes straight at the start. Maybe an extra waypoint between 1 and the start, on the road, would fix it.
Author
Owner

@⁠luisaugustz on GitHub · 2026-12-05 13:30 UTC · original

Thanks for this.

  • downtown worked on every run here: about 50 runs on RX 9070 XT + Ryzen 7 5800X, game 1.0.2.1, RADV. The flight is steady enough that 200 s windows of the baseline land within about ±0.3 fps of each other.
  • drive: the AI took a long detour on leg 1 and then stood at 1 km/h for a while in the run I tried, so I used downtown for the comparisons.

Results are in #591.

**@⁠luisaugustz** on GitHub · 2026-12-05 13:30 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554#issuecomment-7438792321) Thanks for this. - **`downtown`** worked on every run here: about 50 runs on RX 9070 XT + Ryzen 7 5800X, game 1.0.2.1, RADV. The flight is steady enough that 200 s windows of the baseline land within about ±0.3 fps of each other. - **`drive`**: the AI took a long detour on leg 1 and then stood at 1 km/h for a while in the run I tried, so I used `downtown` for the comparisons. Results are in #591.
Author
Owner

@⁠t-jonesy on GitHub · 2026-12-05 14:19 UTC · original

Thanks for the routes. downtown has become our main bench for driving 1% lows. Here are the fixes we needed on top of 82b99a6 and what we measured. RX 9070 XT 16 GB, Ryzen 9 7950X3D, game 1.0.2.1, 3840x2160 with FSR 4 Performance, ray tracing on, 30 fps cap.

Fixes we carry (same findings as Widget9337's):

  • Teleport. teleport() now uses SET_ENTITY_COORDS_NO_OFFSET with [e, v, 0, 0, 0, f(0.0)], as the flight does. With plain SET_ENTITY_COORDS the player stayed at the spawn and the drive stopped with "the ground at the start did not load in 60 s". With NO_OFFSET the start takes about 1 s.
  • Unfreeze on every exit. freeze(me, false) runs on every way out of a route, so a stopped route no longer leaves the player frozen in the air.
  • Idle camera on downtown. The right stick is pushed to 0.5 for the first 0.2 s of every 10 s once the route has started, unless something else moves it. The push goes to the first pad and to the keyboard's stand-in pad, so it works with no controller connected. The flight sets the camera's direction every frame, so the push never shows. Over an 11-minute flight the idle camera never started. We did not find INVALIDATE_IDLE_CAM's handler in 1.0.2.1, and we avoided key nudges (Widget9337's F15 opened the phone).
  • VICTORY_BENCH_ROUTE=spot. We added this mode for fixed-camera benches after an autosave moved our spawn indoors. Fifteen seconds after the player appears, it applies the same noon, sunny, no-wanted and invincible settings. It holds the player over VICTORY_BENCH_SPOT=x,y[,heading] (default: the downtown square's corner) until the ground loads, puts him there, and leaves him alone. It still needs some input, or the idle camera starts after about 30 s.

drive: waypoint 1 is the problem, not the leg back. With the teleport fixed, we changed the loop to go back the way it came: start, (-2399, 7172), (-2566, 7202), (-2399, 7172). That did not help:

  • Legs 0 and 1 took 42 s and 29 s, as in Widget9337's runs.
  • On leg 2, from (-2566, 7202) back toward (-2399, 7172), the AI drove to (-2709, 7272), into the river, and sat at 0 km/h until the leg was skipped at 180 s.

So from (-2566, 7202) the AI leaves the road in both directions: a tree toward the start, the river toward the previous point. That suggests the point itself is off the road network, at the end of a spur. Moving that waypoint onto the road, or dropping it, is probably the fix. We have not found a replacement point yet. luisaugustz's long detour on leg 1 may be the same thing.

downtown as a lows bench. Our method: start the window 60 s after the route starts (to skip the first streaming), measure to +270 s, take frame intervals from a tracer, and interleave A/B arms with control runs.

  • Laps are exact, at 320 s and 640 s.
  • Position in the lap is repeatable. 40 s bins of lap time agree within about 1 fps between runs. The exception is 160-200 s into the first lap, where streaming is heaviest; it is also the slowest bin.
  • The control's run-to-run spread is small. Two sets of 6 and 5 control runs, on different builds the same night: average 25.5 ± 0.3 and 25.6 ± 0.2 fps, frame 1% low 6.64 ± 0.24 and 6.77 ± 0.21 fps, frames over 50 ms 17.4% and 17.0% (± 1 point). That matches luisaugustz's ±0.3 fps for 200 s averages.
  • For comparison: the same box with an idle camera panning at one spot spread 2-7 fps in 1% low over 33 runs, so it could not resolve lows changes at all.
  • It loads the CPU and memory paths hard. About 6.5-6.7k draws a frame at noon, with heavy streaming. Our slow frames there were CPU-late, which is what makes it useful for lows rather than for GPU-bound averages.

With it we could separate changes of 1.3-2.2 fps in the 1% low from noise with 3 runs per arm, and reject several changes that were neutral (0 ± 0.3).

**@⁠t-jonesy** on GitHub · 2026-12-05 14:19 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554#issuecomment-7439476089) Thanks for the routes. `downtown` has become our main bench for driving 1% lows. Here are the fixes we needed on top of 82b99a6 and what we measured. RX 9070 XT 16 GB, Ryzen 9 7950X3D, game 1.0.2.1, 3840x2160 with FSR 4 Performance, ray tracing on, 30 fps cap. **Fixes we carry (same findings as Widget9337's):** - **Teleport.** `teleport()` now uses `SET_ENTITY_COORDS_NO_OFFSET` with `[e, v, 0, 0, 0, f(0.0)]`, as the flight does. With plain `SET_ENTITY_COORDS` the player stayed at the spawn and the drive stopped with "the ground at the start did not load in 60 s". With NO_OFFSET the start takes about 1 s. - **Unfreeze on every exit.** `freeze(me, false)` runs on every way out of a route, so a stopped route no longer leaves the player frozen in the air. - **Idle camera on `downtown`.** The right stick is pushed to 0.5 for the first 0.2 s of every 10 s once the route has started, unless something else moves it. The push goes to the first pad and to the keyboard's stand-in pad, so it works with no controller connected. The flight sets the camera's direction every frame, so the push never shows. Over an 11-minute flight the idle camera never started. We did not find `INVALIDATE_IDLE_CAM`'s handler in 1.0.2.1, and we avoided key nudges (Widget9337's F15 opened the phone). - **`VICTORY_BENCH_ROUTE=spot`.** We added this mode for fixed-camera benches after an autosave moved our spawn indoors. Fifteen seconds after the player appears, it applies the same noon, sunny, no-wanted and invincible settings. It holds the player over `VICTORY_BENCH_SPOT=x,y[,heading]` (default: the downtown square's corner) until the ground loads, puts him there, and leaves him alone. It still needs some input, or the idle camera starts after about 30 s. **`drive`: waypoint 1 is the problem, not the leg back.** With the teleport fixed, we changed the loop to go back the way it came: start, (-2399, 7172), (-2566, 7202), (-2399, 7172). That did not help: - Legs 0 and 1 took 42 s and 29 s, as in Widget9337's runs. - On leg 2, from (-2566, 7202) back toward (-2399, 7172), the AI drove to (-2709, 7272), into the river, and sat at 0 km/h until the leg was skipped at 180 s. So from (-2566, 7202) the AI leaves the road in both directions: a tree toward the start, the river toward the previous point. That suggests the point itself is off the road network, at the end of a spur. Moving that waypoint onto the road, or dropping it, is probably the fix. We have not found a replacement point yet. luisaugustz's long detour on leg 1 may be the same thing. **`downtown` as a lows bench.** Our method: start the window 60 s after the route starts (to skip the first streaming), measure to +270 s, take frame intervals from a tracer, and interleave A/B arms with control runs. - **Laps are exact,** at 320 s and 640 s. - **Position in the lap is repeatable.** 40 s bins of lap time agree within about 1 fps between runs. The exception is 160-200 s into the first lap, where streaming is heaviest; it is also the slowest bin. - **The control's run-to-run spread is small.** Two sets of 6 and 5 control runs, on different builds the same night: average 25.5 ± 0.3 and 25.6 ± 0.2 fps, frame 1% low 6.64 ± 0.24 and 6.77 ± 0.21 fps, frames over 50 ms 17.4% and 17.0% (± 1 point). That matches luisaugustz's ±0.3 fps for 200 s averages. - **For comparison:** the same box with an idle camera panning at one spot spread 2-7 fps in 1% low over 33 runs, so it could not resolve lows changes at all. - **It loads the CPU and memory paths hard.** About 6.5-6.7k draws a frame at noon, with heavy streaming. Our slow frames there were CPU-late, which is what makes it useful for lows rather than for GPU-bound averages. With it we could separate changes of 1.3-2.2 fps in the 1% low from noise with 3 runs per arm, and reject several changes that were neutral (0 ± 0.3).
Author
Owner

@⁠luisaugustz on GitHub · 2026-12-05 15:11 UTC · original

@⁠t-jonesy The idle camera can also be turned off in the game's own settings menu. That should make the stick pushes unnecessary, including for spot.

**@⁠luisaugustz** on GitHub · 2026-12-05 15:11 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554#issuecomment-7440210209) @⁠t-jonesy The idle camera can also be turned off in the game's own settings menu. That should make the stick pushes unnecessary, including for `spot`.
Author
Owner

@⁠datWeazel on GitHub · 2026-12-05 16:44 UTC · original

On main @ 8bf4878 with VICTORY_BENCH=nort VICTORY_BENCH_ROUTE=downtown (game 1.0.2.1, RX 6950 XT), the route started on the title screen. PLAYER_PED_ID is already valid there, and the ped stands at the save's position, so "the player is in the world" was logged before any save had loaded. The benchmark then timed 5 min of the menu, and the automatic Enter presses no longer got past the account picker.

Waiting for the ped to move 2 m from the position first seen worked reliably here (4 of 4 runs); it needs one step from the player. A draw-count threshold does not work: the title screen draws about 11,000 draws a frame.

Also, the route can trigger an autosave, so restoring the save before each run is worth a note in the README.

**@⁠datWeazel** on GitHub · 2026-12-05 16:44 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/554#issuecomment-7441552088) On `main` @ 8bf4878 with `VICTORY_BENCH=nort VICTORY_BENCH_ROUTE=downtown` (game 1.0.2.1, RX 6950 XT), the route started on the title screen. `PLAYER_PED_ID` is already valid there, and the ped stands at the save's position, so "the player is in the world" was logged before any save had loaded. The benchmark then timed 5 min of the menu, and the automatic Enter presses no longer got past the account picker. Waiting for the ped to move 2 m from the position first seen worked reliably here (4 of 4 runs); it needs one step from the player. A draw-count threshold does not work: the title screen draws about 11,000 draws a frame. Also, the route can trigger an autosave, so restoring the save before each run is worth a note in the README.
github-bot force-pushed github-bot/gh-554 from 82b99a685a to 24abbb25cc 2026-12-05 20:23:59 +00:00 Compare
github manually merged commit 8c77ccaf1a into main 2026-12-05 20:24:09 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.