dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

ddtrace/tracer: applyPPROFLabels: allocate max-length labels slice

Open evanj opened this issue 3 years ago • 0 comments

This reduces saves about 3 allocs/call when both the profiler hotspots and profiler endpoints features are enabled, since it will allocate one max-length slice, rather than growing it multiple times. For the gRPC interceptor benchmark, this saves about 5-10% CPU, as well as 3 allocs/call:

name                                                         old time/op    new time/op    delta
UnaryServerInterceptor/ok_no_metadata-8                        5.55µs ±38%    4.59µs ±13%  -17.35%  (p=0.017 n=10+9)
UnaryServerInterceptor/ok_with_metadata_no_parent-8            5.77µs ±18%    5.09µs ± 9%     ~     (p=0.052 n=10+10)
UnaryServerInterceptor/ok_with_metadata_with_parent-8          4.63µs ±17%    4.23µs ± 5%   -8.58%  (p=0.005 n=9+10)
UnaryServerInterceptor/ok_no_metadata_with_analytics_rate-8    5.30µs ±16%    4.79µs ±13%   -9.53%  (p=0.022 n=10+9)
UnaryServerInterceptor/error_no_metadata-8                     13.9µs ±26%    12.5µs ± 9%     ~     (p=0.133 n=10+9)
UnaryServerInterceptor/error_no_metadata_no_stack-8            6.90µs ±12%    6.46µs ±11%     ~     (p=0.055 n=8+10)

name                                                         old alloc/op   new alloc/op   delta
UnaryServerInterceptor/ok_no_metadata-8                        4.82kB ± 0%    4.59kB ± 0%   -4.70%  (p=0.000 n=10+9)
UnaryServerInterceptor/ok_with_metadata_no_parent-8            5.04kB ± 0%    4.81kB ± 0%   -4.46%  (p=0.000 n=10+10)
UnaryServerInterceptor/ok_with_metadata_with_parent-8          4.13kB ± 0%    3.91kB ± 0%   -5.41%  (p=0.000 n=8+9)
UnaryServerInterceptor/ok_no_metadata_with_analytics_rate-8    5.02kB ± 0%    4.81kB ± 0%   -4.15%  (p=0.000 n=10+10)
UnaryServerInterceptor/error_no_metadata-8                     11.4kB ± 0%    11.2kB ± 0%   -1.97%  (p=0.000 n=10+10)
UnaryServerInterceptor/error_no_metadata_no_stack-8            6.34kB ± 1%    6.11kB ± 0%   -3.59%  (p=0.000 n=10+9)

name                                                         old allocs/op  new allocs/op  delta
UnaryServerInterceptor/ok_no_metadata-8                          46.0 ± 0%      43.0 ± 0%   -6.52%  (p=0.000 n=10+10)
UnaryServerInterceptor/ok_with_metadata_no_parent-8              49.0 ± 0%      46.0 ± 0%   -6.12%  (p=0.000 n=10+10)
UnaryServerInterceptor/ok_with_metadata_with_parent-8            40.0 ± 0%      37.0 ± 0%   -7.50%  (p=0.000 n=10+10)
UnaryServerInterceptor/ok_no_metadata_with_analytics_rate-8      48.0 ± 0%      45.0 ± 0%   -6.25%  (p=0.000 n=10+10)
UnaryServerInterceptor/error_no_metadata-8                       69.0 ± 0%      66.0 ± 0%   -4.35%  (p=0.000 n=10+10)
UnaryServerInterceptor/error_no_metadata_no_stack-8              55.0 ± 0%      52.0 ± 0%   -5.45%  (p=0.000 n=10+10)

evanj avatar Mar 08 '22 16:03 evanj