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

[trace-engine] Work around a missed opimization in gcc

GCC doesn't do the desired optimization of the early exit test
in trace_acquire_context_for_category_cached(). This causes a stack
frame to be unnecessarily set up for the common case of tracing off.
Work around this by moving the tail of the function to a separate
no-inline function. GCC then does the desired optimization of
no stack frame for the early-exit test, and the tail call is just a branch.

Benchmark timings on a vim2 (little cores disabled):

TRACE_DURATION_BEGIN macro with 0 arguments (time per call):
 Before:
  Tracing off: 28ns
  Tracing on, category disabled: 28ns
  Tracing on, category enabled: 478ns
 After:
  Tracing off: 26ns
  Tracing on, category disabled: 26ns
  Tracing on, category enabled: 478ns

Note that while the speed improvement is measurable, another reason for
doing this is to remove the noise when trying to visualize how efficient
the tracing=off test is.

PT-84 #comment patch

Tested: CQ
Change-Id: I66753b3ad36a4fe50edb4926f85d571e3b0c9384
parent d3cb1e1d
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