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,cmd/compile,cmd/link: store small GC info as scalars #48740

Closed
josharian opened this issue Oct 1, 2021 · 2 comments
Closed

runtime,cmd/compile,cmd/link: store small GC info as scalars #48740

josharian opened this issue Oct 1, 2021 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@josharian
Copy link
Contributor

Jotting down an idea I had while working on other things.

Lots of GC data is really short. Yet it is stored as FUNCDATA, which means that the data must go in a separate symbol, with all the overhead that such indirection entails (bits to point to the data, cache misses fetching the data, toolchain work processing the data). We have a way to store scalar data (PCDATA). We could use a PCDATA entry associated with the entry PC of a function to store GC info when that GC info is short. The runtime would check the relevant PCDATA entry first and then fall back to the FUNCDATA as needed.

I don't have a good instinct about whether this would end up being better, but it seems like it might be.

@cherrymui
Copy link
Member

cherrymui commented Oct 1, 2021

I'm not sure PCDATA is a good way to store such information. It has its own complexities (e.g. the use of varint). And using the PC seems confusing (and unnecessary).

If it matters, we could let FUNCDATA pseudo-instruction accept a constant (along with a symbol). We could use a bit in the func table to distinguish pointer and scalar. (Mixing pointer and scalar is okay here as this is read-only data and not scanned by the GC.)Then the "fallback" is simple, just checking a bit, instead of switching from PCDATA to FUNCDATA, which are stored quite differently.

@cherrymui cherrymui added this to the Unplanned milestone Oct 1, 2021
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 4, 2021
@mknyszek mknyszek changed the title runtime, cmd/compile, cmd/link: store small GC info as scalars runtime,cmd/compile,cmd/link: store small GC info as scalars Oct 4, 2021
@josharian
Copy link
Contributor Author

Looked at this again. Now that funcdata are stored as 4 byte offsets instead of 8 byte pointers, this makes a lot less sense. Most funcdata are in the 8-20 byte range.

@golang golang locked and limited conversation to collaborators Oct 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants