perf(go): Parallelize call graph building and add progress tracking (PR-18) - #541
Merged
Merged
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
This was referenced Feb 16, 2026
Owner
Author
This was referenced Feb 16, 2026
Merged
Owner
Author
Merge activity
|
shivasurya
changed the base branch from
shiva/golang-pr17-method-resolution
to
graphite-base/541
February 16, 2026 21:15
…PR-18)
Major performance optimizations and UX improvements for Go call graph construction:
## Performance Optimizations
1. **Parallelize Pass 2a (Return Type Extraction)**
- Sequential: Processes 1181 functions one-by-one
- Parallel: 8-worker pool with job queue
- Speedup: ~5-8x faster on large codebases
- Thread-safe: typeEngine.AddReturnType() uses mutexes
2. **Optimize Pass 3 (Call Site Extraction)**
- Before: O(n × m) nested loops for FQN lookup (n=calls, m=functions)
- After: O(n) with reverse map (node ID → FQN) built once
- Impact: ~100-1000x faster on large codebases (3640+ functions)
3. **Add Progress Tracking to All Passes**
- Pass 1: Node scanning progress (every 5000 nodes)
- Pass 2a: Return type extraction (every 500 functions)
- Pass 2b: Variable assignments (every 50 files)
- Pass 3: Call site scanning (every 5000 nodes)
- Pass 4: Call resolution with resolution rate (every 500 sites)
## UX Improvements
1. **Go Version Detection**
- Extracts "go 1.21" directive from go.mod
- Displays: "Detected Go version: 1.21"
- Added GoModuleRegistry.GoVersion field
2. **Improved Logging**
- Shows Go module path: "Go module: github.com/user/project"
- Pass-level status messages
- Real-time progress bars (Python-style)
- Resolution rate tracking in Pass 4
## Example Output
```
Building Go call graph...
Pass 1: Indexing functions...
Scanning nodes: 77126/77126 (100.0%) - 3640 functions found
Pass 2a: Extracting return types...
Return types: 1181/1181 (100.0%)
Pass 2b: Extracting variable assignments (308 files)...
Variable assignments: 308/308 (100.0%)
Pass 3: Extracting call sites...
Scanning for calls: 77126/77126 (100.0%) - 6820 calls found
Pass 4: Resolving call targets...
Call targets: 6820/6820 (100.0%) - 85.2% resolved
```
## Files Changed
- cmd/serve.go: Add Go version logging
- graph/callgraph/builder/go_builder.go: Progress tracking, Pass 3 optimization
- graph/callgraph/extraction/go_return_types.go: Parallelize with worker pool
- graph/callgraph/resolution/go_imports.go: Extract Go version from go.mod
- graph/callgraph/core/types.go: Add GoVersion field to GoModuleRegistry
- graph/callgraph/resolution/go_imports_test.go: Fix test for new parseGoMod signature
## Testing
- All tests passing
- Verified on test fixtures (100% resolution)
- Tested on full sast-engine codebase (3640 functions, 77k nodes)
- No performance degradation in results quality
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
shivasurya
force-pushed
the
shiva/golang-pr18-performance
branch
from
February 16, 2026 21:17
545c0b0 to
e10906d
Compare
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #541 +/- ##
==========================================
- Coverage 82.94% 82.92% -0.02%
==========================================
Files 139 139
Lines 16912 17003 +91
==========================================
+ Hits 14027 14100 +73
- Misses 2355 2368 +13
- Partials 530 535 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Major performance optimizations and UX improvements for Go call graph construction. This PR adds parallel processing, progress bars, and Go version detection to dramatically improve build speed and user experience.
Performance Improvements
🚀 Parallelization
⚡ Algorithmic Optimization
📊 Real-World Results
Tested on full sast-engine codebase:
UX Improvements
📈 Progress Bars (Python-style)
Added real-time progress tracking for all passes:
🔍 Go Version Detection
go.mod(e.g.,go 1.21)Detected Go version: 1.21🎯 Enhanced Logging
Go module: github.com/user/projectTechnical Changes
Files Modified
Key Algorithms
Parallel Return Type Extraction:
O(n) Call Site Resolution:
Testing
Coverage
Test Results
Impact
Before PR-18
After PR-18
Dependencies
Stacks on: PR-17 (shiva/golang-pr17-method-resolution)
Related Issues
Addresses performance concerns when indexing large Go codebases.
🤖 Generated with Claude Code