-
Notifications
You must be signed in to change notification settings - Fork 1
reconciler: Shrink Status type #101
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
Conversation
|
eb85019
to
86ffd17
Compare
On
And in this PR:
So for 1M objects with |
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.
@joamaki Nice work! few comments but out of context so feel free to discard...
reconciler/types.go
Outdated
ID: nextID(), | ||
} | ||
} | ||
|
||
// statusError constructs the status that marks the object | ||
// as failed to be reconciled. | ||
func StatusError(err error) Status { | ||
errStr := err.Error() |
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.
this will panic if called with nil
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.
Ah indeed! Fixed and added test.
StatusKindRefreshing StatusKind = "Refreshing" | ||
StatusKindDone StatusKind = "Done" | ||
StatusKindError StatusKind = "Error" | ||
var ( |
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.
Could be out of context here but this feels a little odd aka consts -> global variables. Not sure if applicable but perhaps we could have gone with StatusKind uint8 and generate the string equivalent of the consts via go:generate.
Aka have the compiler generate the map vs manually curating statusKindToString
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.
I wish I could do that, but since we have existing code doing string(foo.Status.Kind)
we cannot do type StatusKind uint8
since string(uint8(0))
compiles and we want to force the code to switch to foo.Status.Kind.String()
. Maybe in the future once all use-sites have converted over? For now I'd like to err on the safe side and do this trick here to force the use-sites to be fixed.
Also this has to be var
instead of const
since struct{...}
cannot be const.
Error is rarely set, so we can save 8 bytes by using *string instead of string. This brings 'Status' size down to 56 from 64 bytes. Signed-off-by: Jussi Maki <jussi.maki@isovalent.com>
This brings 'Status' size to 48 bytes from 56. The struct fields were rearranged by "betteralign". Signed-off-by: Jussi Maki <jussi.maki@isovalent.com>
86ffd17
to
e4cada2
Compare
Error
fromstring
to*string
as it's rarely set (64 => 56 bytes)StatusKind
fromstring
touint8
(56 => 48 bytes)The
StatusKind
isstruct { uint8 }
to make sure code that used to dostring(foo.Status.Kind)
won't compile and is forced to change tofoo.Status.Kind.String()
. Note that we're going to release v0.5.0 with few other breaking API changes in addition to this one and tooling in cilium/cilium only bumps StateDB on patch version changes.