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

reduce the number of swaps when comparing in minHeap #25125

Closed
wants to merge 1 commit into from

Conversation

shimeng28
Copy link

@shimeng28 shimeng28 commented Aug 21, 2022

use once assignment, instead of swap when comparing in SchedulerMinHeap

@sizebot
Copy link

sizebot commented Aug 21, 2022

Comparing: 9ff738f...b7cc377

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 134.97 kB 134.97 kB = 43.23 kB 43.23 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 141.64 kB 141.64 kB = 45.20 kB 45.20 kB
facebook-www/ReactDOM-prod.classic.js = 486.06 kB 486.06 kB = 86.51 kB 86.51 kB
facebook-www/ReactDOM-prod.modern.js = 471.34 kB 471.34 kB = 84.29 kB 84.29 kB
facebook-www/ReactDOMForked-prod.classic.js = 486.06 kB 486.06 kB = 86.51 kB 86.51 kB
facebook-www/SchedulerMock-prod.classic.js = 12.56 kB 12.27 kB = 2.96 kB 2.92 kB
facebook-www/SchedulerMock-prod.modern.js = 12.56 kB 12.27 kB = 2.96 kB 2.92 kB
facebook-react-native/scheduler/cjs/SchedulerMock-prod.js = 12.28 kB 11.99 kB = 2.88 kB 2.84 kB
facebook-www/Scheduler-prod.classic.js = 11.77 kB 11.48 kB = 2.91 kB 2.87 kB
facebook-www/Scheduler-prod.modern.js = 11.77 kB 11.48 kB = 2.91 kB 2.87 kB
facebook-react-native/scheduler/cjs/Scheduler-profiling.js = 11.06 kB 10.78 kB = 2.78 kB 2.73 kB
facebook-react-native/scheduler/cjs/Scheduler-prod.js = 10.46 kB 10.17 kB = 2.63 kB 2.59 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react/umd/react.development.js = 114.67 kB 114.30 kB = 29.44 kB 29.36 kB
oss-stable/react/umd/react.development.js = 110.26 kB 109.89 kB = 28.38 kB 28.30 kB
oss-stable-semver/react/umd/react.development.js = 110.23 kB 109.86 kB = 28.35 kB 28.27 kB
oss-experimental/react/umd/react.production.min.js = 11.91 kB 11.85 kB = 4.58 kB 4.56 kB
oss-experimental/react/umd/react.profiling.min.js = 11.91 kB 11.85 kB = 4.58 kB 4.56 kB
oss-stable/react/umd/react.production.min.js = 10.79 kB 10.72 kB = 4.28 kB 4.26 kB
oss-stable/react/umd/react.profiling.min.js = 10.79 kB 10.72 kB = 4.28 kB 4.27 kB
oss-stable-semver/react/umd/react.production.min.js = 10.76 kB 10.70 kB = 4.26 kB 4.24 kB
oss-stable-semver/react/umd/react.profiling.min.js = 10.76 kB 10.70 kB = 4.26 kB 4.24 kB
oss-experimental/scheduler/cjs/scheduler-unstable_mock.production.min.js = 4.89 kB 4.83 kB = 1.97 kB 1.95 kB
oss-stable-semver/scheduler/cjs/scheduler-unstable_mock.production.min.js = 4.89 kB 4.83 kB = 1.97 kB 1.95 kB
oss-stable/scheduler/cjs/scheduler-unstable_mock.production.min.js = 4.89 kB 4.83 kB = 1.97 kB 1.95 kB
oss-experimental/scheduler/umd/scheduler-unstable_mock.production.min.js = 4.93 kB 4.86 kB = 2.07 kB 2.04 kB
oss-stable-semver/scheduler/umd/scheduler-unstable_mock.production.min.js = 4.93 kB 4.86 kB = 2.07 kB 2.04 kB
oss-stable/scheduler/umd/scheduler-unstable_mock.production.min.js = 4.93 kB 4.86 kB = 2.07 kB 2.04 kB
facebook-www/Scheduler-dev.classic.js = 24.83 kB 24.50 kB = 6.67 kB 6.60 kB
facebook-www/Scheduler-dev.modern.js = 24.83 kB 24.50 kB = 6.67 kB 6.60 kB
facebook-www/SchedulerMock-dev.classic.js = 23.15 kB 22.81 kB = 5.48 kB 5.42 kB
facebook-www/SchedulerMock-dev.modern.js = 23.15 kB 22.81 kB = 5.48 kB 5.42 kB
oss-experimental/scheduler/cjs/scheduler.production.min.js = 4.26 kB 4.20 kB = 1.79 kB 1.77 kB
oss-stable-semver/scheduler/cjs/scheduler.production.min.js = 4.26 kB 4.20 kB = 1.79 kB 1.77 kB
oss-stable/scheduler/cjs/scheduler.production.min.js = 4.26 kB 4.20 kB = 1.79 kB 1.77 kB
facebook-www/Scheduler-profiling.classic.js = 15.95 kB 15.67 kB = 3.71 kB 3.66 kB
facebook-www/Scheduler-profiling.modern.js = 15.95 kB 15.67 kB = 3.71 kB 3.66 kB
facebook-react-native/scheduler/cjs/SchedulerMock-dev.js = 17.95 kB 17.62 kB = 4.30 kB 4.24 kB
facebook-react-native/scheduler/cjs/Scheduler-dev.js = 17.69 kB 17.35 kB = 4.99 kB 4.93 kB
oss-experimental/scheduler/umd/scheduler-unstable_mock.development.js = 19.24 kB 18.87 kB = 4.41 kB 4.34 kB
oss-stable-semver/scheduler/umd/scheduler-unstable_mock.development.js = 19.24 kB 18.87 kB = 4.41 kB 4.34 kB
oss-stable/scheduler/umd/scheduler-unstable_mock.development.js = 19.24 kB 18.87 kB = 4.41 kB 4.34 kB
oss-experimental/scheduler/cjs/scheduler-unstable_mock.development.js = 17.90 kB 17.55 kB = 4.30 kB 4.23 kB
oss-stable-semver/scheduler/cjs/scheduler-unstable_mock.development.js = 17.90 kB 17.55 kB = 4.30 kB 4.23 kB
oss-stable/scheduler/cjs/scheduler-unstable_mock.development.js = 17.90 kB 17.55 kB = 4.30 kB 4.23 kB
oss-experimental/scheduler/cjs/scheduler.development.js = 17.66 kB 17.31 kB = 4.98 kB 4.91 kB
oss-stable-semver/scheduler/cjs/scheduler.development.js = 17.66 kB 17.31 kB = 4.98 kB 4.91 kB
oss-stable/scheduler/cjs/scheduler.development.js = 17.66 kB 17.31 kB = 4.98 kB 4.91 kB
facebook-www/SchedulerMock-prod.classic.js = 12.56 kB 12.27 kB = 2.96 kB 2.92 kB
facebook-www/SchedulerMock-prod.modern.js = 12.56 kB 12.27 kB = 2.96 kB 2.92 kB
facebook-react-native/scheduler/cjs/SchedulerMock-prod.js = 12.28 kB 11.99 kB = 2.88 kB 2.84 kB
facebook-www/Scheduler-prod.classic.js = 11.77 kB 11.48 kB = 2.91 kB 2.87 kB
facebook-www/Scheduler-prod.modern.js = 11.77 kB 11.48 kB = 2.91 kB 2.87 kB
facebook-react-native/scheduler/cjs/Scheduler-profiling.js = 11.06 kB 10.78 kB = 2.78 kB 2.73 kB
facebook-react-native/scheduler/cjs/Scheduler-prod.js = 10.46 kB 10.17 kB = 2.63 kB 2.59 kB

Generated by 🚫 dangerJS against b7cc377

@acdlite
Copy link
Collaborator

acdlite commented Aug 21, 2022

Can you explain what you mean by "reduce the number of swaps?" In both implementations there's at most a single swap per siftDown call. So I'm not sure what the intent of the refactor is.

}
}
heap[index] = node;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part makes sense

}
}
heap[index] = node;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, so you're waiting to assign the final index until the end. The other factoring changes in this function don't seem relevant, though? Just stylistic. Do you mind reverting those?

@shimeng28 shimeng28 force-pushed the reduce-swap-min-heap branch 3 times, most recently from 576159f to f29f442 Compare August 27, 2022 10:15
Copy link

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 10, 2024
Copy link

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions bot closed this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants