concurrency

package
v0.0.0-...-f09cf9b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NUMCPU   = runtime.GOMAXPROCS(0)
	NUMCPUx2 = NUMCPU * 2
	NUMCPU_2 = NUMCPU / 2
)

Use runtime.GOMAXPROCS instead of runtime.NumCPU because NumCPU returns the physical CPU cores. However, in a containerization context, that might not be what we want. The physical node could have 128 cores, but we could be cgroup-limited to 2 cores. In that case, we want 2 to be our limit, not 128. It isn't guaranteed that MAXPROCS reflects the cgroup limit, but at least there is a chance that it was set correctly. If not, it defaults to NumCPU anyway, so we're not any worse off.

Functions

func NoMoreThanNUMCPU

func NoMoreThanNUMCPU(conc int) int

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL