Commit d51cc3d
authored
lint: cap -j=4 and use --allow-parallel-runners (#5334)
Two changes to the four `golangci-lint run` invocations in
`Taskfile.yml`:
- Add `-j=4` to cap analyzer concurrency.
- Add `--allow-parallel-runners` and drop the per-task `TMPDIR`
workaround introduced in #5050.
`./task lint`, fresh caches, same `tools/go.mod`:
| | Cold wall | Cold CPU (user+sys) | Warm wall |
|---|---|---|---|
| origin/main | 185s | 2282s | 4.1s |
| this PR | 76s | 327s | 4.0s |
2.4× faster cold wall, 7× less CPU. Warm runs are cache-bound and
unchanged.
## `-j=4`
golangci-lint scales poorly past 4–6 workers (upstream
[#5149](golangci/golangci-lint#5149)). With
three sub-lints running in parallel under `lint-go`, the default
`-j=GOMAXPROCS` puts ~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-runners`
By default golangci-lint takes a system-wide lock and refuses to start
if another copy is already running. The per-task `TMPDIR` override
existed to give each invocation its own copy of that lock file so it
didn't collide; `--allow-parallel-runners` tells golangci-lint not to
take the lock in the first place. Same outcome, no `TMPDIR` plumbing.
Parallel runs happen when `lint-go` fans 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](golangci/golangci-lint#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/main` already pins v2.12.2.
## Trade-off
Two `task lint` runs 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
- [x] `task lint` clean
- [x] `task lint-q` clean
- [x] Parallel `task lint` across two worktrees both succeed
- [ ] CI lint job passes
This pull request and its description were written by Isaac.1 parent e06a29d commit d51cc3d
1 file changed
Lines changed: 15 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | | - | |
102 | | - | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
119 | | - | |
120 | | - | |
121 | 118 | | |
122 | 119 | | |
123 | 120 | | |
124 | 121 | | |
125 | 122 | | |
126 | 123 | | |
127 | | - | |
128 | | - | |
129 | 124 | | |
130 | 125 | | |
131 | | - | |
| 126 | + | |
132 | 127 | | |
133 | 128 | | |
134 | 129 | | |
135 | 130 | | |
136 | | - | |
137 | | - | |
138 | 131 | | |
139 | 132 | | |
140 | 133 | | |
141 | 134 | | |
142 | 135 | | |
143 | 136 | | |
144 | | - | |
145 | | - | |
146 | 137 | | |
147 | 138 | | |
148 | | - | |
| 139 | + | |
149 | 140 | | |
150 | 141 | | |
151 | 142 | | |
152 | | - | |
153 | | - | |
154 | 143 | | |
155 | 144 | | |
156 | 145 | | |
| |||
162 | 151 | | |
163 | 152 | | |
164 | 153 | | |
165 | | - | |
166 | | - | |
167 | | - | |
| 154 | + | |
168 | 155 | | |
169 | 156 | | |
170 | 157 | | |
| |||
0 commit comments