From 2d7356193f2438ee53bc02037fed20bf57630e02 Mon Sep 17 00:00:00 2001 From: Vitali Zaidman Date: Wed, 12 Mar 2025 06:49:54 -0700 Subject: [PATCH] report high ping and event loop delay even when debug is not enabled (#49976) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49976 Changelog: [General][Internal] Reviewed By: robhogan Differential Revision: D70962431 fbshipit-source-id: 74c0fcc67e1785f213629db235fbf18bcd5a5f95 --- .../src/inspector-proxy/InspectorProxy.js | 17 +++++++---------- .../dev-middleware/src/types/EventReporter.js | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js b/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js index 9eb897b62f6..4d17955b828 100644 --- a/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js +++ b/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js @@ -48,7 +48,7 @@ const PROXY_IDLE_TIMEOUT_MS = 10000; const EVENT_LOOP_PERF_MEASUREMENT_MS = 5000; const MIN_PING_TO_REPORT = 500; -const MIN_EVENT_LOOP_DELAY_TO_REPORT = 500; +const MIN_EVENT_LOOP_DELAY_PERCENT_TO_REPORT = 20; const INTERNAL_ERROR_CODE = 1011; @@ -422,25 +422,22 @@ export default class InspectorProxy implements InspectorProxyQueries { const eventLoopUtilization = Math.floor(eluEnd.utilization * 100); // The max % of continious time between eluStart and eluEnd where event loop was busy - const maxEventLoopDelay = Math.floor( + const maxEventLoopDelayPercent = Math.floor( (h.max / 1e6 / EVENT_LOOP_PERF_MEASUREMENT_MS) * 100, ); - if ( - debug.enabled && - maxEventLoopDelay >= MIN_EVENT_LOOP_DELAY_TO_REPORT - ) { + if (maxEventLoopDelayPercent >= MIN_EVENT_LOOP_DELAY_PERCENT_TO_REPORT) { debug( - "High event loop delay in the last %ds- event loop utilization='%d%' max event loop delay='%d%'", + "[perf] high event loop delay in the last %ds- event loop utilization='%d%' max event loop delay percent='%d%'", EVENT_LOOP_PERF_MEASUREMENT_MS / 1000, eventLoopUtilization, - maxEventLoopDelay, + maxEventLoopDelayPercent, ); this.#eventReporter?.logEvent({ type: 'high_event_loop_delay', eventLoopUtilization, - maxEventLoopDelay, + maxEventLoopDelayPercent, duration: EVENT_LOOP_PERF_MEASUREMENT_MS, ...debuggerSessionIDs, }); @@ -626,7 +623,7 @@ export default class InspectorProxy implements InspectorProxyQueries { socket.on('pong', () => { const roundtripDuration = Date.now() - latestPingMs; - if (debug.enabled && roundtripDuration >= MIN_PING_TO_REPORT) { + if (roundtripDuration >= MIN_PING_TO_REPORT) { const isIdle = this.#isIdle(); debug( diff --git a/packages/dev-middleware/src/types/EventReporter.js b/packages/dev-middleware/src/types/EventReporter.js index 8afe42c0bf8..91d08a28f10 100644 --- a/packages/dev-middleware/src/types/EventReporter.js +++ b/packages/dev-middleware/src/types/EventReporter.js @@ -115,7 +115,7 @@ export type ReportableEvent = | { type: 'high_event_loop_delay', eventLoopUtilization: number, - maxEventLoopDelay: number, + maxEventLoopDelayPercent: number, duration: number, ...DebuggerSessionIDs, };