Skip to content

cl: stabilize generic local ABI names across cache loads - #2299

Merged
xushiwei merged 3 commits into
xgo-dev:mainfrom
cpunion:codex/fix-generic-local-cache-2297
Aug 20, 2026
Merged

cl: stabilize generic local ABI names across cache loads#2299
xushiwei merged 3 commits into
xgo-dev:mainfrom
cpunion:codex/fix-generic-local-cache-2297

Conversation

@cpunion

@cpunion cpunion commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • keep synthesized generic-local TypeName objects positionless because their generated names already encode the complete local and generic identity
  • prevent ABI naming from appending a loader-relative .p<token.Pos> suffix that differs between cached archives and a later synthetic root module
  • add a cross-process cold/hot package-cache regression and assert the frontend position invariant

This preserves the existing position fallback for genuine detached local-scope objects while making generic-local cache hits link reliably.

Fixes #2297

Testing

  • go test ./cl -run "^TestGenericLocalTypePatchHelpers$" -count=1
  • go test ./cl -run "^TestRunAndTestFromTestgo$" -count=1
  • go test -tags=dev ./internal/build -run "^TestGenericLocalTypeColdAndHotPackageCache$" -count=1
  • go test ./ssa/abi -count=1
  • issue reproducer: forced cold llgo test -a -p=1 ... followed by the immediate cache-hit llgo test -p=1 ...; both pass

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review summary

The fix is correct and well-targeted. Replacing t.Obj().Pos() with token.NoPos for the detached TypeName in patchLocalGenericNamed (cl/compile.go) removes the source of cross-process non-determinism: scopeIndices in ssa/abi/abi.go only appends the loader-relative .p<pos> suffix when pos.IsValid(), so token.NoPos drops that varying suffix while type identity is fully preserved by the type-arg-encoded localNamedName. The explanatory comment is accurate, and the subprocess-based cold/hot cache test is the right shape — an in-process test could not reproduce #2297 since the offending token.Pos comes from a per-process FileSet.

Security, documentation-accuracy, and performance passes surfaced no issues (token.NoPos is in fact a net reduction in per-type work). One minor, optional test-robustness finding is left inline.

No blocking issues.

Comment thread internal/build/build_test.go Outdated
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

af9eb545153f | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Build vs base Run vs base
Linux cprintf 19288 B 0 B / +0.0% 334.317 ms -2.748 ms / -0.8% (better) 1.361 ms -19.95 us / -1.4% (better)
Linux fmtprintf 1859320 B 0 B / +0.0% 2.551 s -37.23 ms / -1.4% (better) 3.755 ms +191.8 us / +5.4% (worse)
Linux println 68776 B 0 B / +0.0% 327.389 ms -7.706 ms / -2.3% (better) 1.649 ms -72.58 us / -4.2% (better)
macOS cprintf 84672 B 0 B / +0.0% 396.257 ms +23.68 ms / +6.4% (worse) 3.110 ms +568 us / +22.3% (worse)
macOS fmtprintf 1892448 B 0 B / +0.0% 3.177 s +950.7 ms / +42.7% (worse) 14.666 ms +2.207 ms / +17.7% (worse)
macOS println 121360 B 0 B / +0.0% 526.840 ms +180.8 ms / +52.3% (worse) 4.700 ms +867.3 us / +22.6% (worse)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 12.290 ns/op -0.11 ns/op / -0.9% (better)
Linux BenchmarkMergeCompilerFlags 146.700 ns/op +3.2 ns/op / +2.2% (worse)
Linux BenchmarkMergeLinkerFlags 96.120 ns/op +2.6 ns/op / +2.8% (worse)
Linux BenchmarkChannelBuffered 36.300 ns/op +0.03 ns/op / +0.1% (worse)
Linux BenchmarkChannelHandoff 24537 ns/op -954 ns/op / -3.7% (better)
Linux BenchmarkDefer 44.890 ns/op +0.1 ns/op / +0.2% (worse)
Linux BenchmarkDirectCall 1.759 ns/op +0.001 ns/op / +0.1% (worse)
Linux BenchmarkGlobalRead 1.760 ns/op 0 ns/op / +0.0%
Linux BenchmarkGlobalWrite 2.811 ns/op 0 ns/op / +0.0%
Linux BenchmarkGoroutine 30267 ns/op -459 ns/op / -1.5% (better)
Linux BenchmarkInterfaceCall 9.045 ns/op -0.098 ns/op / -1.1% (better)
Linux BenchmarkRuntimeGetG 2.111 ns/op -0.001 ns/op / -0.04735% (better)
macOS BenchmarkLookupPCRandom 13.260 ns/op +1.62 ns/op / +13.9% (worse)
macOS BenchmarkMergeCompilerFlags 187.600 ns/op +81.5 ns/op / +76.8% (worse)
macOS BenchmarkMergeLinkerFlags 103.400 ns/op +35.39 ns/op / +52.0% (worse)
macOS BenchmarkChannelBuffered 23.980 ns/op +2.49 ns/op / +11.6% (worse)
macOS BenchmarkChannelHandoff 7631 ns/op -1424 ns/op / -15.7% (better)
macOS BenchmarkDefer 33.380 ns/op +1.27 ns/op / +4.0% (worse)
macOS BenchmarkDirectCall 1.265 ns/op +0.199 ns/op / +18.7% (worse)
macOS BenchmarkGlobalRead 1.257 ns/op +0.2673 ns/op / +27.0% (worse)
macOS BenchmarkGlobalWrite 1.517 ns/op +0.5193 ns/op / +52.0% (worse)
macOS BenchmarkGoroutine 53491 ns/op +27998 ns/op / +109.8% (worse)
macOS BenchmarkInterfaceCall 5.589 ns/op +1.162 ns/op / +26.2% (worse)
macOS BenchmarkRuntimeGetG 2.960 ns/op +0.576 ns/op / +24.2% (worse)

Compared with cf91afb98fca measured in the same runner job.

@cpunion
cpunion force-pushed the codex/fix-generic-local-cache-2297 branch from 2bcdbda to 1bcb70b Compare August 19, 2026 14:32
@xushiwei
xushiwei merged commit bed9d7c into xgo-dev:main Aug 20, 2026
88 of 112 checks passed
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.

build cache: cache hits drop generic local ABI type definitions

2 participants