Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
runtime: P-local/M-local storage for goroutines? #33247
$ go version go version go1.12.4 linux/amd64
I am trying to implement an LRU cache. Several global lru lists could be accessed concurrently by multiple goroutines, which could be a disaster in a machine with 24 or more cores.
Therefore, it would be great if I can add the item to P-local/M-local storage and flush the batched item into the lru list as a whole. This should greatly reduce the potential contention for the global lru list.
How can I do it? I saw some related issues, #8281 and #21355, which leads me to a project called gls, but the code seems too much to integrate into my project (actually I'd better not include any third-party package to avoid potential law issues). Is there any built-in way to achieve this?
See also #18802.
I'm not sure quite what you are proposing. If you are just asking a question, you will almost certainly get better answers in a forum; see https://golang.org/wiki/Questions.
If you are suggesting a language or runtime package change, can you clarify what you are looking for? It is extremely unlikely that Go will ever add general purpose per-P or per-M storage. But it could conceivably be added in the context of a general purpose mechanism, as discussed in #18802.
Thanks for the link. I am just asking a question, and I have already posted a thread in the forum. My use case is to reclaim certain range of memory, which will be stored in the LRU list.
After looking at #18802 , I guess I am looking for the variant of