fix: call graph correctness and performance improvements - #7
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses five correctness and performance bugs in the buildgraph call graph analyzer:
- funcKey collision fix —
funcKey()now usesfn.String()(which includes the receiver type) instead ofpkg.path + "." + fn.Name(), preventing name collisions between methods on different receiver types within the same package. - Exclude patterns enforcement —
applyExcludeFilters()is introduced to actually applycfg.Exclude.PatternsandSkipVendorafterBuildGraph(), removing matched functions from all graph structures. - Baseline version check —
LoadBaselinenow rejects baselines whoseVersiondoes not matchCurrentVersion, preventing silent incorrect diffs from stale snapshots. - O(N²) → O(1)
findSSAFunc— AssaIndexmap is built once inBuildGraph()sofindSSAFuncis a constant-time lookup. - O(N) → O(1)
isService— AserviceSetis precomputed inNewAnalyzer()for O(1) service membership checks. - Dead code removed:
SourceFileInfoandImpactIndextypes fromtypes.go.
Changes:
funcKeybug fix,ssaIndexfor O(1) lookups, andapplyExcludeFiltersimplementationserviceSetprecomputation inimpact.AnalyzerCurrentVersionconstant and version check inLoadBaseline
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/analyzer/analyzer.go |
Core changes: funcKey uses fn.String(), builds ssaIndex in BuildGraph(), adds applyExcludeFilters() and fileMatchesExclude() |
pkg/analyzer/analyzer_test.go |
Tests for funcKey collision fix and exclude patterns |
pkg/analyzer/ssa_index_test.go |
Tests for ssaIndex O(1) lookup (internal package test) |
pkg/impact/impact.go |
serviceSet precomputed in NewAnalyzer(), isService() simplified to O(1) map lookup |
pkg/impact/impact_test.go |
Tests for serviceSet precomputation |
pkg/storage/storage.go |
Adds CurrentVersion = "1.0" constant; LoadBaseline now validates version |
pkg/storage/storage_test.go |
Tests for version validation in LoadBaseline |
pkg/types/types.go |
Removes unused SourceFileInfo and ImpactIndex types |
testproject/core/collision/collision.go |
New test fixture with (*A).Run and (*B).Run for collision testing |
testproject/services/service-a/main.go |
Updated to call both collision methods to exercise the call graph |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes five issues found during evaluation:
All changes include tests. Full suite passes.