From 027dafb02414eac0160970b982434667229b0ae9 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 18 Feb 2021 11:06:53 -0500 Subject: [PATCH] Disable (unstable) scheduler sampling profiler for OSS builds (#20832) * Disabled Scheduler sampling profiler for OSS builds * Added missing conditional feature flag around profiling calls --- packages/scheduler/src/SchedulerFeatureFlags.js | 2 +- .../scheduler/src/__tests__/SchedulerProfiling-test.js | 3 ++- packages/scheduler/src/forks/SchedulerDOM.js | 8 ++++++-- packages/scheduler/src/forks/SchedulerMock.js | 8 ++++++-- packages/scheduler/src/forks/SchedulerNoDOM.js | 8 ++++++-- packages/scheduler/src/forks/SchedulerPostTaskOnly.js | 8 ++++++-- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/scheduler/src/SchedulerFeatureFlags.js b/packages/scheduler/src/SchedulerFeatureFlags.js index bd47c158313cd..e18c34d5a0297 100644 --- a/packages/scheduler/src/SchedulerFeatureFlags.js +++ b/packages/scheduler/src/SchedulerFeatureFlags.js @@ -8,7 +8,7 @@ export const enableSchedulerDebugging = false; export const enableIsInputPending = false; -export const enableProfiling = __PROFILE__; +export const enableProfiling = false; // TODO: enable to fix https://github.com/facebook/react/issues/20756. export const enableSetImmediate = __VARIANT__; diff --git a/packages/scheduler/src/__tests__/SchedulerProfiling-test.js b/packages/scheduler/src/__tests__/SchedulerProfiling-test.js index cf9f9c5ea8cd8..b7828b14487fd 100644 --- a/packages/scheduler/src/__tests__/SchedulerProfiling-test.js +++ b/packages/scheduler/src/__tests__/SchedulerProfiling-test.js @@ -44,7 +44,8 @@ function priorityLevelToString(priorityLevel) { } describe('Scheduler', () => { - if (!__PROFILE__) { + const {enableProfiling} = require('scheduler/src/SchedulerFeatureFlags'); + if (!enableProfiling) { // The tests in this suite only apply when profiling is on it('profiling APIs are not available', () => { Scheduler = require('scheduler'); diff --git a/packages/scheduler/src/forks/SchedulerDOM.js b/packages/scheduler/src/forks/SchedulerDOM.js index 6c7dc446c9a6a..eb70af64d7d6b 100644 --- a/packages/scheduler/src/forks/SchedulerDOM.js +++ b/packages/scheduler/src/forks/SchedulerDOM.js @@ -219,12 +219,16 @@ function workLoop(hasTimeRemaining, initialTime) { currentTask.callback = null; currentPriorityLevel = currentTask.priorityLevel; const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; - markTaskRun(currentTask, currentTime); + if (enableProfiling) { + markTaskRun(currentTask, currentTime); + } const continuationCallback = callback(didUserCallbackTimeout); currentTime = getCurrentTime(); if (typeof continuationCallback === 'function') { currentTask.callback = continuationCallback; - markTaskYield(currentTask, currentTime); + if (enableProfiling) { + markTaskYield(currentTask, currentTime); + } } else { if (enableProfiling) { markTaskCompleted(currentTask, currentTime); diff --git a/packages/scheduler/src/forks/SchedulerMock.js b/packages/scheduler/src/forks/SchedulerMock.js index 9ec5504b243f4..5d7b8c945bb6a 100644 --- a/packages/scheduler/src/forks/SchedulerMock.js +++ b/packages/scheduler/src/forks/SchedulerMock.js @@ -183,12 +183,16 @@ function workLoop(hasTimeRemaining, initialTime) { currentTask.callback = null; currentPriorityLevel = currentTask.priorityLevel; const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; - markTaskRun(currentTask, currentTime); + if (enableProfiling) { + markTaskRun(currentTask, currentTime); + } const continuationCallback = callback(didUserCallbackTimeout); currentTime = getCurrentTime(); if (typeof continuationCallback === 'function') { currentTask.callback = continuationCallback; - markTaskYield(currentTask, currentTime); + if (enableProfiling) { + markTaskYield(currentTask, currentTime); + } } else { if (enableProfiling) { markTaskCompleted(currentTask, currentTime); diff --git a/packages/scheduler/src/forks/SchedulerNoDOM.js b/packages/scheduler/src/forks/SchedulerNoDOM.js index e1a4a5e946d35..35bf3bfbc940d 100644 --- a/packages/scheduler/src/forks/SchedulerNoDOM.js +++ b/packages/scheduler/src/forks/SchedulerNoDOM.js @@ -185,12 +185,16 @@ function workLoop(hasTimeRemaining, initialTime) { currentTask.callback = null; currentPriorityLevel = currentTask.priorityLevel; const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; - markTaskRun(currentTask, currentTime); + if (enableProfiling) { + markTaskRun(currentTask, currentTime); + } const continuationCallback = callback(didUserCallbackTimeout); currentTime = getCurrentTime(); if (typeof continuationCallback === 'function') { currentTask.callback = continuationCallback; - markTaskYield(currentTask, currentTime); + if (enableProfiling) { + markTaskYield(currentTask, currentTime); + } } else { if (enableProfiling) { markTaskCompleted(currentTask, currentTime); diff --git a/packages/scheduler/src/forks/SchedulerPostTaskOnly.js b/packages/scheduler/src/forks/SchedulerPostTaskOnly.js index 8ee96e2d16e54..9f5674e24b2da 100644 --- a/packages/scheduler/src/forks/SchedulerPostTaskOnly.js +++ b/packages/scheduler/src/forks/SchedulerPostTaskOnly.js @@ -210,12 +210,16 @@ function workLoop(hasTimeRemaining, initialTime) { currentTask.callback = null; currentPriorityLevel = currentTask.priorityLevel; const didUserCallbackTimeout = currentTask.expirationTime <= currentTime; - markTaskRun(currentTask, currentTime); + if (enableProfiling) { + markTaskRun(currentTask, currentTime); + } const continuationCallback = callback(didUserCallbackTimeout); currentTime = getCurrentTime(); if (typeof continuationCallback === 'function') { currentTask.callback = continuationCallback; - markTaskYield(currentTask, currentTime); + if (enableProfiling) { + markTaskYield(currentTask, currentTime); + } } else { if (enableProfiling) { markTaskCompleted(currentTask, currentTime);