Skip to content

golangci-lint

Performance Profiling

How to Measure

1. Verbose mode (-v)

Shows active linter count and per-analyzer execution times.

bash
go tool golangci-lint run -v

Key output lines:

  • [lintersdb] Active N linters: [...] — lists all enabled linters
  • analyzers took ... with top 10 stages: ... — per-analyzer breakdown (parallel; sum exceeds wall time)
  • linters took ... with stages: goanalysis_metalinter: ... — actual wall time
  • Execution took ... — total execution time

2. Trace output (--trace-path)

Generates a Go execution trace viewable in browser.

bash
go tool golangci-lint run --trace-path trace.out
go tool trace trace.out

3. CPU profiling (--cpu-profile-path)

Generates a pprof CPU profile for detailed function-level analysis.

bash
go tool golangci-lint run --cpu-profile-path cpu.prof
go tool pprof cpu.prof

Note: golangci-lint does not provide per-linter timing directly. The -v output groups all linters under goanalysis_metalinter, but the analyzers took line shows individual analyzer stages. To isolate a specific linter, use --enable-only <linter>.

Measurement Results (2026-02-27)

Environment: macOS Darwin 23.6.0, Go 1.25, golangci-lint v2 (via go tool)

Conditions: Cache cleared before each run (go tool golangci-lint cache clean)

Profile Comparison

ProfileConfigLintersWall Time
Base.golangci.yml45~31s

Difference: Strict profile adds only modernize linter compared to base. The previously observed 65s for base was due to cold cache; with consistent cache clearing, both profiles take similar time.

Per-Analyzer Breakdown (Base Profile, Cache Cleared)

Total analyzer time: 11m12s (parallel execution, wall time ~31s)

#AnalyzerTimeNotes
1buildir1m58sSSA IR construction (prerequisite for SSA-based linters)
2wastedassign56sDepends on buildir
3goimports56sImport formatting check
4gocritic50sMulti-checker with many sub-analyzers
5gosec43sSecurity analysis (depends on buildir)
6revive15sExtensible linter framework
7gofumpt12sStrict gofmt
8unparam11sUnused function parameter detection
9unconvert10sUnnecessary type conversion detection
10buildssa9sSSA construction (used by multiple linters)

Resource Usage

  • Memory: avg 1,452 MB, max 2,398 MB (346 samples)
  • Package loading: ~378ms