perf: replace source importer with gcexportdata for ~1000x faster type resolution#58
Merged
Merged
Conversation
…aster type resolution
The type resolver previously used importer.ForCompiler("source") which
recursively parses all transitive dependencies from .go source files.
For large dependency graphs (e.g., Cosmos SDK), this took 15+ minutes.
Now uses gcexportdata to read pre-compiled type data from Go's build
cache via `go list -export -deps`. Benchmarks show:
- go list -export -deps: ~42ms (finds all dependency export files)
- gcexportdata.Read() for all deps: ~23ms
- Cached (second call, same process): 750ns
The gcExportImporter also caches `go list` results across multiple
NewTypeResolver calls, eliminating the duplicate invocation between
Phase 0 (semantic validation) and Step 2.1 (error propagation).
Falls back to source importer if `go list -export` fails.
Addresses #38
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review feedback from 6-model team review: - Remove GOFLAGS= override that broke vendor mode projects - Capture go list stderr for better error diagnostics - File descriptor leak was a false positive (os.Open error IS checked before defer f.Close() is registered) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📊 Performance Benchmark ReportPerformance Benchmark ReportAnalyzed 190 benchmark(s)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
importer.ForCompiler("source")inTypeResolverwith a fastgcexportdata-based importer backed bygo list -export -depsgoListCacheto eliminate duplicatego listinvocations between pipeline phases (Phase 0 validation + Step 2.1 error propagation)go list -exportfailsBenchmarks
go build)Test plan
gc_export_importer_test.go(stdlib import, caching, transitive deps, missing package, cache ordering, TypeResolver integration)go test ./...passes with zero regressionsdingo gotranspiles correctly withDINGO_PROFILE=1showing fast pathAddresses #38
🤖 Generated with Claude Code