lint: cap -j=4 and use --allow-parallel-runners#5334
Merged
Conversation
Add -j=4 and --allow-parallel-runners to the four golangci-lint invocations in Taskfile.yml, and drop the per-task TMPDIR override introduced in #5050. The TMPDIR override existed to give each concurrent invocation its own copy of $TMPDIR/golangci-lint.lock; --allow-parallel-runners tells golangci-lint not to acquire that lock in the first place. Safe to do because golangci-lint v2.12.0 (already pinned on main) added content-addressable cache keys. Cold `task lint` drops from ~185s to ~76s; warm runs are cache-bound and unchanged. Co-authored-by: Isaac
Collaborator
|
Commit: a0a9b8b |
Collaborator
|
Commit: d51cc3d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to the four
golangci-lint runinvocations inTaskfile.yml:-j=4to cap analyzer concurrency.--allow-parallel-runnersand drop the per-taskTMPDIRworkaround introduced in Replace Makefile with Taskfile.yml and move all generation-related logic there #5050../task lint, fresh caches, sametools/go.mod:2.4× faster cold wall, 7× less CPU. Warm runs are cache-bound and unchanged.
-j=4golangci-lint scales poorly past 4–6 workers (upstream #5149). With three sub-lints running in parallel under
lint-go, the default-j=GOMAXPROCSputs ~48 nominal workers on 16 cores — most of the 2282s on origin/main is kernel scheduling contention. Capping at 4 lets the three modules cooperate.--allow-parallel-runnersBy default golangci-lint takes a system-wide lock and refuses to start if another copy is already running. The per-task
TMPDIRoverride existed to give each invocation its own copy of that lock file so it didn't collide;--allow-parallel-runnerstells golangci-lint not to take the lock in the first place. Same outcome, noTMPDIRplumbing.Parallel runs happen when
lint-gofans out to the three module sub-lints, and when multiple worktrees lint at once.Safe to skip the lock because golangci-lint v2.12.0 added content-addressable cache keys (PR #6445). Before that, two worktrees produced separate cache entries (keyed by absolute path) — no sharing, but also no contention. Now the entries are shared by content, so concurrent runs read and write the same files; the cache uses OS-level file locks with atomic write semantics to keep that safe.
origin/mainalready pins v2.12.2.Trade-off
Two
task lintruns in the same worktree no longer fail-fast with"parallel golangci-lint is running"— they race instead, harmlessly but wastefully (duplicate analysis work). Minor.Test plan
task lintcleantask lint-qcleantask lintacross two worktrees both succeedThis pull request and its description were written by Isaac.