Go的sync.Pool源代码中的P是什么意思?

jac*_*nie 8 go

最近,我一直在深入研究Go的源代码.当我查看sync.Pool的细节时,我发现了一条我无法理解的评论.

https://golang.org/src/sync/pool.go?s=1633:1992#L58

// Local per-P Pool appendix.
type poolLocalInternal struct {
    private interface{}   // Can be used only by the respective P.
    shared  []interface{} // Can be used by any P.
    Mutex                 // Protects shared.
}
Run Code Online (Sandbox Code Playgroud)

本地per-P Pool附录.

per-P是什么意思?

只能由相应的P使用

P是什么意思?

Cer*_*món 6

P代表处理器。处理器是用于执行 Go 代码的资源。一个进程中正好有 GOMAXPROC Ps。Go Scheduler Design Doc详细描述了 Ps。相关代码在运行时包中