<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Go 语言运行时原理 on PlumePHP</title><link>https://plumephp.com/tags/go-%E8%AF%AD%E8%A8%80%E8%BF%90%E8%A1%8C%E6%97%B6%E5%8E%9F%E7%90%86/</link><description>Recent content in Go 语言运行时原理 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Sun, 25 Oct 2026 10:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/go-%E8%AF%AD%E8%A8%80%E8%BF%90%E8%A1%8C%E6%97%B6%E5%8E%9F%E7%90%86/index.xml" rel="self" type="application/rss+xml"/><item><title>《Go 语言运行时原理》 · 全书目录与章节索引（30 篇）</title><link>https://plumephp.com/posts/books/golang%E8%BF%90%E8%A1%8C%E6%97%B6%E5%8E%9F%E7%90%86/</link><pubDate>Thu, 01 Oct 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/posts/books/golang%E8%BF%90%E8%A1%8C%E6%97%B6%E5%8E%9F%E7%90%86/</guid><description>《Go 语言运行时原理》共 10 章 29 节，全卷实验驱动：每节固定三段式——可复现实验（命令与本机实测数字）、源码定位（文件与函数）、调优决策（决策表或清单）。覆盖调度器、内存分配、GC、编译器四大子系统，以及一次端到端调优实战。</description></item><item><title>《Go 语言运行时原理》10.1 一个服务的端到端调优</title><link>https://plumephp.com/go-runtime-10-1-end-to-end-tuning/</link><pubDate>Thu, 01 Oct 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-10-1-end-to-end-tuning/</guid><description>把前九章的工具串成一次完整调优：一个每请求 20 次分配、914 字节的处理函数，从基准与 pprof 定位到 reflect 与字符串转换两个热点，改写成零分配版本后快约十八倍；并用 GOGC 扫描做对照，证明只调参数只能拿回约百分之五的收益。</description></item><item><title>《Go 语言运行时原理》10.2 运行时决策清单与版本迁移影响</title><link>https://plumephp.com/go-runtime-10-2-runtime-decision-checklist/</link><pubDate>Thu, 01 Oct 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-10-2-runtime-decision-checklist/</guid><description>全书收口：用同一程序在 go1.26 与 go1.27 上对照运行时行为，看哪些指标稳定、哪些结构变了，实测普通负载差异约百分之一、GC 轮数一致；再给出一份可带走的决策清单，覆盖调度、内存、GC、编译器四大子系统的调优判断与版本升级检查项。</description></item><item><title>《Go 语言运行时原理》全书目录与学习路线（30 篇）</title><link>https://plumephp.com/go-runtime-toc/</link><pubDate>Thu, 01 Oct 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-toc/</guid><description>《Go 语言运行时原理》全书目录与学习路线。本卷 10 章 29 节，全部采用实验驱动写法：每节给出可复现实验与实测数字、源码定位（文件与函数）、以及可落地的调优决策表。覆盖调度器、内存分配、GC、编译器四大子系统，适合想从「会用」走向「知其所以然」的 Go 开发者。</description></item><item><title>《Go 语言运行时原理》9.1 类型系统与接口动态派发（itab/eface）</title><link>https://plumephp.com/go-runtime-09-1-itab-eface-dispatch/</link><pubDate>Wed, 30 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-09-1-itab-eface-dispatch/</guid><description>用基准与汇编实测接口动态派发的真实成本：直接调用、接口调用、类型断言、装箱各花多少纳秒；itab 如何构造、何时加锁、如何被缓存；为什么 Go 1.27 的二进制里再也搜不到 go:itab 符号，以及为什么 0 到 255 的整数装箱可以做到零分配。</description></item><item><title>《Go 语言运行时原理》9.2 反射与 unsafe 的运行时成本</title><link>https://plumephp.com/go-runtime-09-2-reflect-unsafe-cost/</link><pubDate>Wed, 30 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-09-2-reflect-unsafe-cost/</guid><description>把反射的每一步成本拆到纳秒级：reflect.Value.Call 为何比直接调用慢约一百倍，一次 Method 调用、一次 Field 读取、一次 New 各花多少并分配多少字节；以及为什么 unsafe 的指针重解释是零成本，给出可替代反射的决策清单。</description></item><item><title>《Go 语言运行时原理》9.3 汇编 ABI 与运行时函数</title><link>https://plumephp.com/go-runtime-09-3-assembly-abi-runtime-funcs/</link><pubDate>Wed, 30 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-09-3-assembly-abi-runtime-funcs/</guid><description>用 objdump 看清 Go 的寄存器 ABI：参数怎么落进 R0 到 R15、超过十六个怎么溢出到栈、浮点参数为什么走 F 寄存器；再定位运行时关键函数的汇编入口，如 memmove、memclrNoHeapPointers、morestack 与 gcWriteBarrier，并给出 ABI 相关的决策清单。</description></item><item><title>《Go 语言运行时原理》8.1 从源码到 SSA：编译阶段与 dump</title><link>https://plumephp.com/go-runtime-08-1-from-source-to-ssa/</link><pubDate>Tue, 29 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-08-1-from-source-to-ssa/</guid><description>用 GOSSAFUNC=sum 生成 ssa.html，实测一个简单函数要经过 58 个 SSA pass（regalloc 21.0 微秒、prove 12.6 微秒），再把编译阶段定位到 src/cmd/compile/internal/gc/main.go:Main 与 src/cmd/compile/internal/ssa/compile.go:passes，并给出 dump 时机。</description></item><item><title>《Go 语言运行时原理》8.2 SSA pass 与优化实测</title><link>https://plumephp.com/go-runtime-08-2-ssa-passes-optimization/</link><pubDate>Tue, 29 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-08-2-ssa-passes-optimization/</guid><description>用 GOSSAFUNC 逐列追踪 OpIsInBounds 节点，实测它在 prove pass 之后消失（边界检查被消除），并用 -S 证明 i*2 被强度削减折叠成 ADD R1&lt;&lt;1；把 prove、checkbce、opt 三个 pass 定位到 src/cmd/compile/internal/ssa/ 下的具体函数。</description></item><item><title>《Go 语言运行时原理》8.3 内联、边界检查消除与 -gcflags</title><link>https://plumephp.com/go-runtime-08-3-inlining-bce-gcflags/</link><pubDate>Tue, 29 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-08-3-inlining-bce-gcflags/</guid><description>用 -gcflags='-m=2' 读出每个函数的内联代价与预算（main 的 cost 137 超过预算 80），用 -d=ssa/check_bce/debug=1 定位未消除的边界检查，并用 -S 对比 guarded 与 unguarded 的汇编（32 字节 vs 96 字节），把内联预算定位到 src/cmd/compile/internal/inline/inl.go。</description></item><item><title>《Go 语言运行时原理》7.1 GOGC/GOMEMLIMIT 实验矩阵</title><link>https://plumephp.com/go-runtime-07-1-gogc-gomemlimit-matrix/</link><pubDate>Mon, 28 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-07-1-gogc-gomemlimit-matrix/</guid><description>用同一段分配负载，在 GOGC=off/100/400 与 GOMEMLIMIT=1GiB 的六组组合下实测墙钟时间、GC 次数与峰值 RSS，得到「谁先触顶谁说了算」的结论，并把 gcPercentHeapGoal 与 memoryLimitHeapGoal 的公式定位到 src/runtime/mgcpacer.go，最后给出选参决策表。</description></item><item><title>《Go 语言运行时原理》7.2 GC trace 与延迟分析</title><link>https://plumephp.com/go-runtime-07-2-gc-trace-latency/</link><pubDate>Mon, 28 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-07-2-gc-trace-latency/</guid><description>把 gctrace 一行里的每一列对应到 src/runtime/mgc.go 的打印语句，用 runtime/metrics 的暂停直方图与调度延迟直方图量化尾延迟，再用 runtime/trace 的事件足迹确认 GC 周期与辅助标记的真实占比，最后落到 pacing 算法（mgcpacer.go）与一份延迟分析清单。</description></item><item><title>《Go 语言运行时原理》7.3 减少分配与 GC 压力</title><link>https://plumephp.com/go-runtime-07-3-reduce-allocation-gc-pressure/</link><pubDate>Mon, 28 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-07-3-reduce-allocation-gc-pressure/</guid><description>用同一组基准量化五类常见优化（字符串拼接、slice/map 预分配、格式化、sync.Pool）在 ns/op、B/op、allocs/op 上的差异，并实测「同样的迭代次数，naive 版触发 6473 次 GC、优化版只有 307 次」，把分配路径定位到 src/runtime/malloc.go:mallocgc 与 src/sync/pool.go。</description></item><item><title>《Go 语言运行时原理》6.1 三色标记与写屏障</title><link>https://plumephp.com/go-runtime-06-1-tricolor-write-barrier/</link><pubDate>Sun, 27 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-06-1-tricolor-write-barrier/</guid><description>从 -gcflags=-S 的汇编里找出写屏障调用：一次全局指针赋值编译成 CALL runtime.gcWriteBarrier2；并拆开 go1.27.0 的混合写屏障实现——mbarrier.go 的伪码、mgc.go 的 writeBarrier 开关、asm_arm64.s 的 gcWriteBarrier2 与 512 项的 wbBuf 缓冲，最后给出写屏障对吞吐影响的判断清单。</description></item><item><title>《Go 语言运行时原理》6.2 GC 阶段、辅助标记与 pacing</title><link>https://plumephp.com/go-runtime-06-2-gc-phases-pacing/</link><pubDate>Sun, 27 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-06-2-gc-phases-pacing/</guid><description>把 gctrace 一行拆成四段时间与三段 CPU，再用 runtime/metrics 读出 STW 暂停分布（p50 18µs / p99 61µs）和 GC 的 CPU 去向；并钉到 go1.27.0 源码——setGCPhase 的阶段开关、gcAssistAlloc 的债务换算、gcControllerState 的 consMark 与 runway，最后给出读 GC 指标的顺序。</description></item><item><title>《Go 语言运行时原理》6.3 Green Tea GC 实测对比</title><link>https://plumephp.com/go-runtime-06-3-greentea-gc-benchmark/</link><pubDate>Sun, 27 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-06-3-greentea-gc-benchmark/</guid><description>实测 Green Tea GC：1.27 与 1.26 各跑「默认 / GOEXPERIMENT=nogreenteagc」两种配置、9 轮取中位数，Green Tea 把 GC CPU 从约 0.19s 降到约 0.06s（约 3 倍），但 1.26→1.27 的墙钟提升并不来自 GC；并钉到 mgcmark_greenteagc.go 的 span 内联标记位与延迟扫描实现。</description></item><item><title>《Go 语言运行时原理》5.1 栈增长与连续栈</title><link>https://plumephp.com/go-runtime-05-1-stack-growth-contiguous/</link><pubDate>Sat, 26 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-05-1-stack-growth-contiguous/</guid><description>用 2 万层递归实测 goroutine 栈：相邻帧地址间距恒为 160 字节（连续栈的证据），全程出现 8 次地址整体搬家（栈复制），StackInuse 从 256 KiB 涨到 4352 KiB；并把「栈检查指令」「翻倍增长」「指针重定位」钉到 go1.27.0 的栈增长序言、newstack、copystack 源码上。</description></item><item><title>《Go 语言运行时原理》5.2 结构体对齐、padding 与缓存行</title><link>https://plumephp.com/go-runtime-05-2-alignment-padding-cacheline/</link><pubDate>Sat, 26 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-05-2-alignment-padding-cacheline/</guid><description>实测同字段集合重排顺序后结构体从 32 字节降到 24 字节（省 25%），并钉到 go1.27.0 的 CalcStructSize 对齐算法；再用 4 个 goroutine 各写一个原子计数器，实测 false sharing 让单次操作从 14.7ms 涨到 221ms（约 15 倍），并确认 M1 Pro 的缓存行是 128 字节。</description></item><item><title>《Go 语言运行时原理》5.3 内存布局优化实测</title><link>https://plumephp.com/go-runtime-05-3-memory-layout-optimization/</link><pubDate>Sat, 26 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-05-3-memory-layout-optimization/</guid><description>把 5.2 的对齐规则落到一个真实结构体上：100 万个实例的 HeapAlloc 从 48.0 B/对象降到 40.0 B/对象（省 8 MB），并诚实报告「[]struct 遍历 vs []*struct 遍历」在 M1 Pro 上没有可辨识差异，附 GC 扫描面（/gc/scan/heap）的实测数字与为什么它不能被简单归因。</description></item><item><title>《Go 语言运行时原理》4.1 size class 与 mcache/mcentral/mheap</title><link>https://plumephp.com/go-runtime-04-1-size-class-mcache-mcentral/</link><pubDate>Fri, 25 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-04-1-size-class-mcache-mcentral/</guid><description>用 50 万次真实分配测出「请求 33 字节实得 48 字节」这类 size class 圆整，实测每对象字节数逐条对上 runtime 的 size class 表，并把一次小对象分配的三级路径（mcache → mcentral → mheap）钉到 go1.27.0 源码的 mallocgc、nextFree、cacheSpan 上，最后给出按 size class 选对象尺寸的决策表。</description></item><item><title>《Go 语言运行时原理》4.2 逃逸分析与分配决策</title><link>https://plumephp.com/go-runtime-04-2-escape-and-allocation-decisions/</link><pubDate>Fri, 25 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-04-2-escape-and-allocation-decisions/</guid><description>把 -gcflags=-m 的每一行拆开读：从 go1.27.0 的 escape 包（escape.go、graph.go、solve.go、leaks.go）看数据流图怎么建、leaks 位图怎么编码、不动点怎么解，并用同一段代码在开/关内联下的不同输出，解释「moved to heap」「escapes to heap」「flow:」三行分别在说什么。</description></item><item><title>《Go 语言运行时原理》4.3 分配热点定位与对象复用</title><link>https://plumephp.com/go-runtime-04-3-allocation-hotspot-and-reuse/</link><pubDate>Fri, 25 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-04-3-allocation-hotspot-and-reuse/</guid><description>用 -memprofile 加 pprof 的 -alloc_space / -alloc_objects / -list 三件套，把分配热点从函数级定位到行级；再用同一份 benchmark 对比 bytes.Buffer 裸用与 sync.Pool 复用，实测 allocs 从 10 降到 1、B/op 从 44992 降到 12293，并诚实报告 ns/op 没有明显改善。</description></item><item><title>《Go 语言运行时原理》3.1 GOMAXPROCS 与容器感知实测</title><link>https://plumephp.com/go-runtime-03-1-gomaxprocs-container-aware/</link><pubDate>Thu, 24 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-03-1-gomaxprocs-container-aware/</guid><description>容器里 Go 程序只用了限额一半的 CPU，是高频困惑。本节在真实 Docker 容器做矩阵实验：cgroup 限额 2/4/1.5 核时 GOMAXPROCS 各取多少，关掉 containermaxprocs 后吞吐如何变化；再定位到 runtime/cgroup_linux.go:defaultGOMAXPROCS 与 adjustCgroupGOMAXPROCS。</description></item><item><title>《Go 语言运行时原理》3.2 runtime/trace 解读 goroutine 时间线</title><link>https://plumephp.com/go-runtime-03-2-runtime-trace-timeline/</link><pubDate>Thu, 24 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-03-2-runtime-trace-timeline/</guid><description>runtime/trace 是逐事件记录，不是采样。本节用 go tool trace 的三个纯文本出口（-d=footprint 计数、-d=parsed 逐事件、-pprof 画像）从真实 trace 读出 goroutine 生命周期、STW/GC 阶段与阻塞归因，再定位到 runtime/trace.go:StartTrace 与 tracestatus.go:writeGoStatus。</description></item><item><title>《Go 语言运行时原理》3.3 调度相关的性能决策</title><link>https://plumephp.com/go-runtime-03-3-scheduling-performance-decisions/</link><pubDate>Thu, 24 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-03-3-scheduling-performance-decisions/</guid><description>GOMAXPROCS 该设几、channel 通信会不会因为核多而变慢，是调度层最常被问的两个问题。本节用 CPU 基准与 ping-pong 基准做核数扫描，给出「核数-吞吐」与「核数-通信延迟」两条真实曲线，再定位到 proc.go:schedule/findRunnable/wakep/stealWork。</description></item><item><title>《Go 语言运行时原理》2.1 G/M/P 结构与状态机</title><link>https://plumephp.com/go-runtime-02-1-gmp-structures/</link><pubDate>Wed, 23 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-02-1-gmp-structures/</guid><description>G/M/P 是什么，站内 Go 专题已经讲过。本节只写增量：用 GODEBUG=scheddetail=1 的真实回显，把每个 goroutine 的 status 与 waitreason 逐字段读出来，再定位到 src/runtime/runtime2.go 的状态常量与 g/m/p 结构体，最后给出一张可直接对照的状态迁移表。</description></item><item><title>《Go 语言运行时原理》2.2 调度循环与 work stealing 实测</title><link>https://plumephp.com/go-runtime-02-2-scheduling-loop-work-stealing/</link><pubDate>Wed, 23 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-02-2-scheduling-loop-work-stealing/</guid><description>调度循环长什么样、work stealing 怎么工作，站内专题讲过原理。本节只写增量：用 schedtrace 的每-P 队列长度和 runtime/metrics 的 goroutine 状态计数，实测窃取的痕迹；再顺着 proc.go:schedule→findRunnable→stealWork→runqsteal 把代码走一遍；最后给一张「队列分布→结论」的决策表。</description></item><item><title>《Go 语言运行时原理》2.3 抢占式调度与 sysmon</title><link>https://plumephp.com/go-runtime-02-3-preemption-and-sysmon/</link><pubDate>Wed, 23 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-02-3-preemption-and-sysmon/</guid><description>协作式抢占和异步抢占的区别、sysmon 干什么，站内专题讲过概念。本节只写增量：用两组真实实验量化抢占——关闭异步抢占后 GC 的 STW 从 0.3ms 暴涨到 1.8s，以及 GOMAXPROCS=1 下阻塞系统调用被 sysmon 夺回 P；再定位到 proc.go:sysmon/retake/preemptone 与 preempt.go:asyncPreempt。</description></item><item><title>《Go 语言运行时原理》1.1 实验驱动方法：GODEBUG、pprof、trace 与 SSA dump</title><link>https://plumephp.com/go-runtime-01-1-experiment-driven-method/</link><pubDate>Tue, 22 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-01-1-experiment-driven-method/</guid><description>交付完整观测探针与基准源码，依次演示 GODEBUG 调度与 GC 输出、CPU 和堆 profile、runtime trace、逃逸分析与 SSA 观测方法；按实际工具链记录命令和环境，解释每种工具能证明什么、不能证明什么，不把队列快照当作 work stealing 的证据，也不把单次耗时当作通用性能结论。</description></item><item><title>《Go 语言运行时原理》1.2 源码地图与阅读路线</title><link>https://plumephp.com/go-runtime-01-2-source-map-and-reading-path/</link><pubDate>Tue, 22 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-01-2-source-map-and-reading-path/</guid><description>按实际 GOROOT 与 Go 工具链生成运行时源码清单、文件哈希和关键符号位置，区分调度、内存分配、垃圾回收与编译器的阅读入口；明确统计范围、版本与架构差异，并用可执行脚本保存定位结果，避免把旧版本固定行号、文件数量或不完整的 grep 输出当作当前源码事实。</description></item><item><title>《Go 语言运行时原理》1.3 复现基线：环境与基准约定</title><link>https://plumephp.com/go-runtime-01-3-reproduction-baseline/</link><pubDate>Tue, 22 Sep 2026 16:00:00 +0800</pubDate><guid>https://plumephp.com/go-runtime-01-3-reproduction-baseline/</guid><description>性能数字脱离环境就没有意义。本节先采集本机基线（Go 版本、CPU 型号与核数、内存、默认 GOMAXPROCS/GOGC），再做三个对照实验：-race 的代价、GOMAXPROCS 环境变量、GOGC/GOMEMLIMIT 对 GC 次数的影响，最后固化成本卷所有实验都要遵守的复现约定。</description></item></channel></rss>