Performance
Parallel Parsing
Section titled “Parallel Parsing”art-dupl --workers 8 # 8 concurrent workersart-dupl --workers 0 # Auto-detect CPU cores (default)The worker pool parallelizes AST parsing across files. For large codebases, explicit worker counts can improve throughput.
Incremental Analysis
Section titled “Incremental Analysis”art-dupl --incremental # Enable AST cachingart-dupl --incremental --cache-dir ~/.cache/art-dupl # Custom cache locationart-dupl --clear-cache # Clear cache before runningIncremental analysis caches parsed ASTs keyed by SHA-256 content hash. Re-runs only re-parse files that changed.
Cache Management
Section titled “Cache Management”art-dupl --max-cache-entries 5000 # Limit cache size (0 = unlimited)The cache uses LRU-style eviction (Prune) to stay within the entry limit.
Parallel Incremental
Section titled “Parallel Incremental”When --workers > 1 and --incremental is enabled, art-dupl uses:
- Worker pool for parallel file parsing
singleflight.Groupto deduplicate concurrent parses of byte-identical files (common in vendored/generated code)- Deep-cloned cache entries to prevent data races
Execution Timeout
Section titled “Execution Timeout”art-dupl --timeout 10m # Timeout after 10 minutesBy default, no timeout is applied. When set, all pipeline goroutines respect context cancellation.
Profiling
Section titled “Profiling”art-dupl --profile # Hidden flag — CPU and memory profilesProduces pprof-compatible CPU and memory profiles. Useful for diagnosing performance issues on large codebases.
Benchmarks
Section titled “Benchmarks”The suffix tree implementation has been benchmarked with property-based testing and race detection. Key optimizations:
- O(1) map-based transition lookup (from original O(n) linear search)
sync.Poolfor memory reuse in hash computation- XXH3 streaming hash (~20x faster than SHA-256)
- Statement-level tokenization (fingerprints entire statement subtrees)
Scaling to Large Codebases
Section titled “Scaling to Large Codebases”For codebases with 10,000+ files:
art-dupl --workers 0 --incremental -t 15 --only go --exclude-pattern "*_test.go"- Auto-detect workers for optimal parallelism
- Enable incremental caching for faster re-runs
- Raise threshold to reduce noise
- Exclude test files to focus on production code