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):

ConnectionsTimeSpeed
145s3.3 MB/s
228s5.4 MB/s
420s7.5 MB/s
818s8.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 --remote called multiple times
  • govman install after govman 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

Operation Time: < 10ms

time govman use 1.25.1
# real    0m0.045s

What happens:

  1. Validate version installed (~1ms)
  2. Update configuration (~5ms)
  3. Create/update symlink (~2ms)
  4. 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:

Versionsgovman list Time
520ms
1035ms
2060ms
50140ms

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

  1. Enable parallel downloads:

    download:
      parallel: true
      max_connections: 4
    
  2. Use mirrors (if geographically closer):

    mirror:
      enabled: true
      url: https://golang.google.cn/dl/
    
  3. Increase timeout for slow connections:

    download:
      timeout: 600s
    

For Faster Version Switching

  1. Use shell integration (wrapper function):

    govman init
    source ~/.bashrc
    
  2. Avoid --verbose flag (reduces output overhead)

For Lower Disk Usage

  1. Clean cache regularly:

    govman clean
    
  2. Uninstall unused versions:

    govman list
    govman uninstall 1.old.version
    
  3. Use custom cache directory (separate partition):

    cache_dir: /mnt/largepartition/govman-cache
    

Benchmarks

Command Performance

CommandTime (avg)
govman --version15ms
govman list25ms
govman list --remote (cached)12ms
govman list --remote (fresh)850ms
govman current30ms
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):

ToolTimeNotes
govman22sParallel download
gvm45sSingle connection
goenv38sSingle connection
asdf41sPlugin overhead

Version switching time:

ToolTime
govman45ms
gvm120ms
goenv90ms
asdf150ms

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

  • 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 --remote can 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

  1. Archive extraction: 60% of install time
  2. SHA-256 verification: 15% of install time
  3. HTTP download: 20% of install time
  4. 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

  1. Run govman clean periodically
  2. Use shell integration for fastest switching
  3. Keep govman updated (govman selfupdate)
  4. Use SSDs for better extraction performance

For Developers

  1. Profile before optimizing
  2. Benchmark critical paths
  3. Avoid premature optimization
  4. Measure real-world performance, not synthetic benchmarks