Repository navigation
docs(r13): the Go runtime for systems — example 44 + chapter 44 (Deep Dives) - #13
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/FAILverdicts across four themes.Example
44-go-runtime-for-systems(mode: local, langs: [go], stdlib only)GOMAXPROCS=1proving signal-based (SIGURG) async preemption lets a starved ticker progress.runtime.GC()→NumGCdelta exactly 1; the same churn underGOGC=100vs800and under a tightGOMEMLIMITshows the pacer's CPU/memory trade-off.<= 4*GOMAXPROCS+16): goroutines are not threads.GOMAXPROCS/NumCPU/GOGC/GOMEMLIMIT/GODEBUG.verify.luamatches 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-awareGOMAXPROCS(since 1.25), the_PsyscallP-state removed (~30% lower cgo overhead), netpoller onepoll_pwait.Chapter 44
To the spine (Part "Deep Dives"): Tools-used box, verbatim
goexcerpts (no tri-language codetabs), Figures 44.1 (GMP scheduler) + 44.2 (goroutines-not-threads netpoller contrast), verified footer with realgctrace/schedtracecaptures and theGODEBUG=asyncpreemptoff=1FAIL contrast (ticker_incr=0).Gate
--only 44→ 1 passed / 0 failed--mode local→ 98 passed / 0 failed / 3 skipped (skips are38-otel, lgtm down)validate.py: OKThe implementer also caught + fixed a real goroutine launch-order livelock that only manifested under
asyncpreemptoff=1(spawn the ticker first so the spinner claimsrunnext).