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

ddtrace/tracer: Remove log.Debug from hot path (-2 allocs; -5% CPU) #1186

Merged
merged 4 commits into from Mar 8, 2022

Commits on Feb 28, 2022

  1. ddtrace/tracer: Remove log.Debug from hot path (-2 allocs; -5% CPU)

    The log.Debug function takes a ...interface{} argument which must be
    heap allocated. This is done even if debug logging is disabled, which
    is the common case. Add a log.DebugEnabled() function to check if it
    is enabled, and skip allocating this slice in the common case. The
    benchstat output from my laptop shows this saves about 5% CPU and
    2 allocs/call for the BenchmarkStartSpan microbenchmark.
    
    Normally, I do not like this sort of ugly log level check. However,
    given that StartSpan is widely called, and sometimes from hot code
    paths, this may be worthit.
    
    name         old time/op    new time/op    delta
    StartSpan-8    1.63µs ± 5%    1.55µs ±10%   -5.00%  (p=0.003 n=9+9)
    
    name         old alloc/op   new alloc/op   delta
    StartSpan-8    1.55kB ± 0%    1.52kB ± 0%   -2.08%  (p=0.000 n=10+8)
    
    name         old allocs/op  new allocs/op  delta
    StartSpan-8      19.0 ± 0%      17.0 ± 0%  -10.53%  (p=0.000 n=10+10)
    evanj committed Feb 28, 2022
    Copy the full SHA
    94c09c9 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2022

  1. Copy the full SHA
    f20206e View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2022

  1. Copy the full SHA
    cf6488d View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    e4fc6d0 View commit details
    Browse the repository at this point in the history