Skip to content

runtime: add g.p #24686

Open
Open
@josharian

Description

@josharian

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

Activity

added this to the Unplanned milestone on Apr 4, 2018
dvyukov

dvyukov commented on Apr 4, 2018

@dvyukov
Member

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

josharian commented on Nov 10, 2018

@josharian
ContributorAuthor

cc @benesch :)

dvyukov

dvyukov commented on Nov 10, 2018

@dvyukov
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @josharian@dvyukov@gopherbot

        Issue actions

          runtime: add g.p · Issue #24686 · golang/go