[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
Showing
- system/ulib/trace-engine/ddk-exports.ld 2 additions, 0 deletionssystem/ulib/trace-engine/ddk-exports.ld
- system/ulib/trace-engine/engine.cpp 237 additions, 2 deletionssystem/ulib/trace-engine/engine.cpp
- system/ulib/trace-engine/include/trace-engine/instrumentation.h 54 additions, 2 deletions.../ulib/trace-engine/include/trace-engine/instrumentation.h
- system/ulib/trace/include/trace/internal/event_internal.h 18 additions, 12 deletionssystem/ulib/trace/include/trace/internal/event_internal.h
- system/utest/trace/engine_tests.cpp 159 additions, 2 deletionssystem/utest/trace/engine_tests.cpp
- system/utest/trace/fixture.cpp 55 additions, 26 deletionssystem/utest/trace/fixture.cpp
- system/utest/trace/fixture.h 2 additions, 0 deletionssystem/utest/trace/fixture.h
Loading
Please register or sign in to comment