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

Improve performance of metric expression matcher #5864

Merged
merged 1 commit into from
Oct 21, 2021

Conversation

tigrannajaryan
Copy link
Member

@tigrannajaryan tigrannajaryan commented Oct 21, 2021

Refactored env struct to avoid creating closure functions for every
expression evaluation operation. This reduced the allocations and
increased the speed.

Improvements:

$ benchstat old.txt new.txt
name          old time/op    new time/op    delta
ExprFilter-8     537µs ± 2%     476µs ± 1%  -11.33%  (p=0.000 n=9+10)

name          old alloc/op   new alloc/op   delta
ExprFilter-8     151kB ± 0%     102kB ± 0%  -32.43%  (p=0.000 n=8+8)

name          old allocs/op  new allocs/op  delta
ExprFilter-8     8.44k ± 0%     6.39k ± 0%  -24.24%  (p=0.000 n=10+10)

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Awesome improvement! Just a couple of suggestions.

processor/filterprocessor/README.md Outdated Show resolved Hide resolved
internal/coreinternal/processor/filterexpr/matcher.go Outdated Show resolved Hide resolved
@tigrannajaryan
Copy link
Member Author

Based on @bogdandrutu 's comment on #5862 I will redo this to only include perf improvements.

Refactored env struct to avoid creating closure functions for every
expression evaluation operation. This reduced the allocations and
increased the speed.

Improvements:

$ benchstat old.txt new.txt
name          old time/op    new time/op    delta
ExprFilter-8     537µs ± 2%     476µs ± 1%  -11.33%  (p=0.000 n=9+10)

name          old alloc/op   new alloc/op   delta
ExprFilter-8     151kB ± 0%     102kB ± 0%  -32.43%  (p=0.000 n=8+8)

name          old allocs/op  new allocs/op  delta
ExprFilter-8     8.44k ± 0%     6.39k ± 0%  -24.24%  (p=0.000 n=10+10)
@tigrannajaryan
Copy link
Member Author

Updated to only be about perf improvement (instead of being stacked on top of another PR).

@bogdandrutu bogdandrutu merged commit 9ceb2ff into open-telemetry:main Oct 21, 2021
@tigrannajaryan tigrannajaryan deleted the expr-perf-improve branch October 22, 2021 00:24
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.

4 participants