Skip to content

Add a script that compares a branch's performance with main - #137

Open
RayTrunk wants to merge 1 commit into
SumirSeth:mainfrom
RayTrunk:feat/bench-perf
Open

RayTrunk wants to merge 1 commit into
SumirSeth:mainfrom
RayTrunk:feat/bench-perf

Conversation

@RayTrunk

@RayTrunk RayTrunk commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The first of the two pull requests for #44: scripts\bench.ps1 -Perf.

  • It builds main in a worktree under target\bench\base and your checkout as it is, both with nightly,perf-trace, and runs them in turn for three rounds.
    • Demo: the launcher_demo scenarios from measure-perf.ps1 at 100% and 125%, with its own APPDATA.
    • Start: three starts per round of the nightly wisp.exe with hide_taskbar = true, also with its own APPDATA. They record when the UI thread is free and when Explorer's taskbar was last visible, and check that the taskbar is hidden after 5 s and back after quitting.
  • Before each run it waits until total CPU stays under 10% for 5 s, and prints the load it measured.
  • It writes target\bench\summary.md to paste into the pull request, plus metrics.csv and the traces.
  • It prints what it will do and asks first. Other running Wisp instances are quit and started again at the end. Your config is never touched.

perf-trace builds get two spans: start around Launcher::start, and dock_paint in the dock's paint. Release builds compile both away. measure-perf.ps1 now also takes an absolute -Demo path, so the script can run main's demo.

Why

So contributors can compare a branch with main on their own machine and paste the result, instead of writing one-off scripts (#44).

How I verified it

Windows 11 Pro build 26300, two screens (2560×1440 at 125%, 1920×1080 at 100%), dock on autohide, Windows PowerShell 5.1 and PowerShell 7.

  • Identical code (this branch against 38c1d4b, which differ only by the two spans), run again after the second commit:

    Medians of the per-round values, with their range. Flagged when every branch round lies outside every main round, and the medians differ by more than 10%, by at least 0.1 (5 points for CPU), and by more than the range within either build.

    Nothing outside the run-to-run noise.

    Starts of main with hide_taskbar: taskbar hidden after 5 s in 9 of 9, back after quitting in 9 of 9.
    Starts of branch with hide_taskbar: taskbar hidden after 5 s in 9 of 9, back after quitting in 9 of 9.

    The taskbar was last visible 459 ms (428-489) after the start on main and 442 ms (398-446) on the branch.

  • The second commit fixes the start runs. The first version's starts ran without the dock, because a config without dock keys reads as one from before the dock. They also ran as scripted captures: measure-perf.ps1 put its variables back as empty strings, and Wisp's test hooks count an empty variable as set. I found both while writing -Sweep, the next pull request.

  • A real slowdown: with a 2 ms sleep added to Launcher::paint on the branch, it flagged paint in every launcher scenario (for example 0.87 → 3.09 ms) and what contains it, such as key_to_content (1.05 → 3.45 ms) and hotkey_to_content (3.14 → 5.37 ms).

  • The flag rule came out of those runs. "The ranges don't overlap" alone flagged a few metrics on identical code, since with three rounds that happens for about one metric in ten. So a change also has to be larger than 10%, 0.1 ms, and the spread within either build. Idle CPU, measured over about 2 s, needs 5 points.

  • cargo fmt --all --check, both clippy runs and cargo test --workspace pass.

Performance

Not affected: the two spans exist only in perf-trace builds, and wisp.exe is the same size (2,245 KB).

Not tested

  • A machine with only one screen, and Windows 10.
  • Starting it while a Wisp Nightly is running. It should be quit and started again like a stable one.
  • UI thread free shows up in the comparison only once main has the start span, that is after this is merged.
  • Decisions for you:
    • Each tree gets its own target folder (target\bench\target for main). In a shared one, cargo copies a binary to target\release only when it rebuilds it, so the other tree's binary stayed there. That cost me a wrong first comparison. The first run therefore builds main from scratch, a few minutes.
    • The idle check needs a fairly quiet desktop: with a browser, Teams and TeamViewer open, the total sat at about 10.4% and the script stopped. Closing them was enough.

Part of #44. Next: -Sweep, the CONTRIBUTING.md section and the template line.

  • I understand every line of this change and tested a build of it.
  • fmt, both clippy runs and the tests pass.
  • CHANGELOG.md has an entry under Unreleased, or this has nothing users notice.

🤖 Generated with Claude Code

scripts\bench.ps1 -Perf builds main in a worktree under target\bench\base
and the current checkout with nightly,perf-trace, then runs them in turn:
the launcher_demo scenarios from measure-perf.ps1 at 100% and 125%, and
starts of the nightly wisp.exe with hide_taskbar on. Both use their own
APPDATA. Before each run it waits for total CPU under 10% for 5 s. It
flags a metric only when the rounds don't overlap and the change is
larger than 10%, 0.1 and the spread within either build, and writes a
summary for the pull request.

perf-trace builds gain a start span around Launcher::start and a
dock_paint span, and measure-perf.ps1 takes an absolute demo path.

Part of SumirSeth#44.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RayTrunk

Copy link
Copy Markdown
Contributor Author

I pushed a second commit that fixes the start runs, and updated the description with a new run.

  • Capture mode. measure-perf.ps1 put its variables back as empty strings, because PowerShell passes $null on as "". Wisp's test hooks only check that a variable exists, so every start after the demo runs opened and closed the launcher every 500 ms. It now removes the variables that weren't set before. That also affects anyone who runs measure-perf.ps1 and then starts Wisp from the same PowerShell window.
  • No dock. The start config had no dock keys, which reads as a config from before the dock. It now turns the dock on, at the bottom. With the dock on, Wisp keeps its own window of the taskbar's class, so the taskbar check now counts only Explorer's.

With both fixed, against 38c1d4b: nothing outside the noise, the taskbar hidden in 9 of 9 starts per build, and last visible about 450 ms after the start.

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