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

[scheduler] Deadline object -> shouldYield #14025

Merged
merged 2 commits into from
Oct 30, 2018
Merged

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Oct 30, 2018

Instead of using a requestIdleCallback-style deadline object, expose a method Scheduler.shouldYield that returns true if there's a higher priority event in the queue.

Instead of using a requestIdleCallback-style deadline object, expose a
method Scheduler.shouldYield that returns true if there's a higher
priority event in the queue.
@sizebot
Copy link

sizebot commented Oct 30, 2018

React: size: -1.4%, gzip: -0.6%

ReactDOM: size: -0.1%, gzip: -0.0%

Details of bundled changes.

Comparing: 21a79a1...55da990

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js -0.7% -0.7% 95.03 KB 94.41 KB 24.94 KB 24.77 KB UMD_DEV
react.production.min.js -1.4% -0.6% 11.86 KB 11.7 KB 4.66 KB 4.63 KB UMD_PROD
react.profiling.min.js -1.2% -0.7% 14.02 KB 13.85 KB 5.18 KB 5.15 KB UMD_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.0% -0.1% 660.48 KB 660.27 KB 154.35 KB 154.25 KB UMD_DEV
react-dom.production.min.js -0.1% -0.0% 95.72 KB 95.64 KB 31.18 KB 31.17 KB UMD_PROD
react-dom.development.js -0.0% -0.1% 655.82 KB 655.55 KB 152.97 KB 152.86 KB NODE_DEV
react-dom.production.min.js -0.1% -0.1% 95.71 KB 95.64 KB 30.77 KB 30.73 KB NODE_PROD
ReactDOM-dev.js -0.0% -0.1% 673.12 KB 672.84 KB 153.62 KB 153.51 KB FB_WWW_DEV
ReactDOM-prod.js -0.0% -0.1% 287.46 KB 287.36 KB 52.79 KB 52.72 KB FB_WWW_PROD
react-dom.profiling.min.js -0.1% -0.1% 98.5 KB 98.43 KB 31.33 KB 31.3 KB NODE_PROFILING
ReactDOM-profiling.js -0.0% -0.1% 293.66 KB 293.57 KB 54.16 KB 54.09 KB FB_WWW_PROFILING
react-dom.profiling.min.js -0.1% -0.1% 98.43 KB 98.35 KB 31.82 KB 31.78 KB UMD_PROFILING

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -0.2% -0.2% 392.5 KB 391.89 KB 85.89 KB 85.73 KB UMD_DEV
react-test-renderer.production.min.js -0.3% -0.3% 54.34 KB 54.19 KB 16.64 KB 16.58 KB UMD_PROD
react-test-renderer.development.js -0.2% -0.2% 388.07 KB 387.47 KB 84.77 KB 84.61 KB NODE_DEV
react-test-renderer.production.min.js -0.2% 🔺+0.3% 54.04 KB 53.91 KB 16.42 KB 16.47 KB NODE_PROD
ReactTestRenderer-dev.js -0.2% -0.2% 392.17 KB 391.57 KB 83.52 KB 83.36 KB FB_WWW_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -0.1% -0.1% 377.85 KB 377.6 KB 81.69 KB 81.58 KB NODE_DEV
react-reconciler.production.min.js -0.1% 🔺+0.2% 52.82 KB 52.75 KB 15.84 KB 15.87 KB NODE_PROD
react-reconciler-persistent.development.js -0.1% -0.1% 376.46 KB 376.21 KB 81.13 KB 81.03 KB NODE_DEV
react-reconciler-persistent.production.min.js -0.1% 🔺+0.2% 52.83 KB 52.76 KB 15.84 KB 15.88 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.0% -0.1% 448.46 KB 448.24 KB 100.42 KB 100.34 KB UMD_DEV
react-art.production.min.js -0.1% -0.0% 88.13 KB 88.06 KB 27.04 KB 27.03 KB UMD_PROD
react-art.development.js -0.1% -0.1% 380.25 KB 379.97 KB 83.25 KB 83.16 KB NODE_DEV
react-art.production.min.js -0.1% 🔺+0.1% 53.09 KB 53.03 KB 16.28 KB 16.31 KB NODE_PROD
ReactART-dev.js -0.1% -0.1% 383.96 KB 383.67 KB 81.66 KB 81.55 KB FB_WWW_DEV
ReactART-prod.js -0.1% -0.2% 162.78 KB 162.67 KB 27.42 KB 27.37 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -0.1% -0.1% 510.41 KB 510.06 KB 112.65 KB 112.52 KB RN_FB_DEV
ReactNativeRenderer-prod.js -0.1% -0.2% 217.84 KB 217.56 KB 37.82 KB 37.73 KB RN_FB_PROD
ReactNativeRenderer-dev.js -0.1% -0.1% 510.12 KB 509.77 KB 112.57 KB 112.44 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -0.1% -0.2% 217.85 KB 217.58 KB 37.82 KB 37.73 KB RN_OSS_PROD
ReactFabric-dev.js -0.1% -0.1% 500.57 KB 500.22 KB 110.23 KB 110.1 KB RN_FB_DEV
ReactFabric-prod.js -0.1% -0.2% 210.31 KB 210.04 KB 36.41 KB 36.33 KB RN_FB_PROD
ReactFabric-dev.js -0.1% -0.1% 500.6 KB 500.25 KB 110.25 KB 110.12 KB RN_OSS_DEV
ReactFabric-prod.js -0.1% -0.2% 210.35 KB 210.07 KB 36.43 KB 36.35 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.1% -0.2% 223.19 KB 222.94 KB 39.12 KB 39.02 KB RN_OSS_PROFILING
ReactFabric-profiling.js -0.1% -0.2% 215.06 KB 214.8 KB 37.67 KB 37.58 KB RN_OSS_PROFILING
ReactNativeRenderer-profiling.js -0.1% -0.2% 223.17 KB 222.92 KB 39.11 KB 39.02 KB RN_FB_PROFILING
ReactFabric-profiling.js -0.1% -0.2% 215.02 KB 214.76 KB 37.65 KB 37.56 KB RN_FB_PROFILING

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler.development.js n/a n/a 0 B 19.17 KB 0 B 5.74 KB UMD_DEV
scheduler.production.min.js n/a n/a 0 B 3.16 KB 0 B 1.53 KB UMD_PROD
scheduler.development.js -2.8% -2.6% 22.19 KB 21.57 KB 6 KB 5.85 KB NODE_DEV
scheduler.production.min.js -3.1% -2.1% 4.81 KB 4.66 KB 1.87 KB 1.83 KB NODE_PROD
Scheduler-dev.js -2.9% -2.5% 22.45 KB 21.79 KB 6.04 KB 5.89 KB FB_WWW_DEV
Scheduler-prod.js -3.6% -2.1% 13.54 KB 13.06 KB 2.92 KB 2.86 KB FB_WWW_PROD

Generated by 🚫 dangerJS

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

I like this change 😄

function shouldYield() {
if (
scheduledCallbackTimeout === -1 ||
elapsedTimeInMs > scheduledCallbackTimeout
Copy link
Contributor

Choose a reason for hiding this comment

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

It's early and I'm probably being stupid, but shouldn't this be elapsedTimeInMs < scheduledCallbackTimeout ?

Edit Never mind. This is just saying that we should never yield if work has already timed out.


function performAsyncWork() {
try {
if (!shouldYieldToRenderer()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not initially obvious to me that dl.didTimeout is semantically equivalent to shouldYieldToRenderer() but I trust you here.

) {
performWorkOnRoot(
nextFlushedRoot,
nextFlushedExpirationTime,
currentRendererTime >= nextFlushedExpirationTime,
!(currentRendererTime >= nextFlushedExpirationTime),
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh, why ! >= rather than <?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Planned to change it once I proved it worked, then forgot :D

expectedNumberOfYields !== -1 &&
yieldedValues.length >= expectedNumberOfYields
) {
// We at least as many values as expected. Stop rendering.
Copy link
Contributor

Choose a reason for hiding this comment

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

"We yielded at least as many"?

@acdlite acdlite merged commit 8c67bbf into facebook:master Oct 30, 2018
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
* [scheduler] Deadline object -> shouldYield

Instead of using a requestIdleCallback-style deadline object, expose a
method Scheduler.shouldYield that returns true if there's a higher
priority event in the queue.

* Nits
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
* [scheduler] Deadline object -> shouldYield

Instead of using a requestIdleCallback-style deadline object, expose a
method Scheduler.shouldYield that returns true if there's a higher
priority event in the queue.

* Nits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants