Skip to content

Commit

Permalink
Unify SystraceSection.h implementation (facebook#35353)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
christophpurrer authored and facebook-github-bot committed Nov 16, 2022
1 parent 67b8e18 commit 1ec1785
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ReactCommon/react/renderer/debug/SystraceSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<systraceSectionFile, __LINE__>
/**
* This is a convenience class to avoid lots of verbose profiling
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
Expand All @@ -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 <typename... ConvertsToStringPiece>
Expand All @@ -41,8 +51,8 @@ struct DummySystraceSection {
public:
template <typename... ConvertsToStringPiece>
explicit DummySystraceSection(
const char *name,
ConvertsToStringPiece &&...args) {}
__unused const char *name,
__unused ConvertsToStringPiece &&...args) {}
};
using SystraceSection = DummySystraceSection;
#endif
Expand Down

0 comments on commit 1ec1785

Please sign in to comment.