-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
some improvements to summarysize
, fixes #32881
#32886
Conversation
I don’t like the addition of gc-padding (alignment) into the mix here. I think that’s an implementation detail that has no place here. Other than that though, the corrections here to account for some types more correctly sound good. |
Regarding GC padding, yes this is a matter of taste. For other languages I have seen several values, two of which would be sizes with and without padding (which often differ by quite a lot); when possible I have also seen sizes including literal constants being referenced (where this is tracked by the GC). |
Yes, I can see two sides here. But I think including alignment is defensible, since people want to know the actual amount of memory consumed. The fact that it's an implementation detail is kind of the point --- the actual resources consumed by something is the ultimate implementation detail, but when you ask we might as well tell you. |
The changes in my testcase (a large-ish immutable AST created using ANLTR from the C API):
The GC allocated I believe includes some objects that are converted at times, so some garbage is expected. The size for the strings even seems to line up with the GC-reported numbers:
So with these changes we would have a much more reliable summarysize it seems. |
There might still be room for improvement as it seems:
Is the size of a header for a struct perhaps missing? Edit: Or perhaps this was intentional as it says only mutable 0-field takes 1 word now. |
Right; immutable empty structs are singletons, only one instance is ever heap allocated, so each additional one takes no space. |
Yeah, but it's also not necessarily that either. In fact, it could be either an over or underestimate, depending on what the allocator decided to do with the request. |
Ok, I might as well separate those changes anyway. |
- 0-field mutable structs take 1 word - take uniqueness into account for Strings - include union selector bytes for Arrays
dc450be
to
6258d08
Compare
Note there is no final decision on whether to include alignment; I'm just putting in the changes everybody agrees with first so we can at least get some improvements. |
This leaves types alone for now, but as a further enhancement we might want to take hash-consing of types into account.
fixes #32881