Recently, I've been digging into Go's source code. When I looked into the details of sync.Pool, I found a comment I couldn't understand.
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.
}
Local per-P Pool appendix.
What does per-P mean?
Can be used only by the respective P
What does P mean?
P stands for processor. A processor is a resource used to execute Go code. There are exactly GOMAXPROC Ps in a process. The Go Scheduler Design Doc describes Ps in detail. The relevant code is in the runtime package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With