-
Notifications
You must be signed in to change notification settings - Fork 34
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
🚀 Speed up toMetricTagsID #130
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.
Awesome, thanks for the PR! Minor suggestion on creating a private new
function for struct initialization, but otherwise looks good. Hopefully this improvement is good enough, but happy to brainstorm if it looks like there may be deeper structural issues that may need to be addressed.
Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @bmoylan)
metrics/tag.go, line 110 at r1 (raw file):
value: normalizeTag(v), } tag.keyValue = tag.key + ":" + tag.value
Might be worth creating a newTag(k, v)
function -- that function can handle normalization of k
and v
and ensuring keyValue
is set.
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.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @nmiyake)
metrics/tag.go, line 110 at r1 (raw file):
Previously, nmiyake (Nick Miyake) wrote…
Might be worth creating a
newTag(k, v)
function -- that function can handle normalization ofk
andv
and ensuringkeyValue
is set.
Done.
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.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @nmiyake and @bmoylan)
metrics/tag.go, line 109 at r2 (raw file):
} func newTag(normalizedKey, normakizedValue string) Tag {
Actually I think it'd be nicer if this just accepted the non-normalized values and we performed the normalization as part of the function.
There's also a typo in normakizedValue
, but probably won't matter as if the suggestion is followed the variable names should be updated as well
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.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @nmiyake)
metrics/tag.go, line 109 at r2 (raw file):
Previously, nmiyake (Nick Miyake) wrote…
Actually I think it'd be nicer if this just accepted the non-normalized values and we performed the normalization as part of the function.
There's also a typo in
normakizedValue
, but probably won't matter as if the suggestion is followed the variable names should be updated as well
ack, fixed!
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.
Reviewed 1 of 1 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved
toMetricTagsID
is called every time a metric is incremented/changed. This PR updates the implementation to run faster and allocate less memory.Benchmark results:
Old
New
This was flagged by an internal team looking at the pprofs of their service.
This change is