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

Optimize Label.String() #15089

Merged
merged 1 commit into from
Mar 8, 2021
Merged

Optimize Label.String() #15089

merged 1 commit into from
Mar 8, 2021

Conversation

michi-covalent
Copy link
Contributor

@michi-covalent michi-covalent commented Feb 24, 2021

Currently Hubble calls Label.String() for each label in every flow. This
PR micro-optimizes Label.String() by using the plus operator instead of
fmt.Sprintf.

// Before
BenchmarkLabel_String-8     5566522  214 ns/op  96B/op   4 allocs/op

// After
BenchmarkLabel_String-8     19522693 60.6 ns/op 48 B/op  1 allocs/op

Signed-off-by: Michi Mutsuzaki michi@isovalent.com

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 24, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to In progress in 1.10.0 Feb 24, 2021
@glibsm
Copy link
Member

glibsm commented Feb 24, 2021

Could you update with benchmem too?

pkg/labels/labels.go Outdated Show resolved Hide resolved
@michi-covalent michi-covalent force-pushed the pr/michi/labelstr branch 2 times, most recently from 06d560f to f7ad702 Compare February 24, 2021 22:23
@michi-covalent michi-covalent changed the title WIP benchmark label.String() Optimize Label.String() Feb 24, 2021
@michi-covalent michi-covalent added the release-note/misc This PR makes changes that have no direct user impact. label Feb 24, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 24, 2021
@michi-covalent michi-covalent marked this pull request as ready for review February 24, 2021 22:28
@michi-covalent michi-covalent requested a review from a team as a code owner February 24, 2021 22:28
@michi-covalent michi-covalent requested review from a team and glibsm and removed request for a team February 24, 2021 22:28
Copy link
Member

@aanm aanm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the commit message since the changes do not reflect the message.

@glibsm
Copy link
Member

glibsm commented Feb 25, 2021

Since we're not scrambling the value each loop, hopefully there are no compiler optimizations skewing the results.

Currently Hubble calls Label.String() for each label in every flow. This
PR micro-optimizes Label.String() by using the plus operator instead of
fmt.Sprintf.

```
// Before
BenchmarkLabel_String-8     5566522  214 ns/op  96B/op   4 allocs/op

// After
BenchmarkLabel_String-8     19522693 60.6 ns/op 48 B/op  1 allocs/op
```

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
@aanm
Copy link
Member

aanm commented Feb 26, 2021

test-me-please

1 similar comment
@michi-covalent
Copy link
Contributor Author

test-me-please

@aanm aanm merged commit bacc2c1 into master Mar 8, 2021
1.10.0 automation moved this from In progress to Done Mar 8, 2021
@aanm aanm deleted the pr/michi/labelstr branch March 8, 2021 12:10
@pchaigno pchaigno added sig/hubble Impacts hubble server or relay kind/cleanup This includes no functional changes. labels Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact. sig/hubble Impacts hubble server or relay
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants