Skip to content
Snippets Groups Projects
Commit 2ecff019 authored by Doug Evans's avatar Doug Evans Committed by CQ bot account: commit-bot@chromium.org
Browse files

[trace-engine] Add trace_acquire_context_for_category_cached()

This function is a variation of trace_acquire_context_for_category
that adds call-site caching of enabled/disabled state.

The first call to a TRACE_*() macro invokes trace_acquire_context_for_category,
regardless of whether tracing is enabled or not, same as before.
But now the enabled/disabled state of that lookup is cached for each call
site, allowing subsequent calls to just do a load/test. This greatly
speeds up the disabled case, both when tracing is off and when tracing is
on but the category hasn't been selected by the user.

Benchmark timings on a NUC:
TRACE_DURATION_BEGIN macro with 0 arguments:
 Before:
  Tracing off: 8ns per call
  Tracing on, category disabled: 41ns per call
  Tracing on, category enabled: 107ns
 After:
  Tracing off: 5ns per call
  Tracing on, category disabled: 5ns per call
  Tracing on, category enabled: 112ns

PT-2877 #done

Tested: CQ

Change-Id: I9f454031e15c27c05da64dceb60dd472b7b76390
parent 0f7ca793
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment