Skip to content

bench/run: time the installed build, and cold starts (ALI-2106) - #16

Merged
michaelaguiar merged 3 commits into
mainfrom
aliasbot/ali-2106-bench
Nov 27, 2026
Merged

michaelaguiar merged 3 commits into
mainfrom
aliasbot/ali-2106-bench

Conversation

@michaelaguiar

Copy link
Copy Markdown
Member

Part of ALI-2106.

bench/run gets two options, for the measurements still open on the ticket:

  • --bin PATH times that Alias Calc instead of building this checkout. For example, bench/run --bin /usr/bin/alias-calc times the installed package.
  • --cold drops the page cache (echo 3 > /proc/sys/vm/drop_caches, after a sync) before every launch, so each start reads its binary and libraries from disk. It asks for sudo once, up front. Each drop then runs sudo -n, so the runs never stop at a prompt.

The README lists both.

Results so far

Installed alias-calc 0.1.2-1 against omacalc (e43fd0a), warm, median of 10, on the desktop:

Alias Calc (installed) omacalc
Time until the window opened 2.8 ms 144.8 ms
PSS 2.5 MiB 70.7 MiB
RSS 5.5 MiB 155.7 MiB
Threads 1 7
Idle wakeups/s 0.8 3.5

GNOME Calculator isn't installed any more. Its row stays the 2026-11-26 run, in the project's status update.

Binary size

panic = "abort" is already set, and SCTK already builds with only xkbcommon. That leaves opt-level. Each build was timed with bench/run --bin (median of 10) and with the full-frame budget test (cargo test --release -- --ignored budget_full_frame):

opt-level Binary Time to open Full frame at 640×960
3 (now) 1,060,728 B 2.7 ms 0.53 ms
2 1,027,032 B 2.8 ms —
s 911,704 B (−14%) 2.6 ms 0.58 ms
z 887,064 B (−16%) 3.2 ms 1.13 ms, over the 1 ms budget

z breaks the frame budget. s saves 149 KB and opens just as fast, but each redraw is about 10% slower. That's a trade-off for Mike, so this PR leaves the profile as it is.

Checks

  • bash -n bench/run passes, and calcbench.py compiles.
  • --bin produced the tables above.
  • --cold isn't run yet: it needs sudo.

…e (ALI-2106)

--bin PATH times that Alias Calc (the installed /usr/bin/alias-calc, say)
instead of building this checkout. --cold drops the page cache before every
launch, so each start reads its binary and libraries from disk; it asks for
sudo once up front and then drops with sudo -n.
…yped, cold runs say so

From review:
- A failed sudo -n tee (credentials gone, or not allowed) raised a
  traceback; it now ends that app's run with a line saying --cold needs
  sudo.
- --bin was resolved after cd-ing to the repo root, a bare name wasn't
  looked up on PATH, and a directory passed -x. It's now resolved where
  it was typed (or on PATH) and must be an executable file.
- A cold run's table says it's from a cold page cache, and a cold start
  gets 30 s to map, not 10.
@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 1 (head e4d3d2b)

Fixed in the latest commit:

  • A failed cache drop printed a traceback (P2). If sudo -n tee fails, because the credentials are gone or tee isn't allowed, that app's run now ends with: "couldn't drop the page cache (… exited 1); --cold needs sudo, asked for first by bench/run". Checked with no cached sudo.
  • --bin paths (P3):
    • A relative path is now resolved from where it was typed, before the cd to the repo root.
    • A bare name is looked up on PATH.
    • A directory is rejected, because the path must be an executable file.
    • Checked with nope, /etc and ../nope.
  • Cold timeout (P3): under --cold a start gets 30 s to map, not 10.
  • Cold results weren't labelled (P3): each row records cold, and the table's footer says "from a cold page cache".

Checked and holds:

  • both forms of each option;
  • "${cold[@]}" under set -u;
  • the cache drop happens before the timer starts;
  • --cold applies to every app;
  • sudo stays valid through a run, because each sudo -n renews it.

@michaelaguiar

Copy link
Copy Markdown
Member Author

Review round 2 (head 366d4bf; narrow, on that commit)

No P1 or P2 findings.

Checked and holds:

  • global MAP_TIMEOUT comes before any use in main(), and wait_for_window reads it at call time.
  • A bad --bin exits 2 with a message.
  • The default build still runs in the repo root.
  • $root is quoted everywhere.
  • A cold row's footer says so.

Fixed in eb61108 (P3):

  • The error always blamed sudo. It now blames sudo only when sudo was the command that failed. A failed sync or tee gets just the command and its exit code.
  • "Page cache" undersold what --cold drops. The README now says --cold writes 3, so the page, dentry and inode caches are emptied. A library another running app has mapped stays in memory, so a cold start is as cold as the machine allows, not a first boot.

Declined (P3):

  • "${cold[@]}" breaks on bash older than 4.4. The harness runs on aliasOS, which has bash 5.
  • realpath on a symlinked --bin. /usr/bin/alias-calc is a plain file, and Alias Calc doesn't find its resources from its own path.

@michaelaguiar
michaelaguiar marked this pull request as ready for review November 27, 2026 17:46
@michaelaguiar
michaelaguiar merged commit e28c1c2 into main Nov 27, 2026
1 check passed
@michaelaguiar
michaelaguiar deleted the aliasbot/ali-2106-bench branch November 27, 2026 17:50
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