Skip to content

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

Open
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/fix-generic-local-cache-2297
Open

cl: stabilize generic local ABI names across cache loads#2299
cpunion wants to merge 2 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

2bcdbdafd654 | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Build vs base Run vs base
Linux cprintf 18656 B +0.0% 335.054 ms +11.4% (worse) 1.410 ms +2.8% (worse)
Linux fmtprintf 1881664 B +0.0% 3.216 s +11.5% (worse) 4.344 ms +2.1% (worse)
Linux println 68512 B +0.0% 317.873 ms +8.6% (worse) 1.731 ms +1.8% (worse)
macOS cprintf 84672 B +0.0% 374.691 ms -40.6% (better) 3.151 ms -66.6% (better)
macOS fmtprintf 1889248 B +0.0% 3.385 s -35.5% (better) 13.616 ms -29.1% (better)
macOS println 121216 B +0.0% 423.927 ms -12.3% (better) 4.110 ms -53.3% (better)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 12.270 ns/op -0.5% (better)
Linux BenchmarkMergeCompilerFlags 148.400 ns/op +3.2% (worse)
Linux BenchmarkMergeLinkerFlags 96.430 ns/op +2.4% (worse)
Linux BenchmarkChannelBuffered 36.310 ns/op -0.0% (better)
Linux BenchmarkChannelHandoff 25190 ns/op -0.9% (better)
Linux BenchmarkDefer 48.230 ns/op -1.4% (better)
Linux BenchmarkDirectCall 1.759 ns/op +0.1% (worse)
Linux BenchmarkGlobalRead 1.773 ns/op +0.9% (worse)
Linux BenchmarkGlobalWrite 2.807 ns/op +0.1% (worse)
Linux BenchmarkGoroutine 36084 ns/op +17.5% (worse)
Linux BenchmarkInterfaceCall 8.454 ns/op +0.1% (worse)
Linux BenchmarkRuntimeGetG 2.462 ns/op +0.0%
macOS BenchmarkLookupPCRandom 12.810 ns/op +0.9% (worse)
macOS BenchmarkMergeCompilerFlags 114.800 ns/op -21.9% (better)
macOS BenchmarkMergeLinkerFlags 82.540 ns/op -7.9% (better)
macOS BenchmarkChannelBuffered 27.770 ns/op -34.1% (better)
macOS BenchmarkChannelHandoff 7895 ns/op -30.3% (better)
macOS BenchmarkDefer 41.430 ns/op -21.8% (better)
macOS BenchmarkDirectCall 1.057 ns/op -24.9% (better)
macOS BenchmarkGlobalRead 1.123 ns/op -37.4% (better)
macOS BenchmarkGlobalWrite 1.125 ns/op -55.1% (better)
macOS BenchmarkGoroutine 46861 ns/op -14.2% (better)
macOS BenchmarkInterfaceCall 6.085 ns/op -14.1% (better)
macOS BenchmarkRuntimeGetG 2.420 ns/op -29.9% (better)

Compared with c454c0e65b71 measured in the same runner job.

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

1 participant