-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/ottl] Improve time performance #35129
Merged
TylerHelmuth
merged 1 commit into
open-telemetry:main
from
TylerHelmuth:ottl-improve-time-performance
Sep 16, 2024
Merged
[pkg/ottl] Improve time performance #35129
TylerHelmuth
merged 1 commit into
open-telemetry:main
from
TylerHelmuth:ottl-improve-time-performance
Sep 16, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TylerHelmuth
added
the
Skip Changelog
PRs that do not require a CHANGELOG.md entry
label
Sep 10, 2024
TylerHelmuth
requested review from
bogdandrutu and
evan-bradley
as code owners
September 10, 2024 20:38
I fed your benchmark results into benchstat:
38.85% performance gains! |
atoulme
reviewed
Sep 10, 2024
assert.NoError(t, err) | ||
|
||
t.Run(tt.name, func(t *testing.B) { | ||
result, err := exprFunc(nil, 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.
you might need to use b.N, and report allocs.
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
djaglowski
approved these changes
Sep 11, 2024
jriguera
pushed a commit
to springernature/opentelemetry-collector-contrib
that referenced
this pull request
Oct 4, 2024
**Description:** Improves `Time` performance by move the conversion from our format to Go's format to happen during startup. Benchmarks before: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs Benchmark_Time/simple_short_form-10 1000000000 0.0000079 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_short_form_with_short_year_and_slashes-10 1000000000 0.0000115 ns/op 0 B/op 0 allocs/op Benchmark_Time/month_day_year-10 1000000000 0.0000057 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_long_form-10 1000000000 0.0000075 ns/op 0 B/op 0 allocs/op Benchmark_Time/date_with_timestamp-10 1000000000 0.0000063 ns/op 0 B/op 0 allocs/op Benchmark_Time/day_of_the_week_long_form-10 1000000000 0.0000085 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_weekday,_short_month,_long_format-10 1000000000 0.0000089 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_months-10 1000000000 0.0000070 ns/op 0 B/op 0 allocs/op Benchmark_Time/timestamp_with_time_zone_offset-10 1000000000 0.0000665 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_date_with_timestamp_without_time_zone_offset-10 1000000000 0.0000428 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format-10 1000000000 0.0000345 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000-10 1000000000 0.0000349 ns/op 0 B/op 0 allocs/op Benchmark_Time/no_location-10 1000000000 0.0000035 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_America-10 1000000000 0.0000104 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_Asia-10 1000000000 0.0000084 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000,_ignore_default_location-10 1000000000 0.0000379 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs 0.458s ``` Benchmark's after: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs Benchmark_Time/simple_short_form-10 1000000000 0.0000054 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_short_form_with_short_year_and_slashes-10 1000000000 0.0000037 ns/op 0 B/op 0 allocs/op Benchmark_Time/month_day_year-10 1000000000 0.0000053 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_long_form-10 1000000000 0.0000042 ns/op 0 B/op 0 allocs/op Benchmark_Time/date_with_timestamp-10 1000000000 0.0000087 ns/op 0 B/op 0 allocs/op Benchmark_Time/day_of_the_week_long_form-10 1000000000 0.0000035 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_weekday,_short_month,_long_format-10 1000000000 0.0000036 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_months-10 1000000000 0.0000031 ns/op 0 B/op 0 allocs/op Benchmark_Time/timestamp_with_time_zone_offset-10 1000000000 0.0000491 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_date_with_timestamp_without_time_zone_offset-10 1000000000 0.0000381 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format-10 1000000000 0.0000365 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000-10 1000000000 0.0000364 ns/op 0 B/op 0 allocs/op Benchmark_Time/no_location-10 1000000000 0.0000028 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_America-10 1000000000 0.0000017 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_Asia-10 1000000000 0.0000028 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000,_ignore_default_location-10 1000000000 0.0000393 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs 0.441s ``` **Link to tracking Issue:** <Issue number if applicable> Closes open-telemetry#35078 **Testing:** <Describe what testing was performed and which tests were added.> Added benchmark test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Improves
Time
performance by move the conversion from our format to Go's format to happen during startup.Benchmarks before:
Benchmark's after:
Link to tracking Issue:
Closes #35078
Testing:
Added benchmark test