mcache per P or per M?

176 views
Skip to first unread message

Vincent Blanchon

unread,
Nov 2, 2019, 7:57:56 AM11/2/19
to golang-nuts
Hello,

Reading the code, I can see the structs m and p hold a mcache instance. I'm curious to understand why both of them need an instance of mcache?
Also, I see that those instances are the same ones (runtime/proc.go init the p.mcache with m.cache and vice versa), is it correct? Should we consider that mcache belongs to m or p?

Thank you for the ones that will take time to reply :)

tokers

unread,
Nov 3, 2019, 9:48:51 PM11/3/19
to golang-nuts
Hello!

It's my own understanding and it's not necessary true.
The mcache belongs to per P, but by assigning it to M, we can mark M is binded to this P.

Ian Lance Taylor

unread,
Nov 4, 2019, 5:27:00 PM11/4/19
to Vincent Blanchon, golang-nuts
On Sat, Nov 2, 2019 at 4:58 AM Vincent Blanchon
<blanchon...@gmail.com> wrote:
>
> Reading the code, I can see the structs m and p hold a mcache instance. I'm curious to understand why both of them need an instance of mcache?
> Also, I see that those instances are the same ones (runtime/proc.go init the p.mcache with m.cache and vice versa), is it correct? Should we consider that mcache belongs to m or p?

The mcache belongs to the P.

We used to have the possibility of an M using the mcache of a P even
though it was not running on the P. That happened in the helpgc
function which was run by gchelpers. But gchelpers was removed in
https://golang.org/cl/134785, so it may be that we no longer need the
mcache field on an M.

Out of curiosity, I tried that: https://golang.org/cl/205239.

Ian

Vincent Blanchon

unread,
Nov 5, 2019, 12:49:00 AM11/5/19
to golang-nuts

Thank you, Ian! With the CL it is much more clear now
Reply all
Reply to author
Forward
0 new messages