From 53a2742e13f55c3e412bde2ac7b56f6950e44b17 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Thu, 2 Nov 2023 19:41:46 -0700 Subject: [PATCH] Remove web performance logging from GlobalPerformanceLogger (#41299) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41299 ## Changelog: It makes sense to keep Web Performance logging mechanism separate from the GlobalPerformanceLogger, removing. Reviewed By: rubennorte Differential Revision: D50930312 fbshipit-source-id: 3b76ff28eae8c5a2bf41faceb33cf188d8318610 --- .../Utilities/createPerformanceLogger.js | 64 +------------------ 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js index 092877c3570630..1849d04f452faa 100644 --- a/packages/react-native/Libraries/Utilities/createPerformanceLogger.js +++ b/packages/react-native/Libraries/Utilities/createPerformanceLogger.js @@ -22,10 +22,6 @@ const _cookies: {[key: string]: number, ...} = {}; const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`; -// This is the prefix for optional logging points/timespans as marks/measures via Performance API, -// used to separate these internally from other marks/measures -const WEB_PERFORMANCE_PREFIX = 'web_perf_'; - export const getCurrentTimestamp: () => number = global.nativeQPLTimestamp ?? (() => global.performance.now()); @@ -35,41 +31,6 @@ class PerformanceLogger implements IPerformanceLogger { _points: {[key: string]: ?number} = {}; _pointExtras: {[key: string]: ?Extras, ...} = {}; _closed: boolean = false; - _isLoggingForWebPerformance: boolean = false; - - // When `isLoggingForWebPerformance` is true, the data will be additionally logged via - // Performance.mark/measure API, if available. - constructor(isLoggingForWebPerformance?: boolean) { - this._isLoggingForWebPerformance = isLoggingForWebPerformance === true; - } - - // NOTE: The Performance.mark/measure calls are wrapped here to ensure that - // we are safe from the cases when the global 'peformance' object is still not yet defined. - // It is only necessary in this file because of potential race conditions in the initialization - // order between 'createPerformanceLogger' and 'setUpPerformance'. - // - // In most of the other cases this kind of check for `performance` being defined - // wouldn't be necessary. - _performanceMark(key: string, startTime: number) { - if (this._isLoggingForWebPerformance) { - global.performance?.mark?.(key, { - startTime, - }); - } - } - - _performanceMeasure( - key: string, - start: number | string, - end: number | string, - ) { - if (this._isLoggingForWebPerformance) { - global.performance?.measure?.(key, { - start, - end, - }); - } - } addTimespan( key: string, @@ -101,12 +62,6 @@ class PerformanceLogger implements IPerformanceLogger { startExtras, endExtras, }; - - this._performanceMeasure( - `${WEB_PERFORMANCE_PREFIX}_${key}`, - startTime, - endTime, - ); } append(performanceLogger: IPerformanceLogger) { @@ -221,8 +176,6 @@ class PerformanceLogger implements IPerformanceLogger { if (extras) { this._pointExtras[key] = extras; } - - this._performanceMark(`${WEB_PERFORMANCE_PREFIX}_${key}`, timestamp); } removeExtra(key: string): ?ExtraValue { @@ -284,11 +237,6 @@ class PerformanceLogger implements IPerformanceLogger { if (PRINT_TO_CONSOLE) { infoLog('PerformanceLogger.js', 'start: ' + key); } - - this._performanceMark( - `${WEB_PERFORMANCE_PREFIX}_timespan_start_${key}`, - timestamp, - ); } stopTimespan( @@ -334,12 +282,6 @@ class PerformanceLogger implements IPerformanceLogger { Systrace.endAsyncEvent(key, _cookies[key]); delete _cookies[key]; } - - this._performanceMeasure( - `${WEB_PERFORMANCE_PREFIX}_${key}`, - `${WEB_PERFORMANCE_PREFIX}_timespan_start_${key}`, - timestamp, - ); } } @@ -352,8 +294,6 @@ export type {Extras, ExtraValue, IPerformanceLogger, Timespan}; * various performance data such as timespans, points and extras. * The loggers need to have minimal overhead since they're used in production. */ -export default function createPerformanceLogger( - isLoggingForWebPerformance?: boolean, -): IPerformanceLogger { - return new PerformanceLogger(isLoggingForWebPerformance); +export default function createPerformanceLogger(): IPerformanceLogger { + return new PerformanceLogger(); }