Skip to content

Commit b769136

Browse files
authored
Clearing the old systrace plumbing to make way for improved one (#149)
1 parent f498222 commit b769136

File tree

5 files changed

+19
-189
lines changed

5 files changed

+19
-189
lines changed

ReactCommon/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ endif(WIN32)
4343

4444
if(ANDROID)
4545
set(SOURCES ${SOURCES}
46-
cxxreact/fbsystrace.cpp
4746
cxxreact/JSBigString.cpp
4847
)
4948
endif(ANDROID)

ReactCommon/cxxreact/Android.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ LOCAL_MODULE := reactnative
1111

1212
LOCAL_SRC_FILES := \
1313
CxxNativeModule.cpp \
14-
fbsystrace.cpp \
1514
Instance.cpp \
1615
JSBigString.cpp \
1716
JSBundleType.cpp \

ReactCommon/cxxreact/SystraceSection.h

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,40 @@
99
#include <fbsystrace.h>
1010
#endif
1111

12-
#include <string>
13-
#include <chrono>
14-
1512
namespace facebook {
1613
namespace react {
1714

18-
void SystraceBeginSection(const char* name, const char* args) noexcept;
19-
void SystraceEndSection(const char* name, const char* args, std::chrono::nanoseconds duration) noexcept;
20-
2115
/**
2216
* This is a convenience class to avoid lots of verbose profiling
2317
* #ifdefs. If WITH_FBSYSTRACE is not defined, the optimizer will
2418
* remove this completely. If it is defined, it will behave as
25-
* FbSystraceSection, with the right tag provided.
19+
* FbSystraceSection, with the right tag provided. Use two separate classes to
20+
* to ensure that the ODR rule isn't violated, that is, if WITH_FBSYSTRACE has
21+
* different values in different files, there is no inconsistency in the sizes
22+
* of defined symbols.
2623
*/
27-
struct SystraceSection {
28-
public:
29-
template<typename... ConvertsToStringPiece>
30-
explicit SystraceSection(const char* name, ConvertsToStringPiece&&... args)
3124
#ifdef WITH_FBSYSTRACE
32-
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, std::forward<ConvertsToStringPiece>(args)...)
33-
#elif defined(WITH_OFFICE_TRACING)
34-
: m_start(std::chrono::steady_clock::now())
35-
, m_name{name}
36-
, m_args{concatArgs(std::forward<ConvertsToStringPiece>(args)...)}
37-
{
38-
SystraceBeginSection(m_name.c_str(), m_args.c_str());
39-
}
40-
41-
~SystraceSection()
42-
{
43-
SystraceEndSection(m_name.c_str(), m_args.c_str(), std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now()-m_start));
44-
}
45-
46-
private:
47-
std::string concatArgs() noexcept
48-
{
49-
return "";
50-
}
51-
25+
struct ConcreteSystraceSection {
26+
public:
5227
template<typename... ConvertsToStringPiece>
53-
std::string concatArgs(const char* name, const std::string& value, ConvertsToStringPiece&&... rest) noexcept
54-
{
55-
return std::string(name) + "=" + value + "|" + concatArgs(std::forward<ConvertsToStringPiece>(rest)...);
56-
}
57-
#else
28+
explicit
29+
ConcreteSystraceSection(__unused const char* name, __unused ConvertsToStringPiece&&... args)
30+
: m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...)
5831
{}
59-
#endif
6032

61-
#ifdef WITH_FBSYSTRACE
33+
private:
6234
fbsystrace::FbSystraceSection m_section;
63-
#elif defined(WITH_OFFICE_TRACING)
64-
std::string m_name;
65-
std::string m_args;
66-
std::chrono::time_point<std::chrono::steady_clock> m_start;
67-
#endif
6835
};
69-
70-
// Some placeholder definitions to satisfy linker.. as we are enabling some unintented code paths when enabling these macros.
71-
#if defined(WITH_OFFICE_TRACING)
72-
#define TRACE_TAG_REACT_CXX_BRIDGE 0
73-
struct FbSystraceAsyncFlow{
74-
static void begin(uint64_t /*tag*/, const char* /*name*/, int /*cookie*/) {}
75-
static void end(uint64_t /*tag*/, const char* /*name*/, int /*cookie*/) {}
36+
using SystraceSection = ConcreteSystraceSection;
37+
#else
38+
struct DummySystraceSection {
39+
public:
40+
template<typename... ConvertsToStringPiece>
41+
explicit
42+
DummySystraceSection(__unused const char* name, __unused ConvertsToStringPiece&&... args)
43+
{}
7644
};
45+
using SystraceSection = DummySystraceSection;
7746
#endif
7847

7948
}}

ReactCommon/cxxreact/fbsystrace.cpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

ReactCommon/cxxreact/fbsystrace.h

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)