Guest processes are limited to 64 threads

Open
#494 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
47/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, go, macos

Research direction

Start with MAX_THREADS in src/runtime/thread.h and the SP_EL1 slot tracking in src/runtime/thread.c; then review the thread-related context in #224. Reproduce the failure with the Go workload command in the issue and confirm whether it also occurs during make bench-ci. Done means guest processes can create more than 64 threads and the workload no longer fails with EAGAIN.

Written by the indexing model from the issue text.

Description

bug enhancement

A guest process gets at most 64 threads (MAX_THREADS in src/runtime/thread.h; the SP_EL1 slots are tracked in one uint64_t in src/runtime/thread.c). The 65th clone fails with EAGAIN. Linux allows far more, and Go programs reach this with ordinary work, because the Go runtime starts a new OS thread whenever a goroutine blocks in a syscall, independent of GOMAXPROCS.

gofmt over a few standard-library trees is enough:

scripts/elfuse-oci.py run --entrypoint /bin/sh \
  mirror.gcr.io/library/golang:1.23-alpine@sha256:56e44a486dc12270a471259239c0005ae492be2f078c4f54567c0e3159e23e4b \
  -c 'r=$(go env GOROOT); go version; for t in net runtime crypto; do gofmt -l $r/src/$t; done; gofmt -d $r/src/fmt' > /dev/null

It failed 5 of 30 runs:

runtime: failed to create new OS thread (have 65 already; errno=11)
runtime: may need to increase max user processes (ulimit -u)
fatal error: newosproc

With GOMAXPROCS=4 it passed 40 of 40 runs alone but still failed inside a full make bench-ci, so capping GOMAXPROCS is not a workaround.

This is why the go row of the real-workload ranking is left out of the Tier 3 benchmarks in #493.

Refs #224

Dominant language
C
Stars
287
Forks
33
Avg merge
2d 17h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.