Skip to content

Keep Linux PGSO startup code fast - #1517

Merged
fazxes merged 4 commits into
mainfrom
fazxes/pgso-linux-startup
Oct 30, 2026
Merged

fazxes merged 4 commits into
mainfrom
fazxes/pgso-linux-startup

Conversation

@fazxes

@fazxes fazxes commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1502.

Profile use compiles the functions it judges cold for size. On Linux that makes short commands slower than the control: fx help failed the startup gate in every Linux run without this change.

This change keeps the startup path fast:

  • Training keeps a profile for each of the five direct startup scenarios (direct-help, direct-version, direct-status, direct-doctor, direct-sessions).
  • Before profile use, a first pass applies the production profile, and ir_size.py minsize-functions reads which startup functions came out minsize. Their records are removed from the production profile. Startup functions that stay hot, those the build inlines away, and those any heavy benchmark runs keep their records. The benchmarks build from the production profile, so dropping the allocator or Io.Mutex records slowed ui-activity by about 6 points.
  • Every startup function is marked nooutline (ir_size.py no-outline) before outlining, so neither the IR outliner nor llc's machine outliner moves its code into helpers far from the rest of the startup code. Those helpers cost fx --version extra page faults.
  • The candidate link places the startup functions first, in the order they first run.

macOS has no startup scenarios, so its build is unchanged. Distributed builds don't carry the startup profiles, so they reject Linux.

Testing

  • python3 -m unittest discover -s scripts/pgso/tests -t . passes all 238 tests. New coverage: minsize-functions and no-outline against real LLVM, record removal, the two-pass exemption with faked tools, startup profiles kept during training, startup-first link order, and the distributed rejection.
  • On an arm64 Linux machine, python3 -m scripts.pgso all --target aarch64-linux:
    • With the startup exemption and nooutline, training, profile use, the behavior corpus, and the startup gate passed. help was 34% faster than the control and --version 6% slower, within the 10% limit. ui-activity failed at +11.9%.
    • With this commit's narrower exemption, training and profile use passed. The behavior corpus then hit timeouts in tui-resume.test.ts while the host was heavily loaded. The same tests pass three of three times against both the control and this candidate on recheck.
  • The narrower exemption's gates on a rebuild from the same inputs, run alternately on local disk:
    • The startup gate passed all five commands in 6 of 6 rounds. Median p50: help −7.0%, --version +1.1%, status −7.9%, doctor −8.9%, sessions −6.8%.
    • ui-activity ran +5.3% to +6.7% at p50, against +13.6% to +17.8% with the broader exemption.
  • A clean end-to-end run of every gate still needs a quiet Linux arm64 machine. The Linux CI workflow will provide it.

Profile use compiles the functions it judges cold for size. On Linux that
makes short commands such as fx help slower than the control, past the
startup gate.

Training now keeps a profile for each of the five direct startup
scenarios. Before profile use, a first pass applies the production
profile and reads which startup functions came out minsize. Their
records are removed from the production profile, except for functions a
heavy benchmark runs, because the benchmarks build from the same
profile. Every startup function is marked nooutline, so neither outliner
moves its code into helpers far from the rest of the startup code. The
candidate link places the startup functions first, in the order they
first run.

macOS has no startup scenarios, so its build is unchanged. Distributed
builds don't carry the startup profiles, so they reject Linux.
@fazxes fazxes added the type: maintenance Changes internal tooling, dependencies, CI, or implementation structure label Oct 29, 2026
… fazxes/pgso-linux-startup

# Conflicts:
#	scripts/pgso/ir_size.py
… fazxes/pgso-linux-startup

# Conflicts:
#	scripts/pgso/ir_size.py
@fazxes
fazxes changed the base branch from fazxes/pgso-linux-platform to main October 30, 2026 06:38
@fazxes
fazxes marked this pull request as ready for review October 30, 2026 06:39
@fazxes
fazxes merged commit f79ed55 into main Oct 30, 2026
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Changes internal tooling, dependencies, CI, or implementation structure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant