Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: add g.p #24686

Open
josharian opened this issue Apr 4, 2018 · 3 comments
Open

runtime: add g.p #24686

josharian opened this issue Apr 4, 2018 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Milestone

Comments

@josharian
Copy link
Contributor

Some important and hot data is stored in Ps, such as write barrier buffers and defer pools. Getting from a G to a P currently requires evaluating g.m.p. We should consider adding a direct link, g.p, to avoid an extra memory lookup. This should reduce memory lookups and cache pressure / cache misses on hot code, particularly write barrier writes.

This might also enable us to eliminate the mcache.

This requires updating g.p every time a G gets (un)scheduled.

I took a stab at this but never quite got it working. I hope someone else might.

cc @aclements @dvyukov

@josharian josharian added this to the Unplanned milestone Apr 4, 2018
@dvyukov
Copy link
Member

dvyukov commented Apr 4, 2018

Sounds reasonable to try.
There are probably few hot things (like the ones required for GC barriers and malloc), so we could also try to cache them in g directly.

@josharian
Copy link
Contributor Author

cc @benesch :)

@dvyukov
Copy link
Member

dvyukov commented Nov 10, 2018

I happened to write this code while debugging #27660 yesterday:
https://go-review.googlesource.com/c/go/+/148823/1/src/runtime/proc.go
It has all places for wiring and unwiring g and p marked. Feel free to productionize and submit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Projects
None yet
Development

No branches or pull requests

3 participants