From 1ec1785e322290d35d05dcb5b5952b2c80176747 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Wed, 16 Nov 2022 12:58:42 -0800 Subject: [PATCH] Unify SystraceSection.h implementation (#35353) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35353 Unfortunately we have 2 different definitions of SystraceSection.h - xplat/js/react-native-github/ReactCommon/cxxreact/SystraceSection.h - xplat/js/react-native-github/ReactCommon/react/renderer/debug/SystraceSection.h The first one is the Old Arch one and the second one is the New Arch one. As we first step, we unify the implementation Changelog: [Internal] Reviewed By: rshest Differential Revision: D41307049 fbshipit-source-id: a9eb854dfcf49f87ad81fd9cc8dbe51648ecd209 --- .../react/renderer/debug/SystraceSection.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/debug/SystraceSection.h b/ReactCommon/react/renderer/debug/SystraceSection.h index d3ccd0b4827e29..46996ff2bb74d9 100644 --- a/ReactCommon/react/renderer/debug/SystraceSection.h +++ b/ReactCommon/react/renderer/debug/SystraceSection.h @@ -14,6 +14,16 @@ namespace facebook { namespace react { +/** + * Allow providing an fbsystrace implementation that can short-circuit out + * quickly and can throttle too frequent events so we can get useful traces even + * if rendering etc. is spinning. For throttling we'll need file/line info so we + * use a macro. + */ +#if defined(WITH_LOOM_TRACE) +#define SystraceSection \ + static constexpr const char systraceSectionFile[] = __FILE__; \ + fbsystrace::FbSystraceSection /** * This is a convenience class to avoid lots of verbose profiling * #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will @@ -23,7 +33,7 @@ namespace react { * different values in different files, there is no inconsistency in the sizes * of defined symbols. */ -#ifdef WITH_FBSYSTRACE +#elif defined(WITH_FBSYSTRACE) struct ConcreteSystraceSection { public: template @@ -41,8 +51,8 @@ struct DummySystraceSection { public: template explicit DummySystraceSection( - const char *name, - ConvertsToStringPiece &&...args) {} + __unused const char *name, + __unused ConvertsToStringPiece &&...args) {} }; using SystraceSection = DummySystraceSection; #endif