Where the startup's gap goes
Traced on 28 November 2026. ttybench's startup gap, Lokyr's window on screen less its floor app's, was 76.6 ms for 1.6.0's notarized app and 80.9 ms for 1.5.0's in the startup of the releases' notarized DMGs, past its budget of 70 ms. These traces look for where Lokyr spends what the floor app does not. The script, run.sh, the analysis, analyze.py, and its tables are in startup-F5b-110; the traces' exports, some 30 MB each, stay outside the repository.
Method
- The copies: 1.6.0's app of its release's DMG, notarized and stapled, of the sessions' base config; and ttybench's floor app, the least AppKit app that shows a window. Each was started 20 times first.
- The traces: Instruments' App Launch template, five of each copy in turns, each copy launched by its executable, the same pause before each. Each trace's launch periods, dyld's activity, the time profile, the system calls and the threads' states were exported; the figures below are the means of five traces of each.
- The machine: an Apple M5 Pro on AC power, a 4K display at 60 Hz, the load average below 3 at the start; VS Code open, as both copies ran beside it alike. A first session of the same traces, without the system calls, found a gap of 59.6 ms, its
applicationDidFinishLaunching9 ms shorter.
Launched by its executable, rather than by open, Lokyr reaches the foreground 69.2 ms after the floor app: ttybench's gap of open holds Launch Services' share too.
Results
The main thread's time from dyld's launch to the app in the foreground, ms:
| Phase | Lokyr, running | Lokyr, blocked | The floor, running | The floor, blocked |
|---|---|---|---|---|
To applicationWillFinishLaunching | 21.0 | 42.0 | 39.0 | 31.0 |
| AppKit's scene | 19.8 | 23.6 | 23.3 | 17.9 |
applicationDidFinishLaunching to the foreground | 70.2 | 38.1 | 19.6 | 15.7 |
| In all | 111.0 | 103.7 | 81.9 | 64.6 |
The phases reach the foreground at 218.0 ms for Lokyr and 148.8 ms for the floor app. The floor app makes its window before applicationWillFinishLaunching, Lokyr in applicationDidFinishLaunching, so that the phases compare in their sums: Lokyr's main thread runs 29 ms more and waits 39 ms more.
- It waits longer in AppKit's own start, before its code has run: in
NSApplication's first call, which connects to the window server and asks the privacy service about the app, Lokyr's main thread waits 14.9 ms for the window server's display state and 14.8 ms for the privacy service, the floor app's 3.2 and 4.2 ms. Lokyr's thread that makes the GPU's device and the font, so that the first frame finds them ready, runs at the same time, and may ask the same services; the floor app has no such thread. - Its window's work: making the window takes 47 of its 150 samples of
applicationDidFinishLaunching, as the floor app's earlier, and 9.5 ms of the window server's answers. The pane's shell starts in 5 samples, and the first frame, its layout, glyphs and presentation, takes 19. - What waits for the first window but need not: the menu bar and the global keys, 7 samples, the themes' list, 3, and the watches of the config and the installed plugins, which wait for their thread to start them, 3.2 ms of the main thread's waits.
- After
applicationDidFinishLaunching, the run loop's first commit of the window's layers is AppKit's, 54 samples for Lokyr and 57 for the floor app: no gap there. - The antivirus woke the main thread a few times, 0.1 ms each: no part of the gap.
What follows
The cuts to try, measured each against 1.6.0 of ttybench's ab/1-start:
- The GPU and the font made after AppKit's first call, rather than beside it, so that the window server and the privacy service answer the main thread first: up to some 20 ms of its waits.
- The menu bar, the global keys, the themes' list and the watches after the first frame, on the run loop's next turn: some 5 to 8 ms.
- The watches started without waiting for their thread.
The cuts, measured: the first moved nothing and was reverted; the second, which also starts the watches after the first window, cut the gap by 10.9 ms.