Skip to content

perf: ⚡️ remove extra collection when using rayon#2016

Merged
IWANABETHATGUY merged 6 commits intomainfrom
perf/remove-extra-collection
Aug 19, 2024
Merged

perf: ⚡️ remove extra collection when using rayon#2016
IWANABETHATGUY merged 6 commits intomainfrom
perf/remove-extra-collection

Conversation

@IWANABETHATGUY
Copy link
Copy Markdown
Member

Description

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 18, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit f6852ef
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66c238c55d40040008d3317a


let index_sorted_cross_chunk_imports = index_cross_chunk_imports
.into_iter()
// FIXME: Extra traversing. This is a workaround due to `par_bridge` doesn't ensure order https://github.com/rayon-rs/rayon/issues/551#issuecomment-882069261
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should keep this. What this PR does is still to be considered as a workaround.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

why this is a workaround?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

According to rayon-rs/rayon#669 (comment), the ordering now is preserved without another traverse

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not about rayon here. IMO, this should be solved by the oxc_index to have a native support of rayon.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Then that should be TODO: wait oxc_index support IntoParIterator rather than Fixme:, since the bug is fixed, no overhead needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah.

.raw
.into_par_iter()
.enumerate()
.map(|(asset_idx, mut hasher)| {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

asset_idx become usize instead of AssetIdx, this is unexpected. I'm not sure why oxc_index allows using usize as the valid index type. But the reason we use IndexVec is to have a domain-specific Vec to prevent misusing wrong index. Otherwise we could just use std Vec.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@overlookmotel Sorry for bothering. Could you take have a rough look if this is expected/reasonable behavior of oxc_index?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@hyf0 Sorry I'm so late to come back on this. It got lost in my Github notifications.

I've made a PR to prevent IndexVecs being indexed into with a usize (oxc-project/oxc#5733). As you say, that's a bad idea! That oddity was inherited from index_vec crate.

Opened an issue for the par iter problem: oxc-project/oxc#5734

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 18, 2024

Benchmarks Rust

group                                                               pr                                     target
-----                                                               --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol                     1.00     51.3±0.80ms        ? ?/sec    1.01     51.8±0.89ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify              1.00     75.2±1.39ms        ? ?/sec    1.00     75.3±1.74ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify-sourcemap    1.00     90.8±0.99ms        ? ?/sec    1.00     91.0±1.14ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap           1.01     60.1±1.27ms        ? ?/sec    1.00     59.8±1.11ms        ? ?/sec
bundle/bundle@rome-ts                                               1.03    103.4±1.54ms        ? ?/sec    1.00    100.5±0.98ms        ? ?/sec
bundle/bundle@rome-ts-minify                                        1.07   194.5±10.56ms        ? ?/sec    1.00    181.9±4.42ms        ? ?/sec
bundle/bundle@rome-ts-minify-sourcemap                              1.02    226.9±7.64ms        ? ?/sec    1.00    221.5±4.73ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap                                     1.01    117.7±1.22ms        ? ?/sec    1.00    116.0±0.89ms        ? ?/sec
bundle/bundle@threejs                                               1.04     37.2±1.13ms        ? ?/sec    1.00     35.9±0.13ms        ? ?/sec
bundle/bundle@threejs-minify                                        1.01     81.9±2.21ms        ? ?/sec    1.00     81.2±1.24ms        ? ?/sec
bundle/bundle@threejs-minify-sourcemap                              1.06    102.1±3.67ms        ? ?/sec    1.00     96.2±1.81ms        ? ?/sec
bundle/bundle@threejs-sourcemap                                     1.03     46.3±0.52ms        ? ?/sec    1.00     45.1±0.47ms        ? ?/sec
bundle/bundle@threejs10x                                            1.02    392.4±3.65ms        ? ?/sec    1.00    385.0±2.04ms        ? ?/sec
bundle/bundle@threejs10x-minify                                     1.02  1001.6±12.93ms        ? ?/sec    1.00    985.4±7.82ms        ? ?/sec
bundle/bundle@threejs10x-minify-sourcemap                           1.00  1223.4±16.93ms        ? ?/sec    1.00  1223.6±11.53ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                                  1.01    457.2±5.35ms        ? ?/sec    1.00    452.5±2.32ms        ? ?/sec
remapping/remapping                                                 1.01     32.9±0.22ms        ? ?/sec    1.00     32.7±0.13ms        ? ?/sec
remapping/render-chunk-remapping                                    1.03     83.3±0.26ms        ? ?/sec    1.00     81.3±0.32ms        ? ?/sec
scan/scan@rome-ts                                                   1.01     82.2±0.74ms        ? ?/sec    1.00     81.7±0.63ms        ? ?/sec
scan/scan@threejs                                                   1.00     28.7±1.14ms        ? ?/sec    1.00     28.7±0.87ms        ? ?/sec
scan/scan@threejs10x                                                1.00    286.9±2.60ms        ? ?/sec    1.01    289.9±3.04ms        ? ?/sec

@IWANABETHATGUY
Copy link
Copy Markdown
Member Author

TODO: is added

@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review August 18, 2024 18:05
@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Aug 19, 2024
Merged via the queue into main with commit 7442d95 Aug 19, 2024
@IWANABETHATGUY IWANABETHATGUY deleted the perf/remove-extra-collection branch August 19, 2024 02:39
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.

3 participants