Skip to content

Commit 837bc14

Browse files
chore: remove hardcoded GOMAXPROCS; print cpu info in startup-banner (#9600)
**Description** This PR removes the hardcoded `GOMAXPROCS(128)` from the shared `main.go`. Modern go runtimes (>1.25) on Linux and containers use cgroup to determine optimal CPU allocation. This PR also introduces the printing of GOMAXPROCS and numcpus in the version banner. **Checklist** - [x] The PR title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) syntax, leading with `fix:`, `feat:`, `chore:`, `ci:`, etc. - [x] Code compiles correctly and linting (via trunk) passes locally - [x] Tests added for new functionality, or regression tests for bug fixes added as applicable
1 parent 974923a commit 837bc14

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

dgraph/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import (
1717
)
1818

1919
func main() {
20-
// Setting a higher number here allows more disk I/O calls to be scheduled, hence considerably
21-
// improving throughput. The extra CPU overhead is almost negligible in comparison. The
22-
// benchmark notes are located in badger-bench/randread.
23-
runtime.GOMAXPROCS(128)
2420

2521
absDiff := func(a, b uint64) uint64 {
2622
if a > b {

x/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Commit timestamp : %v
5050
Branch : %v
5151
Go version : %v
5252
jemalloc enabled : %v
53+
GOMAXPROCS : %v
54+
Num CPUs : %v
5355
5456
For Dgraph official documentation, visit https://dgraph.io/docs.
5557
For discussions about Dgraph , visit https://discuss.dgraph.io.
@@ -59,7 +61,7 @@ For discussions about Dgraph , visit https://discuss.dgraph.io.
5961
6062
`,
6163
dgraphVersion, dgraphCodename, ExecutableChecksum(), lastCommitSHA, lastCommitTime, gitBranch,
62-
runtime.Version(), jem, licenseInfo)
64+
runtime.Version(), jem, runtime.GOMAXPROCS(0), runtime.NumCPU(), licenseInfo)
6365
}
6466

6567
// PrintVersion prints version and other helpful information if --version.

0 commit comments

Comments
 (0)