You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on Supavisor performance and our benchmarking shows that TelemetryMetricsPrometheusCore is main culprit of slowness. It is called in very tight loop (via :telemetry obviously) and it shows that tags filtering is substantial part of handling event.
I have run simple Benchee script to check out whether it would be possible to speed it up:
Results show, that Enum.reject/2 approach disfavours happy path:
Operating System: macOS
CPU Information: Apple M3 Pro
Number of Available Cores: 12
Available memory: 36 GB
Elixir 1.17.1
Erlang 26.2.5
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 0 ns
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 21 s
Benchmarking matching new ...
Benchmarking matching new_2 ...
Benchmarking matching old ...
Name ips average deviation median 99th %
matching new_2 4.57 M 218.79 ns ±9601.91% 166 ns 833 ns
matching new 3.53 M 283.58 ns ±6234.59% 250 ns 375 ns
matching old 2.41 M 414.93 ns ±4529.68% 375 ns 500 ns
Comparison:
matching new_2 4.57 M
matching new 3.53 M - 1.30x slower +64.78 ns
matching old 2.41 M - 1.90x slower +196.14 ns
Operating System: macOS
CPU Information: Apple M3 Pro
Number of Available Cores: 12
Available memory: 36 GB
Elixir 1.17.1
Erlang 26.2.5
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 0 ns
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 21 s
Benchmarking missing new ...
Benchmarking missing new_2 ...
Benchmarking missing old ...
Name ips average deviation median 99th %
missing old 5.74 M 174.27 ns ±9073.23% 166 ns 291 ns
missing new_2 1.31 M 760.70 ns ±2264.45% 709 ns 917 ns
missing new 1.29 M 772.91 ns ±2281.40% 709 ns 958 ns
Comparison:
missing old 5.74 M
missing new_2 1.31 M - 4.36x slower +586.43 ns
missing new 1.29 M - 4.44x slower +598.64 ns
This is rather odd, as metrics library should rather optimise for happy path as we can assume that most of the time (ideally - always) we will see all metadata available (also, there may be some optimisations. For example length(tags) can be cached to not recompute it each time we compute metrics. Maybe there are some other optimisations that I haven't thought about, but as shown above, we can do quite better on happy path.
The text was updated successfully, but these errors were encountered:
I am working on Supavisor performance and our benchmarking shows that
TelemetryMetricsPrometheusCore
is main culprit of slowness. It is called in very tight loop (via:telemetry
obviously) and it shows that tags filtering is substantial part of handling event.I have run simple Benchee script to check out whether it would be possible to speed it up:
Results show, that
Enum.reject/2
approach disfavours happy path:This is rather odd, as metrics library should rather optimise for happy path as we can assume that most of the time (ideally - always) we will see all metadata available (also, there may be some optimisations. For example
length(tags)
can be cached to not recompute it each time we compute metrics. Maybe there are some other optimisations that I haven't thought about, but as shown above, we can do quite better on happy path.The text was updated successfully, but these errors were encountered: