This document describes the new branch analysis optimization features added to GitFlow Analytics to handle large organizations with many repositories and branches efficiently.
The original "analyze all branches" approach caused performance issues on large organizations with:
- 95+ repositories
- Hundreds of branches per repository
- Analysis times exceeding practical limits
- Risk of hanging or running out of memory
Three configurable strategies are now available:
- Use case: Rapid testing, simple analysis
- Performance: Fastest
- Completeness: Basic (main branch only)
- Recommended for: Quick analysis, CI/CD pipelines
- Use case: Production analysis
- Performance: Balanced
- Completeness: High (captures meaningful development activity)
- Recommended for: Most use cases
- Use case: Comprehensive research
- Performance: Slowest
- Completeness: Maximum
- Recommended for: Research, detailed historical analysis
The smart strategy uses intelligent filtering:
-
Important branches (always included):
- Main/master branches
- Release branches (
release/*) - Hotfix branches (
hotfix/*)
-
Active branches:
- Branches with commits within the last 90 days (configurable)
- Limited to top 50 branches per repository (configurable)
-
Excluded branches:
- Automation branches (
dependabot/*,renovate/*) - Temporary branches (
*-backup,*-temp)
- Automation branches (
- Branch limit: Maximum branches analyzed per repository
- Commit limit: Maximum commits analyzed per branch
- Progress logging: Real-time feedback during analysis
Add branch analysis configuration to your YAML config:
analysis:
branch_analysis:
# Strategy: "smart", "main_only", or "all"
strategy: "smart"
# Smart analysis parameters
max_branches_per_repo: 50
active_days_threshold: 90
include_main_branches: true
# Branch patterns (regex)
always_include_patterns:
- "^(main|master|develop|dev)$"
- "^release/.*"
- "^hotfix/.*"
always_exclude_patterns:
- "^dependabot/.*"
- "^renovate/.*"
- ".*-backup$"
- ".*-temp$"
# Performance settings
enable_progress_logging: true
branch_commit_limit: 1000- Type: String
- Options:
"smart","main_only","all" - Default:
"smart" - Description: Branch analysis strategy
- Type: Integer
- Default: 50
- Description: Maximum branches to analyze per repository
- Type: Integer
- Default: 90
- Description: Days to consider a branch "active"
- Type: List of strings (regex patterns)
- Default: Main, release, hotfix patterns
- Description: Branch patterns to always include
- Type: List of strings (regex patterns)
- Default: Automation and temp branch patterns
- Description: Branch patterns to always exclude
- Type: Boolean
- Default: true
- Description: Show branch analysis progress
- Type: Integer
- Default: 1000
- Description: Maximum commits to analyze per branch
Based on testing with a large organization:
| Strategy | Branches Analyzed | Analysis Time | Completeness |
|---|---|---|---|
main_only |
1 per repo | ~30 seconds | ~60% |
smart |
~20 per repo | ~5 minutes | ~90% |
all |
100+ per repo | ~30+ minutes | ~95% |
- No action required: Configurations without
branch_analysissection will use smart defaults - Explicit control: Add
branch_analysissection for custom behavior
- Start with defaults: Smart strategy with default settings
- Adjust for scale: Reduce
max_branches_per_repofor very large organizations - Fine-tune patterns: Customize include/exclude patterns for your naming conventions
- Switch to
main_onlystrategy for testing - Reduce
max_branches_per_repo - Decrease
active_days_threshold
- Check
always_include_patterns - Increase
max_branches_per_repo - Reduce
active_days_threshold
- Review
always_exclude_patterns - Increase
active_days_threshold - Decrease
max_branches_per_repo
analysis:
branch_analysis:
strategy: "smart"
max_branches_per_repo: 25
active_days_threshold: 60
enable_progress_logging: trueanalysis:
branch_analysis:
strategy: "all"
max_branches_per_repo: 100
enable_progress_logging: falseanalysis:
branch_analysis:
strategy: "main_only"
enable_progress_logging: falseThe optimization is implemented in GitAnalyzer._get_commits_optimized() with:
- Strategy pattern for different analysis approaches
- Branch metadata collection and prioritization
- Regex-based filtering
- Progress reporting
- Graceful error handling
See the source code for complete implementation details.