-
Notifications
You must be signed in to change notification settings - Fork 32
datadog: add fast path for serializer #213
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
98f08b0 to
791dd09
Compare
datadog/serializer.go
Outdated
| // Trim leading/trailing '.', '_' or '-' | ||
| start, end := orig, len(dst) | ||
| for start < end && isTrim(dst[start]) { | ||
| start++ | ||
| } | ||
| for end > start && isTrim(dst[end-1]) { | ||
| end-- | ||
| } |
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.
Why not just use strings.Trim or bytes.Trim for this?
datadog/serializer_test.go
Outdated
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { |
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.
| b.ResetTimer() | |
| for i := 0; i < b.N; i++ { | |
| for b.Loop() { |
b.Loop is the newer, improved way to do this since 1.24, and provides a b.ResetTimer for free ahead of the first iter. See https://pkg.go.dev/testing#B.Loop
datadog/serializer_test.go
Outdated
| cutset := "._-" | ||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { |
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.
| cutset := "._-" | |
| b.ResetTimer() | |
| for i := 0; i < b.N; i++ { | |
| const cutset = "._-" | |
| for b.Loop() { |
extemporalgenome
left a comment
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.
LGTM
extemporalgenome
left a comment
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.
LGTM
In the common case where metric names/tags are all ASCII, we can copy bytes much more quickly. Update some unrelated code to fix some formatting concerns and also use the newest syntax.
acddb8d to
9fcd686
Compare
In the common case where metric names/tags are all ASCII, we can copy bytes much more quickly.