Skip to content

perf(egui): start the boot before the window is built - #137

Merged
klNuno merged 7 commits into
mainfrom
perf/early-boot
Nov 22, 2026
Merged

klNuno merged 7 commits into
mainfrom
perf/early-boot

Conversation

@klNuno

@klNuno klNuno commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

Summary

Starts the boot job from main, before the event loop and the window are built, so the window no longer waits for a boot that started late.

What changes

  • The boot runs on the session thread started in main, right after begin_session (log rotation and panic hook stay first). AppModel::real takes it over as its own boot job; the legacy storage arrives through a channel instead of a join.
  • Window geometry is read before the boot thread starts, the legacy migration runs under the config write locks, the session thread migrates the legacy config before handing over the legacy read, so telemetry then maintenance start in their old order on a migrated config, and main joins the boot thread after the event loop ends, so a close never cuts a migration.
  • A presented mark after the first shown frame, compiled only in the startup bench build, so launch time can be measured as "window visible with content".

Measurements

Startup bench build, 14 interleaved runs per exe on Windows 11, hidden window, fresh copy of the app folders per run. Time to the first presented frame, median / p90:

Variant From process start After main
main d94a7f2 139.7 / 149.8 ms 42.0 / 49.1 ms
Early boot 131.3 / 138.7 ms 35.0 / 38.4 ms

About 90 to 100 ms pass before main (loader, executable size, Windows reputation checks on an unsigned exe), which code inside the app cannot reach.

Testing

  • cargo test -p accshift-egui early_boot: 7 passed, including the_legacy_read_is_handed_over_once_the_config_is_migrated (red before: the migration was still to come), the telemetry consent read after the migration, a saved window geometry kept through the migration, and a pre-1.0 release folder (legacy config, settings, custom theme) that migrates and boots the same through the early boot and the old boot job, with byte-identical files.
  • config::migrate::race_tests::a_write_racing_the_migration_is_kept: red before the lock fix (left: "", right: "racing-id"), green over 60 runs after.
  • build-safe node scripts/gates.mjs: exit 0, 2064 Rust tests.
  • reviewed by GPT-6.2 Sol: 4 rounds, approved.
  • Git range-diff verified all seven reviewed patches remained identical after rebasing onto main (16a69c1).
  • Not run: a visible window, the shipped fat-LTO executable, an update from an installed 2.0.0.

Related issue

None.

Tested on

  • Windows
  • macOS
  • Linux

Checklist

  • CI checks pass locally (see CONTRIBUTING.md)
  • Docs or wiki updated if the change is user-facing
  • No secrets, session tokens or captured account data in the diff

The migration read the split files, then saved the merge: a write landing in between, such as the telemetry id the app sets at launch while the boot thread migrates, was saved over. The read, merge, save and retire now run under the same locks as every other config write.
The boot migrates a pre-1.0 config into two files; reading the geometry between their writes opened the window at the default size. The session thread now starts after the geometry is read, and is joined before the process ends so a close never cuts a migration midway.
start_telemetry read the consent on the UI thread while the boot thread migrated a pre-1.0 config: a read that found neither split file, then the legacy file already retired, got the defaults. The session thread now starts the queue after the boot payload and before the model can report the first boot.
Starting telemetry after the boot payload let the maintenance take the config lock first: a consented profile without an anonymous id waited up to the lock timeout to write it, and the first frame with it. The session thread now migrates a pre-1.0 config right after the legacy web storage read and only then hands that read over, so the UI thread starts telemetry, then the maintenance, in their old order on a migrated config. The boot payload reports the early migration's outcome.
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3f6114af-ff50-40f1-8848-f2107d7ee25a
Commits

Reviewing files that changed from the base of the PR and between 16a69c1 and fa06bc3.

Files selected for processing: 13

  • crates/accshift-app/src/jobs.rs
  • crates/accshift-app/src/real.rs
  • crates/accshift-app/src/real/app.rs
  • crates/accshift-core/src/config/migrate.rs
  • crates/accshift-core/src/config/migrate/race_tests.rs
  • crates/accshift-egui/src/app/boot.rs
  • crates/accshift-egui/src/app/mod.rs
  • crates/accshift-egui/src/app/session.rs
  • crates/accshift-egui/src/app/tests.rs
  • crates/accshift-egui/src/app/tests/early_boot.rs
  • crates/accshift-egui/src/lib.rs
  • crates/accshift-egui/src/main.rs
  • crates/accshift-egui/src/soft/paint.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mtsu-patrol mtsu-patrol Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

@mtsu-patrol

mtsu-patrol Bot commented Nov 22, 2026

Copy link
Copy Markdown

This change starts loading the boot data on a background session thread before the window is created, so showing the first window no longer waits for work that could run earlier. It also moves the old single-file config migration earlier and holds the config locks while it runs, so later reads see the migrated result and a concurrent write is not lost.

No comments posted: the reviewers raised no finding.

Review details
  • Model: muse-spark-1.3-contributor
  • Compared commits: 16a69c1 to fa06bc3
  • Execution: tests could run in a disposable Linux sandbox
  • Files reviewed: 13 of 13
  • Duration: 5 min 24 s
Commands run (11)

Could not run tests, build, or app flow: sandbox has no Rust toolchain or C linker (cc/gcc absent, cargo: command not found), no sudo (no new privileges flag), and /tmp is wiped between commands. Installed cargo 1.100.0 to /work/.cargo (persists) but rustup warned no default linker (cc) found, so linking/running cargo test -p accshift-egui early_boot and config::migrate::race_tests was not possible within budget. No failures reproduced; no code comments filed.

passed · exit 0 · 0 s

cat .github/CONTRIBUTING.md 2>/dev/null | head -n 200; echo "---"; ls crates/*/; echo "---"; cat package.json 2>/dev/null | head -n 50; echo "---"; cat Cargo.toml | head -n 80

failed · exit 127 · 0 s

cargo test -p accshift-egui early_boot -- --nocapture 2>&1 | tail -n 60
/bin/bash: line 1: cargo: command not found

failed · exit 2 · 0 s

which rustc; ls /root/.cargo/bin/ 2>&1; ls ~/.cargo/bin/ 2>&1; find / -maxdepth 4 -name cargo -type f 2>/dev/null | head; echo PATH=$PATH; cat rust-toolchain* 2>/dev/null; ls /usr/local/cargo/bin/ 2>&1 | head
/bin/bash: line 1: which: command not found
ls: cannot access '/root/.cargo/bin/': No such file or directory
ls: cannot access '/work/.patrol-home/.cargo/bin/': No such file or directory
PATH=/usr/local/bin:/usr/bin:/bin
ls: cannot access '/usr/local/cargo/bin/': No such file or directory

passed · exit 0 · 0 s

ls /usr/local/bin/ 2>&1; echo "---"; ls /opt/ 2>&1; echo "---"; ls /work/ | head -n 30; echo "---"; cat /work/Cargo.toml | head -n 30; echo "---"; env | sort | head -n 30

passed · exit 0 · 0 s

cat /etc/os-release 2>&1; echo "---"; curl --version 2>&1 | head; echo "---"; wget --version 2>&1 | head; echo "---"; python3 --version 2>&1; echo "---"; df -h 2>&1 | head; echo "---"; free -m 2>&1 | head

passed · exit 0 · 0 s

uname -a; df -h /work /tmp 2>&1; ls -la /work/.patrol-home/ 2>&1 | head -n 20
export CARGO_HOME=/tmp/cargo RUSTUP_HOME=/tmp/rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh && ls -lh /tmp/rustup.sh && head -n 5 /tmp/rustup.sh

failed · exit 127 · 0 s

export CARGO_HOME=/tmp/cargo RUSTUP_HOME=/tmp/rustup
sh /tmp/rustup.sh -y --profile minimal --default-toolchain stable 2>&1 | tail -n 20
ls -lh /tmp/cargo/bin/ 2>&1 | head -n 20
/tmp/cargo/bin/cargo --version 2>&1; /tmp/cargo/bin/rustc --version 2>&1
sh: 0: cannot open /tmp/rustup.sh: No such file
ls: cannot access '/tmp/cargo/bin/': No such file or directory
/bin/bash: line 4: /tmp/cargo/bin/cargo: No such file or directory
/bin/bash: line 4: /tmp/cargo/bin/rustc: No such file or directory

passed · exit 0 · 0 s

echo "persist-test-work" > /work/.persist_test 2>&1; echo "persist-test-tmp" > /tmp/persist_test 2>&1; ls -lh /work/.persist_test /tmp/persist_test 2>&1; df -h /work /tmp 2>&1; ls /work/ | head -n 20

failed · exit 2 · 0 s

ls -lh /work/.persist_test /tmp/persist_test 2>&1; ls -lh /tmp/rustup.sh /tmp/cargo 2>&1; echo "---HOME---"; echo $HOME; ls -la $HOME 2>&1 | head -n 20; ls /work/.patrol-home 2>&1 | head
ls: cannot access '/tmp/persist_test': No such file or directory
-rw------- 1 1001 1001 18 Nov 22 18:05 /work/.persist_test
ls: cannot access '/tmp/rustup.sh': No such file or directory
ls: cannot access '/tmp/cargo': No such file or directory
---HOME---
/work/.patrol-home
ls: cannot access '/work/.patrol-home': No such file or directory
ls: cannot access '/work/.patrol-home': No such file or directory

passed · exit 0 · 8 s

mkdir -p "$HOME" /work/.cargo /work/.rustup
export CARGO_HOME=/work/.cargo RUSTUP_HOME=/work/.rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /work/rustup.sh && ls -lh /work/rustup.sh
sh /work/rustup.sh -y --profile minimal --default-toolchain stable 2>&1 | tail -n 30
/work/.cargo/bin/cargo --version 2>&1; /work/.cargo/bin/rustc --version 2>&1; ls /work/.cargo/bin/ 2>&1 | head

passed · exit 0 · 0 s

id 2>&1; echo "---"; ls /usr/bin/cc* /usr/bin/gcc* 2>&1; echo "---"; apt --version 2>&1 | head; echo "---"; sudo -n true 2>&1; echo "sudo-exit:$?"

@klNuno
klNuno merged commit 16fcdd6 into main Nov 22, 2026
9 checks passed
@klNuno
klNuno deleted the perf/early-boot branch November 22, 2026 18:15
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