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

feat: Optimize log parsing performance by using unsafe package #13223

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

cyriltovena
Copy link
Contributor

This commit modifies the log parsing logic in the distributor package to improve performance. It introduces the use of the unsafe package to work with log strings as byte slices, reducing memory allocations and improving efficiency.

Benchstat

name                                          old time/op    new time/op    delta
_optParseExtractLogLevelFromLogLineLogfmt-10    1.25µs ± 1%    0.66µs ± 7%  -46.65%  (p=0.008 n=5+5)

name                                          old alloc/op   new alloc/op   delta
_optParseExtractLogLevelFromLogLineLogfmt-10    4.15kB ± 0%    0.02kB ± 0%  -99.61%  (p=0.008 n=5+5)

name                                          old allocs/op  new allocs/op  delta
_optParseExtractLogLevelFromLogLineLogfmt-10      5.00 ± 0%      1.00 ± 0%  -80.00%  (p=0.008 n=5+5)

name                                        old time/op    new time/op    delta
_optParseExtractLogLevelFromLogLineJson-10    1.20µs ± 0%    0.93µs ±20%  -22.34%  (p=0.008 n=5+5)

name                                        old alloc/op   new alloc/op   delta
_optParseExtractLogLevelFromLogLineJson-10      293B ± 0%       16B ± 0%     ~     (p=0.079 n=4+5)

name                                        old allocs/op  new allocs/op  delta
_optParseExtractLogLevelFromLogLineJson-10      6.00 ± 0%      1.00 ± 0%  -83.33%  (p=0.008 n=5+5)

This commit modifies the log parsing logic in the `distributor` package to improve performance. It introduces the use of the `unsafe` package to work with log strings as byte slices, reducing memory allocations and improving efficiency.
@cyriltovena cyriltovena requested a review from a team as a code owner June 14, 2024 20:02
@cyriltovena cyriltovena requested review from shantanualsi and removed request for a team June 14, 2024 20:02
@cyriltovena cyriltovena enabled auto-merge (squash) June 14, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants