Skip to content

Commit 1741450

Browse files
committed
chore: new concurrency default
1 parent 18e322e commit 1741450

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

.golangci.next.reference.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,8 +4186,8 @@ run:
41864186
go: '1.19'
41874187

41884188
# Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
4189-
# If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota.
4190-
# Default: the number of logical CPUs in the machine
4189+
# Default: automatically set to match Linux container CPU quota and
4190+
# fall back to the number of logical CPUs in the machine.
41914191
concurrency: 4
41924192

41934193

pkg/commands/flagsets.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ func setupFormattersFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
4242
}
4343

4444
func setupRunFlagSet(v *viper.Viper, fs *pflag.FlagSet) {
45-
internal.AddFlagAndBindP(v, fs, fs.IntP, "concurrency", "j", "run.concurrency", getDefaultConcurrency(),
46-
color.GreenString("Number of CPUs to use (Default: number of logical CPUs)"))
45+
internal.AddFlagAndBindP(v, fs, fs.IntP, "concurrency", "j", "run.concurrency", 0,
46+
color.GreenString("Number of CPUs to use (Default: Automatically set to match Linux container CPU quota,"+
47+
" fall backs on number of logical CPUs)"))
4748

4849
internal.AddFlagAndBind(v, fs, fs.String, "modules-download-mode", "run.modules-download-mode", "",
4950
color.GreenString("Modules download mode. If not empty, passed as -mod=<mode> to go tools"))

pkg/commands/run.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, args []string) error
161161
}
162162

163163
if c.cfg.Run.Concurrency == 0 {
164+
// `runtime.GOMAXPROCS` defaults to the value of `runtime.NumCPU`.
164165
backup := runtime.GOMAXPROCS(0)
165166

166167
// Automatically set GOMAXPROCS to match Linux container CPU quota.
@@ -590,16 +591,6 @@ func setupRunPersistentFlags(fs *pflag.FlagSet, opts *runOptions) {
590591
fs.StringVar(&opts.TracePath, "trace-path", "", color.GreenString("Path to trace output file"))
591592
}
592593

593-
func getDefaultConcurrency() int {
594-
if os.Getenv(envHelpRun) == "1" {
595-
// Make stable concurrency for generating help documentation.
596-
const prettyConcurrency = 8
597-
return prettyConcurrency
598-
}
599-
600-
return runtime.NumCPU()
601-
}
602-
603594
func printMemStats(ms *runtime.MemStats, logger logutils.Log) {
604595
logger.Infof("Mem stats: alloc=%s total_alloc=%s sys=%s "+
605596
"heap_alloc=%s heap_sys=%s heap_idle=%s heap_released=%s heap_in_use=%s "+

0 commit comments

Comments
 (0)