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

Reduce memory allocations in handlePacket #218

Merged
merged 1 commit into from
May 17, 2019

Conversation

claytono
Copy link
Contributor

This converts the byte buffer to a string by casting and parses the
string by looping over it instead of calling Split.

This usage of unsafe is taken from the strings.Builder package here:
https://github.com/golang/go/blob/cb5c82bc3df2e95c2ab36555fefb7cd3f334c685/src/strings/builder.go#L47

This also adds a benchmark for testing overall performance of the UDP code path.

Signed-off-by: Clayton O'Neill claytono@github.com

This converts the byte buffer to a string by casting and parses the
string by looping over it instead of calling Split.

This usage of unsafe is taken from the strings.Builder package here:
https://github.com/golang/go/blob/cb5c82bc3df2e95c2ab36555fefb7cd3f334c685/src/strings/builder.go#L47

Signed-off-by: Clayton O'Neill <claytono@github.com>
@matthiasr
Copy link
Contributor

Sweet, thank you!

@matthiasr matthiasr merged commit 4e64da2 into prometheus:master May 17, 2019
matthiasr pushed a commit that referenced this pull request May 17, 2019
Signed-off-by: Matthias Rampke <mr@soundcloud.com>
matthiasr pushed a commit that referenced this pull request May 20, 2019
Reverting #218 due to race condition issue #220

Signed-off-by: Matthias Rampke <mr@soundcloud.com>
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.

2 participants