Skip to content

perf(rust/renamer): new deconflict strategy#1461

Merged
hyfdev merged 12 commits into
mainfrom
perf/add-top-level-symbol2
Jun 28, 2024
Merged

perf(rust/renamer): new deconflict strategy#1461
hyfdev merged 12 commits into
mainfrom
perf/add-top-level-symbol2

Conversation

@IWANABETHATGUY

@IWANABETHATGUY IWANABETHATGUY commented Jun 27, 2024

Copy link
Copy Markdown
Member

chore: 🤖 update snap

chore: 🤖 clean

chore: 🤖 lint

chore: 🤖 revert
chore: 🤖 lint

chore: 🤖 clean

chore: 🤖 try

chore: 🤖 update

chore: 🤖 cleran

chore: 🤖 clean

chore: 🤖 clean
@IWANABETHATGUY IWANABETHATGUY changed the title Perf/add top level symbol2 perf: add top level symbol Jun 27, 2024
@netlify

netlify Bot commented Jun 27, 2024

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 7a70b89
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/667e4a61a389530008c54a20

@codecov

codecov Bot commented Jun 27, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.99%. Comparing base (5df84a8) to head (7a70b89).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1461      +/-   ##
==========================================
+ Coverage   85.98%   85.99%   +0.01%     
==========================================
  Files         152      152              
  Lines        7741     7747       +6     
==========================================
+ Hits         6656     6662       +6     
  Misses       1085     1085              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Jun 27, 2024

Copy link
Copy Markdown
Contributor

Benchmarks Rust

group                                 pr                                     target
-----                                 --                                     ------
bundle/bundle@rome-ts                 1.00     92.9±0.67ms        ? ?/sec    1.00     93.1±0.75ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap       1.01    111.8±1.80ms        ? ?/sec    1.00    111.0±0.75ms        ? ?/sec
bundle/bundle@threejs                 1.00     28.1±0.81ms        ? ?/sec    1.00     28.0±0.57ms        ? ?/sec
bundle/bundle@threejs-sourcemap       1.00     36.5±0.63ms        ? ?/sec    1.01     36.8±0.86ms        ? ?/sec
bundle/bundle@threejs10x              1.00    301.5±2.43ms        ? ?/sec    1.02    308.3±4.81ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap    1.00    400.4±7.92ms        ? ?/sec    1.03    411.0±8.32ms        ? ?/sec
scan/scan@rome-ts                     1.00     75.9±0.65ms        ? ?/sec    1.00     76.3±0.63ms        ? ?/sec
scan/scan@rome-ts-sourcemap           1.00     76.6±0.66ms        ? ?/sec    1.00     76.9±0.91ms        ? ?/sec
scan/scan@threejs                     1.00     20.9±0.37ms        ? ?/sec    1.00     20.9±0.44ms        ? ?/sec
scan/scan@threejs-sourcemap           1.00     20.7±0.16ms        ? ?/sec    1.01     20.9±0.19ms        ? ?/sec
scan/scan@threejs10x                  1.00    208.3±1.73ms        ? ?/sec    1.01    209.8±2.53ms        ? ?/sec
scan/scan@threejs10x-sourcemap        1.00    208.2±1.66ms        ? ?/sec    1.02    211.7±1.86ms        ? ?/sec

chore: 🤖 update comments

chore: 🤖 improve comments
@IWANABETHATGUY
IWANABETHATGUY marked this pull request as ready for review June 27, 2024 16:49
@IWANABETHATGUY
IWANABETHATGUY force-pushed the perf/add-top-level-symbol2 branch from 02bac33 to 7376db9 Compare June 27, 2024 16:49
@IWANABETHATGUY
IWANABETHATGUY requested a review from hyfdev June 28, 2024 02:51
@IWANABETHATGUY
IWANABETHATGUY enabled auto-merge June 28, 2024 02:51
Comment thread crates/rolldown/src/utils/renamer.rs Outdated
let next_conflict_index = *occ.get() + 1;
*occ.get_mut() = next_conflict_index;
candidate_name =
Cow::Owned(format!("{candidate_name}${next_conflict_index}",).into());

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.

Suggested change
Cow::Owned(format!("{candidate_name}${next_conflict_index}",).into());
Cow::Owned(format!("{original_name}${next_conflict_index}",).into());

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.

same above

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.

fixed

count += 1;
candidate_name = Cow::Owned(format!("{original_name}${count}").into());
loop {
match self.used_canonical_names.entry(candidate_name.clone()) {

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.

Suggested change
match self.used_canonical_names.entry(candidate_name.clone()) {
match self.used_canonical_names.entry(original_name.clone()) {

Should you use original_name name here?

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.

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.

We need to find a fixed point

@hyfdev hyfdev Jun 28, 2024

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.

If there's is another a, in the current algorithm, will it be renamed to a$1$1$1? If so, I would like to see if we could fix this, it's kind of ugly in the output.

If we don't care the how output looks, we could follow how parcel did which is renaming the vars to a meaningless hashed value. This way it should be more faster.

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.

Fixed

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.


//#region shared.js
const a$2 = 'shared.js';
const a$1$1 = 'shared.js';

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 be a$n rather than a$1$1

@IWANABETHATGUY IWANABETHATGUY Jun 28, 2024

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.

Alright, I get you, let me test if performance got regressed

@hyfdev hyfdev changed the title perf: add top level symbol perf(rust/renamer): new deconflict strategy Jun 28, 2024
@hyfdev
hyfdev disabled auto-merge June 28, 2024 05:36
@hyfdev
hyfdev enabled auto-merge June 28, 2024 05:36

@hyfdev hyfdev left a comment

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.

Well done!

@hyfdev
hyfdev added this pull request to the merge queue Jun 28, 2024
Merged via the queue into main with commit fa866eb Jun 28, 2024
@hyfdev
hyfdev deleted the perf/add-top-level-symbol2 branch June 28, 2024 05:48
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.

Need a new strategy for dealing with conflicted identifiers

2 participants