Skip to content
Snippets Groups Projects
Forked from hexang-mirrors / Fuchsia OS
Source project has a limited visibility.
user avatar
Doug Evans authored
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
36d22dc2
Name Last commit Last update