Skip to content

detect when rearrangement changes the size class #22

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

Closed
odeke-em opened this issue Nov 6, 2020 · 6 comments · Fixed by #24
Closed

detect when rearrangement changes the size class #22

odeke-em opened this issue Nov 6, 2020 · 6 comments · Fixed by #24
Labels
enhancement New feature or request

Comments

@odeke-em
Copy link
Member

odeke-em commented Nov 6, 2020

Coming here from a suggestion from Josh Bleecher Snyder, we should detect when the rearrangement changes the size class of the struct.

@odeke-em odeke-em added the enhancement New feature or request label Nov 6, 2020
@cuonglm
Copy link
Contributor

cuonglm commented Nov 6, 2020

@odeke-em do you refer to the size class that runtime use to allocate memory for struct? https://golang.org/src/runtime/mksizeclasses.go

@odeke-em
Copy link
Member Author

odeke-em commented Nov 6, 2020

That's right! Please see also see golang/go#42412 (comment)

@cuonglm
Copy link
Contributor

cuonglm commented Nov 6, 2020

Look cool!

So when size class changed, what should we report? Or we will report the actual size class instead of the struct size?

@odeke-em
Copy link
Member Author

odeke-em commented Nov 6, 2020

We should report all of them. Basically:

<LINENO_POS>: struct has size 112 (size class <CLASS_SIZE>), rearrange to <REARRANGEMENT> for optimal size

@odeke-em
Copy link
Member Author

odeke-em commented Nov 6, 2020

Also we should make sure that the optimal size suggested is an actual size class.

@odeke-em
Copy link
Member Author

odeke-em commented Nov 6, 2020

cuonglm pushed a commit that referenced this issue Nov 6, 2020
The runtime use diferrent size class to allocate memory. So a struct
with size 32 and size 24 are atually consume the same amount of memory,
size class 32. So they're not sloppy.

Instead, we only report if the rearrangement makes actual change in
runtime size class.

Fixes #22
cuonglm pushed a commit that referenced this issue Nov 6, 2020
The runtime use diferrent size class to allocate memory. So a struct
with size 32 and size 24 are atually consume the same amount of memory,
size class 32. So they're not sloppy.

Instead, we only report if the rearrangement makes actual change in
runtime size class.

Fixes #22
cuonglm pushed a commit that referenced this issue Nov 6, 2020
The runtime use diferrent size class to allocate memory. So a struct
with size 32 and size 24 are atually consume the same amount of memory,
size class 32. So they're not sloppy.

Instead, we only report if the rearrangement makes actual change in
runtime size class.

Fixes #22
cuonglm pushed a commit that referenced this issue Nov 6, 2020
The runtime use diferrent size class to allocate memory. So a struct
with size 32 and size 24 are atually consume the same amount of memory,
size class 32. So they're not sloppy.

Instead, we only report if the rearrangement makes actual change in
runtime size class.

Fixes #22
cuonglm pushed a commit that referenced this issue Nov 6, 2020
Since when we use "go:linkname", we should always run CI with tip to see
if it's broken or not.

Updates #22
cuonglm pushed a commit that referenced this issue Nov 6, 2020
Since when we use "go:linkname", we should always run CI with tip to see
if it's broken or not.

Updates #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants