Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature flags for scheduler experiments #22105

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/scheduler/src/SchedulerFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
export const enableSchedulerDebugging = false;
export const enableIsInputPending = false;
export const enableProfiling = false;
export const enableIsInputPendingContinuous = false;
export const frameYieldMs = 5;
export const continuousYieldMs = 50;
15 changes: 8 additions & 7 deletions packages/scheduler/src/forks/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import {
enableSchedulerDebugging,
enableProfiling,
enableIsInputPending,
enableIsInputPendingContinuous,
frameYieldMs,
continuousYieldMs,
} from '../SchedulerFeatureFlags';

import {push, pop, peek} from '../SchedulerMinHeap';
Expand All @@ -36,8 +40,6 @@ import {
startLoggingProfilingEvents,
} from '../SchedulerProfiling';

import {enableIsInputPending} from '../SchedulerFeatureFlags';

let getCurrentTime;
const hasPerformanceNow =
typeof performance === 'object' && typeof performance.now === 'function';
Expand Down Expand Up @@ -98,7 +100,7 @@ const isInputPending =
? navigator.scheduling.isInputPending.bind(navigator.scheduling)
: null;

const continuousOptions = {includeContinuous: true};
const continuousOptions = {includeContinuous: enableIsInputPendingContinuous};

function advanceTimers(currentTime) {
// Check for tasks that are no longer delayed and add them to the queue.
Expand Down Expand Up @@ -427,9 +429,8 @@ let taskTimeoutID = -1;
// thread, like user events. By default, it yields multiple times per frame.
// It does not attempt to align with frame boundaries, since most tasks don't
// need to be frame aligned; for those that do, use requestAnimationFrame.
// TODO: Make these configurable
let frameInterval = 5;
const continuousInputInterval = 50;
let frameInterval = frameYieldMs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxInterval needs to be configurable, too. That's what will control how long, for example, network requests are blocked for.

const continuousInputInterval = continuousYieldMs;
const maxInterval = 300;
let startTime = -1;

Expand Down Expand Up @@ -506,7 +507,7 @@ function forceFrameRate(fps) {
frameInterval = Math.floor(1000 / fps);
} else {
// reset the framerate
frameInterval = 5;
frameInterval = frameYieldMs;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
export const enableIsInputPending = __VARIANT__;
export const enableSchedulerDebugging = __VARIANT__;
export const enableProfiling = __VARIANT__;
export const enableIsInputPendingContinuous = __VARIANT__;
export const frameYieldMs = 5;
export const continuousYieldMs = 50;
3 changes: 3 additions & 0 deletions packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const {
enableIsInputPending,
enableSchedulerDebugging,
enableProfiling: enableProfilingFeatureFlag,
enableIsInputPendingContinuous,
frameYieldMs,
continuousYieldMs,
} = dynamicFeatureFlags;

export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;