From d91e00ab45f50451fa8c4caefe9d474925dcf2f0 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Wed, 14 Jan 2026 11:39:44 -0800 Subject: [PATCH 1/2] Reduce impact of tracing layer enabled with no tracers - Added calls to check the existence of active tracers and callbacks before generating tracing such that the impact of tracing is reduced until enabled. Signed-off-by: Neil R. Spruit --- source/layers/tracing/tracing_imp.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/layers/tracing/tracing_imp.h b/source/layers/tracing/tracing_imp.h index 9b42ccf6..c80960aa 100644 --- a/source/layers/tracing/tracing_imp.h +++ b/source/layers/tracing/tracing_imp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2025 Intel Corporation + * Copyright (C) 2020-2026 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -170,7 +170,7 @@ class APITracerCallbackDataImp { currentTracerArray = \ (tracing_layer::tracer_array_t *) \ tracing_layer::pGlobalAPITracerContextImp->getActiveTracersList(); \ - if (currentTracerArray) { \ + if (currentTracerArray && currentTracerArray->tracerArrayCount > 0) { \ for (size_t i = 0; i < currentTracerArray->tracerArrayCount; i++) { \ tracerType prologueCallbackPtr; \ tracerType epilogue_callback_ptr; \ @@ -201,7 +201,7 @@ class APITracerCallbackDataImp { currentTracerArray = \ (tracing_layer::tracer_array_t *) \ tracing_layer::pGlobalAPITracerContextImp->getActiveTracersList(); \ - if (currentTracerArray) { \ + if (currentTracerArray && currentTracerArray->tracerArrayCount > 0) { \ for (size_t i = 0; i < currentTracerArray->tracerArrayCount; i++){ \ tracerType prologueCallbackPtr; \ tracerType epilogue_callback_ptr; \ @@ -237,6 +237,15 @@ APITracerWrapperImp(TFunction_pointer zeApiPtr, TParams paramsStruct, TRet ret {}; std::vector> *callbacks_prologs = &prologCallbacks; + std::vector> *callbacksEpilogs = + &epilogCallbacks; + // Fast path: if no callbacks are registered, directly call the API + if (callbacks_prologs->empty() && callbacksEpilogs->empty()) { + ret = zeApiPtr(args...); + tracing_layer::tracingInProgress = 0; + tracing_layer::pGlobalAPITracerContextImp->releaseActivetracersList(); + return ret; + } std::vector ppTracerInstanceUserData; ppTracerInstanceUserData.resize(callbacks_prologs->size()); @@ -248,8 +257,6 @@ APITracerWrapperImp(TFunction_pointer zeApiPtr, TParams paramsStruct, &ppTracerInstanceUserData[i]); } ret = zeApiPtr(args...); - std::vector> *callbacksEpilogs = - &epilogCallbacks; for (size_t i = 0; i < callbacksEpilogs->size(); i++) { if (callbacksEpilogs->at(i).current_api_callback != nullptr) callbacksEpilogs->at(i).current_api_callback( From b6fae07a2c262439ceb4b6e882957682bb2a46a7 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Thu, 5 Feb 2026 09:36:58 -0800 Subject: [PATCH 2/2] Simplify the tracer array count check Signed-off-by: Neil R. Spruit --- source/layers/tracing/tracing_imp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/layers/tracing/tracing_imp.h b/source/layers/tracing/tracing_imp.h index c80960aa..c03be8be 100644 --- a/source/layers/tracing/tracing_imp.h +++ b/source/layers/tracing/tracing_imp.h @@ -170,7 +170,7 @@ class APITracerCallbackDataImp { currentTracerArray = \ (tracing_layer::tracer_array_t *) \ tracing_layer::pGlobalAPITracerContextImp->getActiveTracersList(); \ - if (currentTracerArray && currentTracerArray->tracerArrayCount > 0) { \ + if (currentTracerArray && currentTracerArray->tracerArrayCount) { \ for (size_t i = 0; i < currentTracerArray->tracerArrayCount; i++) { \ tracerType prologueCallbackPtr; \ tracerType epilogue_callback_ptr; \ @@ -201,7 +201,7 @@ class APITracerCallbackDataImp { currentTracerArray = \ (tracing_layer::tracer_array_t *) \ tracing_layer::pGlobalAPITracerContextImp->getActiveTracersList(); \ - if (currentTracerArray && currentTracerArray->tracerArrayCount > 0) { \ + if (currentTracerArray && currentTracerArray->tracerArrayCount) { \ for (size_t i = 0; i < currentTracerArray->tracerArrayCount; i++){ \ tracerType prologueCallbackPtr; \ tracerType epilogue_callback_ptr; \