Skip to content

Commit 2d73561

Browse files
vzaidmanfacebook-github-bot
authored andcommitted
report high ping and event loop delay even when debug is not enabled (facebook#49976)
Summary: Pull Request resolved: facebook#49976 Changelog: [General][Internal] Reviewed By: robhogan Differential Revision: D70962431 fbshipit-source-id: 74c0fcc67e1785f213629db235fbf18bcd5a5f95
1 parent 6356a85 commit 2d73561

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/dev-middleware/src/inspector-proxy/InspectorProxy.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const PROXY_IDLE_TIMEOUT_MS = 10000;
4848
const EVENT_LOOP_PERF_MEASUREMENT_MS = 5000;
4949

5050
const MIN_PING_TO_REPORT = 500;
51-
const MIN_EVENT_LOOP_DELAY_TO_REPORT = 500;
51+
const MIN_EVENT_LOOP_DELAY_PERCENT_TO_REPORT = 20;
5252

5353
const INTERNAL_ERROR_CODE = 1011;
5454

@@ -422,25 +422,22 @@ export default class InspectorProxy implements InspectorProxyQueries {
422422
const eventLoopUtilization = Math.floor(eluEnd.utilization * 100);
423423

424424
// The max % of continious time between eluStart and eluEnd where event loop was busy
425-
const maxEventLoopDelay = Math.floor(
425+
const maxEventLoopDelayPercent = Math.floor(
426426
(h.max / 1e6 / EVENT_LOOP_PERF_MEASUREMENT_MS) * 100,
427427
);
428428

429-
if (
430-
debug.enabled &&
431-
maxEventLoopDelay >= MIN_EVENT_LOOP_DELAY_TO_REPORT
432-
) {
429+
if (maxEventLoopDelayPercent >= MIN_EVENT_LOOP_DELAY_PERCENT_TO_REPORT) {
433430
debug(
434-
"High event loop delay in the last %ds- event loop utilization='%d%' max event loop delay='%d%'",
431+
"[perf] high event loop delay in the last %ds- event loop utilization='%d%' max event loop delay percent='%d%'",
435432
EVENT_LOOP_PERF_MEASUREMENT_MS / 1000,
436433
eventLoopUtilization,
437-
maxEventLoopDelay,
434+
maxEventLoopDelayPercent,
438435
);
439436

440437
this.#eventReporter?.logEvent({
441438
type: 'high_event_loop_delay',
442439
eventLoopUtilization,
443-
maxEventLoopDelay,
440+
maxEventLoopDelayPercent,
444441
duration: EVENT_LOOP_PERF_MEASUREMENT_MS,
445442
...debuggerSessionIDs,
446443
});
@@ -626,7 +623,7 @@ export default class InspectorProxy implements InspectorProxyQueries {
626623
socket.on('pong', () => {
627624
const roundtripDuration = Date.now() - latestPingMs;
628625

629-
if (debug.enabled && roundtripDuration >= MIN_PING_TO_REPORT) {
626+
if (roundtripDuration >= MIN_PING_TO_REPORT) {
630627
const isIdle = this.#isIdle();
631628

632629
debug(

packages/dev-middleware/src/types/EventReporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export type ReportableEvent =
115115
| {
116116
type: 'high_event_loop_delay',
117117
eventLoopUtilization: number,
118-
maxEventLoopDelay: number,
118+
maxEventLoopDelayPercent: number,
119119
duration: number,
120120
...DebuggerSessionIDs,
121121
};

0 commit comments

Comments
 (0)