Performance
Performance considerations and optimization guidelines for govman.
Performance Goals
- Install time: < 30 seconds for typical Go version (100-500 MB)
- Switch time: < 100ms for version switching
- List remote: < 1 second (with caching)
- List installed: < 100ms
- Startup time: < 50ms for simple commands
Download Performance
Parallel Downloads
Configuration:
download:
parallel: true
max_connections: 4
Benchmarks (downloading Go 1.25.1, ~150 MB):
| Connections | Time | Speed |
|---|---|---|
| 1 | 45s | 3.3 MB/s |
| 2 | 28s | 5.4 MB/s |
| 4 | 20s | 7.5 MB/s |
| 8 | 18s | 8.3 MB/s |
Recommendation: Use 4 connections for best balance.
Download Caching
Cache Hit Performance:
- No download time
- Only extraction time (~3-5 seconds)
- 10x faster than fresh download
Cache Strategy:
- Files cached in
~/.govman/cache/ - Persistent across installations
- Verified by expected file size
Resume Support
Incomplete downloads resume from last byte:
First attempt: [████████░░░░░░░░] 45% - Network failure
Resume attempt: [████████████████] 100% - Continues from 45%
Benefits:
- No wasted bandwidth
- Reliable on unstable connections
- Automatic (no user intervention)
API Performance
Release Data Caching
Cache Duration: 10 minutes (configurable)
Cache Hit Scenarios:
govman list --remotecalled multiple timesgovman installaftergovman list- Any command needing version data within cache window
Benchmark:
First call: govman list --remote → 800ms (API call)
Second call: govman list --remote → 10ms (cache hit)
API Optimization
- Single request: Fetch all versions at once
- JSON parsing: Efficient unmarshaling
- In-memory cache: No disk I/O for cached data
Version Switching Performance
Symlink Updates
Operation Time: < 10ms
time govman use 1.25.1
# real 0m0.045s
What happens:
- Validate version installed (~1ms)
- Update configuration (~5ms)
- Create/update symlink (~2ms)
- Generate PATH command (~1ms)
Atomic: Single system call, no locks needed
Shell Integration Overhead
Auto-switch trigger time: < 50ms
# With auto-switch enabled
time cd /project-with-govman-version
# Overhead: ~40ms for version check and switch
Optimizations:
- Only triggers on directory change
- Caches current version check
- No-op if already on correct version
Memory Usage
Typical Memory Footprint
govman install: ~15-30 MB RAM
govman list: ~10-20 MB RAM
govman use: ~8-15 MB RAM
Low memory usage because:
- Streaming downloads (not loaded into memory)
- Minimal in-memory caching
- Efficient data structures
Large Operations
Installing multiple versions sequentially:
govman install 1.25.1 1.24.0 1.23.5
# Peak memory: ~30 MB (each install independent)
Disk I/O
Extraction Performance
.tar.gz extraction (Linux/macOS):
100 MB archive → ~3-4 seconds extraction
.zip extraction (Windows):
100 MB archive → ~4-5 seconds extraction
Optimizations:
- Stream-based extraction (no temp decompression)
- Preserve file permissions from archive
- Efficient buffering
Filesystem Cache
Read Performance:
- Config file: Read once per command
- Version list: Stat calls on directory
Write Performance:
- Config updates: Single atomic write
- Symlink: Single syscall
Network Performance
HTTP Client Configuration
client := &http.Client{
Timeout: 300 * time.Second, // Configurable
Transport: &http.Transport{
MaxIdleConns: 10,
IdleConnTimeout: 90 * time.Second,
DisableKeepAlives: false,
DisableCompression: false,
},
}
Retry Strategy
download:
retry_count: 3
retry_delay: 5s
Exponential backoff: Not implemented (constant delay) for simplicity
Scalability
Installed Versions
Performance by version count:
| Versions | govman list Time |
|---|---|
| 5 | 20ms |
| 10 | 35ms |
| 20 | 60ms |
| 50 | 140ms |
Bottleneck: Filesystem stat calls
Optimization: Results cached within command execution
Filesystem Limits
Practical limits:
- Max versions: ~100 (filesystem dependent)
- Total disk usage: Plan for 50-100 GB for many versions
- Cache size: Can grow unbounded (use
govman clean)
Optimization Tips
For Faster Downloads
-
Enable parallel downloads:
download: parallel: true max_connections: 4 -
Use mirrors (if geographically closer):
mirror: enabled: true url: https://golang.google.cn/dl/ -
Increase timeout for slow connections:
download: timeout: 600s
For Faster Version Switching
-
Use shell integration (wrapper function):
govman init source ~/.bashrc -
Avoid
--verboseflag (reduces output overhead)
For Lower Disk Usage
-
Clean cache regularly:
govman clean -
Uninstall unused versions:
govman list govman uninstall 1.old.version -
Use custom cache directory (separate partition):
cache_dir: /mnt/largepartition/govman-cache
Benchmarks
Command Performance
| Command | Time (avg) |
|---|---|
govman --version | 15ms |
govman list | 25ms |
govman list --remote (cached) | 12ms |
govman list --remote (fresh) | 850ms |
govman current | 30ms |
govman use X (installed) | 45ms |
govman install X (cached) | 4s |
govman install X (download) | 22s |
Test environment: Linux, 100 Mbps internet, SSD
Comparison with Other Tools
Installation time (Go 1.25.1):
| Tool | Time | Notes |
|---|---|---|
| govman | 22s | Parallel download |
| gvm | 45s | Single connection |
| goenv | 38s | Single connection |
| asdf | 41s | Plugin overhead |
Version switching time:
| Tool | Time |
|---|---|
| govman | 45ms |
| gvm | 120ms |
| goenv | 90ms |
| asdf | 150ms |
Performance Monitoring
Verbose Mode
See detailed timing:
govman --verbose install 1.25.1
# Output includes:
# - API call timing
# - Download speed
# - Extraction time
# - Total elapsed time
Profiling (Development)
go test -cpuprofile=cpu.prof -memprofile=mem.prof ./...
go tool pprof cpu.prof
Known Performance Issues
Windows Symlink Performance
- Issue: Slower symlink operations on Windows
- Impact: +10-20ms on version switching
- Mitigation: Use PowerShell (better than cmd.exe)
Large Archive Extraction
- Issue: 500+ MB archives take 8-10 seconds
- Impact: Longer installation time for large Go versions
- Mitigation: Streaming extraction (already implemented)
Network Latency
- Issue: High latency connections slow API calls
- Impact:
govman list --remotecan be slow (1-2 seconds) - Mitigation: API caching (10-minute TTL)
Future Optimizations
Planned
- Compression-aware extraction (faster for gzip)
- Incremental version updates (binary diff patches)
- Shared download pool for team environments
- Background pre-fetching of latest releases
Under Consideration
- Optional persistent daemon for instant switching
- ZST compression support (faster than gzip)
- Binary delta compression for updates
Profiling Results
CPU Profile Hotspots
- Archive extraction: 60% of install time
- SHA-256 verification: 15% of install time
- HTTP download: 20% of install time
- Other: 5%
Memory Profile
- Peak allocation: During archive extraction (~25 MB)
- Steady state: ~10 MB (mostly cached data structures)
- No memory leaks: Verified over long-running tests
Performance Best Practices
For Users
- Run
govman cleanperiodically - Use shell integration for fastest switching
- Keep govman updated (
govman selfupdate) - Use SSDs for better extraction performance
For Developers
- Profile before optimizing
- Benchmark critical paths
- Avoid premature optimization
- Measure real-world performance, not synthetic benchmarks