Skip to content

cmd/compile: rearrange hairyVisitors to reduce struct slop and reclaim 33.33% space wasted #42416

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 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@odeke-em
Copy link
Member

odeke-em commented Nov 6, 2020

Coming here from tip ecc3f51, with one of the static analysis tools, we have developed at Orijtech, Inc., we've found a
struct that we could re-arrange and reclaim 33.33% of the RAM each struct uses

$ structslop .
cmd/compile/internal/gc/inl.go:300:19: struct has size 40 (size class 48), could be 32 (size class 32),
rearrange to  struct{reason string; usedLocals map[*Node]bool; budget int32; extraCallCost int32} for
optimal size (33.33% savings)

hairyVisitors seems like a potentially frequently created struct, so these savings could directly be quantifiable in compilations.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/267978 mentions this issue: cmd/compile: re-arrange hairyVisitors inline helper for efficiency

@toothrot toothrot added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Nov 6, 2020
@toothrot toothrot added this to the Backlog milestone Nov 6, 2020
@rsc
Copy link
Contributor

rsc commented Nov 6, 2020

This one is again not something that there are many of. This variable is declared as a local to hold state before a recursive walk of a function body. It's a miniscule percentage of a tiny fraction of the overall compiler memory usage.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@mknyszek mknyszek moved this to Triage Backlog in Go Compiler / Runtime Jul 15, 2022
@odeke-em
Copy link
Member Author

Can be closed.

@github-project-automation github-project-automation bot moved this from Triage Backlog to Done in Go Compiler / Runtime Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
Development

No branches or pull requests

4 participants