Skip to content

Commit

Permalink
RN: Remove React Stack Systrace Logic
Browse files Browse the repository at this point in the history
Reviewed By: sophiebits

Differential Revision: D7027263

fbshipit-source-id: f4eb3fab402eda337f464e4ebb0771202a9b93f2
  • Loading branch information
yungsters authored and facebook-github-bot committed Feb 20, 2018
1 parent 4454fdc commit 973ef97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Libraries/Core/InitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (!global.process.env.NODE_ENV) {
// Setup the Systrace profiling hooks if necessary
if (global.__RCTProfileIsProfiling) {
const Systrace = require('Systrace');
Systrace.installReactHook(true);
Systrace.installReactHook();
Systrace.setEnabled(true);
}

Expand Down
61 changes: 5 additions & 56 deletions Libraries/Performance/Systrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ let _asyncCookie = 0;
const _markStack = [];
let _markStackIndex = -1;
let _canInstallReactHook = false;
let _useFiber = false;

// Implements a subset of User Timing API necessary for React measurements.
// https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API
Expand Down Expand Up @@ -98,54 +97,13 @@ const userTimingPolyfill = __DEV__ ? {
},
} : null;

// A hook to get React Stack markers in Systrace.
const reactDebugToolHook = __DEV__ ? {
onBeforeMountComponent(debugID) {
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.mountComponent(${displayName})`);
},
onMountComponent(debugID) {
Systrace.endEvent();
},
onBeforeUpdateComponent(debugID) {
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.updateComponent(${displayName})`);
},
onUpdateComponent(debugID) {
Systrace.endEvent();
},
onBeforeUnmountComponent(debugID) {
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.unmountComponent(${displayName})`);
},
onUnmountComponent(debugID) {
Systrace.endEvent();
},
onBeginLifeCycleTimer(debugID, timerType) {
const ReactComponentTreeHook = require('ReactGlobalSharedState').ReactComponentTreeHook;
const displayName = ReactComponentTreeHook.getDisplayName(debugID);
Systrace.beginEvent(`${displayName}.${timerType}()`);
},
onEndLifeCycleTimer(debugID, timerType) {
Systrace.endEvent();
},
} : null;

const Systrace = {
installReactHook(useFiber: boolean) {
installReactHook() {
if (_enabled) {
if (__DEV__) {
if (useFiber) {
global.performance = userTimingPolyfill;
} else {
require('ReactDebugTool').addHook(reactDebugToolHook);
}
global.performance = userTimingPolyfill;
}
}
_useFiber = useFiber;
_canInstallReactHook = true;
},

Expand All @@ -158,17 +116,8 @@ const Systrace = {
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JS_VM_CALLS);
}
if (_canInstallReactHook) {
if (_useFiber) {
if (enabled && global.performance === undefined) {
global.performance = userTimingPolyfill;
}
} else {
const ReactDebugTool = require('ReactDebugTool');
if (enabled) {
ReactDebugTool.addHook(reactDebugToolHook);
} else {
ReactDebugTool.removeHook(reactDebugToolHook);
}
if (enabled && global.performance === undefined) {
global.performance = userTimingPolyfill;
}
}
}
Expand Down Expand Up @@ -240,7 +189,7 @@ const Systrace = {
attachToRelayProfiler(relayProfiler: RelayProfiler) {
relayProfiler.attachProfileHandler('*', (name, state?) => {
if (state != null && state.queryName !== undefined) {
name += '_' + state.queryName
name += '_' + state.queryName;
}
const cookie = Systrace.beginAsyncEvent(name);
return () => {
Expand Down

0 comments on commit 973ef97

Please sign in to comment.