Skip to content

Commit 75a154b

Browse files
motiz88facebook-github-bot
authored andcommitted
Use timer type as Systrace identifier
Summary: Removes the use of `parseErrorStack` in `_allocateCallback`, which was used to determine which timer API was allocating the callback (for Systrace purposes). Instead, we now use the already-existing `type` argument, which achieves the exact same thing but is much faster than parsing the stack trace. Changelog: [General] [Fixed] - Reduce overhead of setting up timers in DEV Reviewed By: yinghuitan Differential Revision: D18233182 fbshipit-source-id: 190c0ffad8734cd889b790248e5a77cfb147454b
1 parent db4a7ae commit 75a154b

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

Libraries/Core/Timers/JSTimers.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const timerIDs: Array<?number> = [];
5959
let immediates: Array<number> = [];
6060
let requestIdleCallbacks: Array<number> = [];
6161
const requestIdleCallbackTimeouts: {[number]: number} = {};
62-
const identifiers: Array<null | {methodName: string}> = [];
6362

6463
let GUID = 1;
6564
let errors: ?Array<Error> = null;
@@ -81,14 +80,6 @@ function _allocateCallback(func: Function, type: JSTimerType): number {
8180
timerIDs[freeIndex] = id;
8281
callbacks[freeIndex] = func;
8382
types[freeIndex] = type;
84-
if (__DEV__) {
85-
const parseErrorStack = require('../Devtools/parseErrorStack');
86-
// TODO: (moti) T55685778 Use Error.captureStackTrace on Hermes
87-
const stack = parseErrorStack(new Error());
88-
if (stack) {
89-
identifiers[freeIndex] = stack[1]; // skip _allocateCallback's own stack frame
90-
}
91-
}
9283
return id;
9384
}
9485

@@ -122,8 +113,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) {
122113
}
123114

124115
if (__DEV__) {
125-
const identifier = identifiers[timerIndex] || {};
126-
Systrace.beginEvent('Systrace.callTimer: ' + identifier.methodName);
116+
Systrace.beginEvent('Systrace.callTimer: ' + type);
127117
}
128118

129119
// Clear the metadata
@@ -204,7 +194,6 @@ function _clearIndex(i: number) {
204194
timerIDs[i] = null;
205195
callbacks[i] = null;
206196
types[i] = null;
207-
identifiers[i] = null;
208197
}
209198

210199
function _freeCallback(timerID: number) {

0 commit comments

Comments
 (0)