Skip to content

docs(r13): the Go runtime for systems — example 44 + chapter 44 (Deep Dives) - #13

Merged
patterncatalyst merged 1 commit into
mainfrom
docs/r13-go-runtime
Jul 27, 2026
Merged

patterncatalyst merged 1 commit into
mainfrom
docs/r13-go-runtime

Conversation

@patterncatalyst

Copy link
Copy Markdown
Owner

Closes Part 12 (Deep Dives) with the Go counterpart to ch43's Rust deep dive: a single Go binary that observes its own runtime and prints self-computed ok/FAIL verdicts across four themes.

Example 44-go-runtime-for-systems (mode: local, langs: [go], stdlib only)

  • sched — GMP scheduler: a rendezvous barrier (8 goroutines concurrently alive), a worker pool (every job once), and a no-yield-point spinner under GOMAXPROCS=1 proving signal-based (SIGURG) async preemption lets a starved ticker progress.
  • gc — pacing: auto-GC off, one runtime.GC() → NumGC delta exactly 1; the same churn under GOGC=100 vs 800 and under a tight GOMEMLIMIT shows the pacer's CPU/memory trade-off.
  • netpoll — 2000 goroutines block on pipe reads while OS threads stay bounded (<= 4*GOMAXPROCS+16): goroutines are not threads.
  • knobs — effective GOMAXPROCS/NumCPU/GOGC/GOMEMLIMIT/GODEBUG.
  • verify.lua matches each theme's fixed verdict label (PASS 16 / FAIL 0); numbers vary per run, labels don't.

Runtime facts current to Go 1.26 (source-verified vs go1.26.5): Green Tea GC on by default, container-aware GOMAXPROCS (since 1.25), the _Psyscall P-state removed (~30% lower cgo overhead), netpoller on epoll_pwait.

Chapter 44

To the spine (Part "Deep Dives"): Tools-used box, verbatim go excerpts (no tri-language codetabs), Figures 44.1 (GMP scheduler) + 44.2 (goroutines-not-threads netpoller contrast), verified footer with real gctrace/schedtrace captures and the GODEBUG=asyncpreemptoff=1 FAIL contrast (ticker_incr=0).

Gate

  • --only 44 → 1 passed / 0 failed
  • full --mode local → 98 passed / 0 failed / 3 skipped (skips are 38-otel, lgtm down)
  • validate.py: OK

The implementer also caught + fixed a real goroutine launch-order livelock that only manifested under asyncpreemptoff=1 (spawn the ticker first so the spinner claims runnext).

… Dives)

Closes Part 12 (Deep Dives) with the Go counterpart to ch43's Rust deep
dive: a single Go binary that observes its own runtime and prints
self-computed ok/FAIL verdicts across four themes.

Example 44-go-runtime-for-systems (mode: local, langs: [go], stdlib only):
- sched — GMP scheduler: a rendezvous barrier proves 8 goroutines are
  concurrently alive, a worker pool proves work distribution, and a
  no-yield-point spinner under GOMAXPROCS=1 proves signal-based (SIGURG)
  async preemption lets a starved ticker goroutine progress.
- gc — pacing: with auto-GC off, one runtime.GC() advances NumGC by exactly
  1; the same churn under GOGC=100 vs 800 and under a tight GOMEMLIMIT shows
  the pacer's CPU/memory trade-off in cycle counts.
- netpoll — 2000 goroutines block on pipe reads while the OS thread count
  stays bounded (<= 4*GOMAXPROCS+16): goroutines are not threads.
- knobs — echoes effective GOMAXPROCS/NumCPU/GOGC/GOMEMLIMIT/GODEBUG.
- verify.lua matches each theme's fixed verdict label (PASS 16/FAIL 0);
  numbers vary per run, labels do not.

Runtime facts are current to Go 1.26 (source-verified vs go1.26.5): Green
Tea GC on by default, container-aware GOMAXPROCS (since 1.25), the _Psyscall
P-state removed (~30% lower cgo overhead), netpoller on epoll_pwait.

Chapter 44 to the spine (Part "Deep Dives"): Tools-used box, verbatim go
excerpts (no tri-language codetabs), Figures 44.1 (GMP scheduler) + 44.2
(goroutines-not-threads netpoller contrast), verified footer with the real
gctrace/schedtrace captures and the GODEBUG=asyncpreemptoff=1 FAIL contrast.

Gate: --only 44 → 1 passed/0 failed; full --mode local → 98 passed/0 failed/
3 skipped (skips are 38-otel, lgtm down). validate: OK.
@patterncatalyst
patterncatalyst merged commit 95c8846 into main Jul 27, 2026
2 checks passed
@patterncatalyst
patterncatalyst deleted the docs/r13-go-runtime branch July 27, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant