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

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Oct 1, 2021

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
Contributor

@cherrymui 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.

Loading

@cherrymui cherrymui added this to the Unplanned milestone Oct 1, 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

@josharian josharian commented Oct 5, 2021

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.

Loading

@josharian josharian closed this Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants