Skip to content

Improve build performance with simple hot-path optimizations#1856

Closed
cpunion wants to merge 19 commits into
xgo-dev:mainfrom
cpunion:improve/build-perf-simple
Closed

Improve build performance with simple hot-path optimizations#1856
cpunion wants to merge 19 commits into
xgo-dev:mainfrom
cpunion:improve/build-perf-simple

Conversation

@cpunion

@cpunion cpunion commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

This extracts the lower-risk, source-only build performance changes from the larger build-perf branch.

Included changes focus on simple hot-path reductions:

  • cache repeated tool/sysroot/LLVM setup work
  • make SSA sanity checking opt-in for normal builds
  • reduce package load/type-check allocations
  • skip parser object resolution for build loads
  • avoid unused type scopes
  • use upstream parallel go/ssa.Program.Build
  • skip redundant SSA program builds
  • avoid MethodSet construction in SSA order fixup
  • reduce embed/type-conversion allocations
  • avoid external go list -json for Plan9 asm discovery while preserving internal/chacha8rand stub behavior
  • remove unused reflect/method metadata maps
  • pre-size predictable linkMainPkg scratch containers
  • cache parsed runtime Go minor version

Intentionally excluded from this PR:

  • async LLVM/object emission changes
  • stdin-based IR compilation
  • build-cache publication/archive scheduling changes
  • manifest writer/format optimizations
  • CI workflow fan-out/sharding changes

The branch does not modify cache archive/manifest generation or cache publication ordering. The only cache-related behavior kept is adding LLGO_SSA_SANITY to build env inputs when sanity checking is explicitly enabled, so cached artifacts distinguish sanity mode from normal builds.

Local timing

Representative paired local runs on darwin/arm64, Go 1.24.11:

go test ./internal/build -run '^TestExtest$' -count=3

  • main: 35.621s reported, 36.82s wall
  • this PR: 32.356s / 32.359s reported, 32.88s / 32.91s wall

Approx wall improvement: ~10.6%.

go test ./internal/build -count=1

  • main: 48.644s reported, 49.17s wall
  • this PR: 43.259s / 44.594s reported, 43.78s / 45.19s wall

Approx wall improvement: ~8-11%.

Validation

  • go test ./internal/packages ./internal/build ./internal/crosscompile ./internal/env ./internal/goembed ./ssa ./xtool/env/llvm -count=1
  • go test ./internal/build -run '^TestExtest$' -count=3
  • go test ./test/std/math/rand/v2 ./test/std/reflect -count=1
  • go test ./internal/build -run '^TestPkgSFilesChacha8UsesStubBeforeOtherFiles$|^TestParallelObjectEmit|MainModule|Abi|Reflect' -count=1
  • go build -a -tags=dev -o /tmp/llgo-build-perf-simple ./cmd/llgo

cpunion added 19 commits May 11, 2026 17:50
(cherry picked from commit 4907ad1)
(cherry picked from commit 54380c6)
(cherry picked from commit 9a88c0c)
(cherry picked from commit 0c14164)
(cherry picked from commit e87e5b3)
(cherry picked from commit 4d93cca)
(cherry picked from commit 746ac58)
(cherry picked from commit e2b0386)
Result: {"status":"keep","warm_internal_build_wall":29.279,"go_reported_s":28.415,"baseline_s":31.157,"patched_s":29.279,"delta_s":-1.878,"base_go_reported_s":30.589,"patched_go_reported_s":28.415,"wall_s":29.279}
(cherry picked from commit aebd4c2)
Result: {"status":"keep","warm_internal_build_wall":29.256,"go_reported_s":28.699,"baseline_s":31.312,"patched_s":29.256,"delta_s":-2.056,"base_go_reported_s":30.727,"patched_go_reported_s":28.699,"wall_s":29.256}
(cherry picked from commit f857424)
Result: {"status":"keep","warm_internal_build_wall":29.456,"go_reported_s":28.89,"baseline_s":30.32,"patched_s":29.456,"delta_s":-0.864,"base_go_reported_s":29.756,"patched_go_reported_s":28.89,"wall_s":29.456}
(cherry picked from commit 04e9b01)
Result: {"status":"keep","warm_internal_build_wall":28.574,"go_reported_s":27.996,"baseline_s":30.326,"patched_s":28.574,"delta_s":-1.752,"base_go_reported_s":29.768,"patched_go_reported_s":27.996,"wall_s":28.574}
(cherry picked from commit fd5680f)
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.04673% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ssa/type_cvt.go 80.76% 7 Missing and 3 partials ⚠️
internal/goembed/goembed.go 66.66% 2 Missing and 2 partials ⚠️
internal/crosscompile/crosscompile.go 85.71% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cpunion cpunion marked this pull request as draft May 11, 2026 11:41
@cpunion

cpunion commented May 11, 2026

Copy link
Copy Markdown
Collaborator Author

Closing per decision: CI/build-time benefit is not strong or stable enough to proceed with this build-performance PR.

@cpunion cpunion closed this May 11, 2026
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.

2 participants