-
Notifications
You must be signed in to change notification settings - Fork 19
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
Update system/status structs #70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just 2 notes:
1- please think about start writing tests, they'll save a lot of time
2- why alphabetic order for struct fields? lately, I've been thinking that we could try to lower the memory usage by sorting using fieldalignment
or something similar. what do you think?
Alphabetical seems like it makes it easy to identify changes. But I also agree it's irrational given how Go stores structures in memory. I'll start putting tests in for any new methods. |
I played with this for a bit. Does not seem to matter what order I put the fields in, the Lidarr struct is always 328 bytes. Try it: https://go.dev/play/p/4zrxs5qm8Ir Maybe t's just that struct, but I'm not seeing an easy win here. :( |
yes, since all fields but bool are multiple of 8 bytes, and there are 9 bool, the only way to have a bigger struct is to have 3 or more groups of bools (https://go.dev/play/p/d18Fu0jxx2d) I think that putting However, if there really is an improvement, we're talking about minimal. Hence, feel free do do as you prefer. |
Can you link me to the
EDIT2:
|
sure, package is: https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
fieldalignment -fix ./ it could be enabled as linter as well as part of linters-settings:
govet:
enable:
- fieldalignment |
btw, it's really a small thing, don't waste too much time here |
|
I can only get this to work through golangci-lint, and not by running it directly I suspect I have a library out of date, but not sure how to fix it. |
I'm just going to worry about optimizing the structs later; there's hundreds that need fixing, and I can't get this dang tool to work right. |
Closes #67.
Updates and alphabetizes structs for
system/status
.