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

optimize sructs with memory alignment / padding #596

Merged
merged 1 commit into from
Mar 7, 2021
Merged

optimize sructs with memory alignment / padding #596

merged 1 commit into from
Mar 7, 2021

Conversation

chemidy
Copy link
Contributor

@chemidy chemidy commented Mar 6, 2021

Another small optimizations on structs.

  • middleware/compress.go :
    • struct with 48 pointer bytes could be 40
    • struct with 64 pointer bytes could be 56
  • middleware/route_headers.go : struct with 72 pointer bytes could be 56
  • mux.go : struct with 88 pointer bytes could be 64
  • tree.go : struct with 136 pointer bytes could be 128

@vtolstov
Copy link

vtolstov commented Mar 6, 2021

do yo have some go binary that check alignment and display needed changes? or tool is only says about misaligning and numbers?

@chemidy
Copy link
Contributor Author

chemidy commented Mar 6, 2021

Sure : i'm using gopls experimental Field alignment analyzer
: https://github.com/golang/tools/releases/tag/gopls/v0.6.0#Experimental

and enabled it on vscode

  "gopls": {
    "analyses": { "fieldalignment": true }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants