Skip to content

Commit

Permalink
Disable (unstable) scheduler sampling profiler for OSS builds (#20832)
Browse files Browse the repository at this point in the history
* Disabled Scheduler sampling profiler for OSS builds
* Added missing conditional feature flag around profiling calls
  • Loading branch information
Brian Vaughn authored Feb 18, 2021
1 parent 8fa0ccc commit af3d526
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/scheduler/src/SchedulerFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__;
3 changes: 2 additions & 1 deletion packages/scheduler/src/__tests__/SchedulerProfiling-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 6 additions & 2 deletions packages/scheduler/src/forks/SchedulerDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions packages/scheduler/src/forks/SchedulerMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions packages/scheduler/src/forks/SchedulerNoDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions packages/scheduler/src/forks/SchedulerPostTaskOnly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit af3d526

Please sign in to comment.