Skip to content

Conversation

@CPunisher
Copy link
Contributor

@CPunisher CPunisher commented Dec 10, 2025

Summary

  1. Replace SourceFile with &str. From my observation, the SourceFile is used for diagnostic generation, and only its source string is used.
  2. Replace Arc<SourceMap> with Rope. Arc<SourceMap> is only used for transformation between Spans and line-column positions. I'd like to see if the Rope implementation is more performant than Arc<SourceMap>
  3. Fix column calculation: 0-based [start, end) -> 1-based [start, end]

If this pr is meaningful, I will also refactor other parts of JavascriptCompiler.

This pr is also a part of work to integrate swc_experimental

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 4b0bd9c
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69394ee49cef5c000891c01f

@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Dec 10, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

📦 Binary Size-limit

Comparing 4b0bd9c to test: enable passing normalCases tests and document failures (#12409) by harpsealjs

❌ Size increased by 6.50KB from 47.71MB to 47.72MB (⬆️0.01%)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 9bace5c3d9 | PR: #12409

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 9bace5c3d9 | PR: #12409

Metric Current Baseline Change
📊 Total Size 823.6 KB 823.6 KB 0 B (0.0%)
📄 JavaScript 823.6 KB 823.6 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 9bace5c3d9 | PR: #12409

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 9bace5c3d9 | PR: #12409

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 9bace5c3d9 | PR: #12409

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 0 B (0.0%)
📄 JavaScript 2.0 MB 2.0 MB 0 B (0.0%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 10, 2025

CodSpeed Performance Report

Merging #12404 will not alter performance

Comparing 12-10-refactor/rope (4b0bd9c) with main (9bace5c)

Summary

✅ 17 untouched

@CPunisher CPunisher marked this pull request as ready for review December 10, 2025 10:44
Copilot AI review requested due to automatic review settings December 10, 2025 10:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the JavaScript plugin to replace SourceFile with &str and Arc<SourceMap> with Rope for better performance in span-to-location conversions. It also converts column calculations from 0-based [start, end) to 1-based [start, end] format.

Key changes include:

  • Replacing Arc<SourceMap> with Rope data structure for efficient line/column lookups
  • Changing parser to accept &str instead of SourceFile
  • Implementing SourceLocation trait for Rope to convert byte offsets to line/column positions
  • Updating all test snapshots to reflect the 1-based column numbering

Reviewed changes

Copilot reviewed 107 out of 108 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/rspack_core/src/dependency/dependency_location.rs Implements SourceLocation for Rope, converts SharedSourceMap to use Rope
crates/rspack_plugin_javascript/src/visitors/dependency/parser/mod.rs Replaces source_file: &SourceFile with source: &str, adds lazy Rope initialization
crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs Removes SourceMap creation, passes source string directly to parser
crates/rspack_plugin_javascript/src/visitors/dependency/util.rs Updates error creation to accept String instead of &SourceFile
crates/rspack_location/src/lib.rs Removes from_span methods that depended on SourceMap
Various parser plugin files Updates all plugins to use source_rope() instead of source_map
Test snapshot files Updates all location formats from 0-based to 1-based column numbering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

📝 Benchmark detail: Open

Name Base (2025-12-10 80c4537) Current Change
10000_big_production-mode_disable-minimize + exec 24.8 s ± 419 ms 24.6 s ± 509 ms -0.96 %
10000_development-mode + exec 1.26 s ± 34 ms 1.28 s ± 26 ms +1.81 %
10000_development-mode_hmr + exec 589 ms ± 3.4 ms 586 ms ± 19 ms -0.61 %
10000_development-mode_noop-loader + exec 2.2 s ± 24 ms 2.17 s ± 41 ms -1.37 %
10000_production-mode + exec 1.36 s ± 79 ms 1.32 s ± 42 ms -3.26 %
10000_production-mode_persistent-cold + exec 1.48 s ± 28 ms 1.47 s ± 60 ms -0.70 %
10000_production-mode_persistent-hot + exec 1.04 s ± 16 ms 1.01 s ± 27 ms -2.43 %
arco-pro_development-mode + exec 1.55 s ± 67 ms 1.46 s ± 59 ms -6.03 %
arco-pro_development-mode_hmr + exec 360 ms ± 1.3 ms 360 ms ± 2.4 ms -0.03 %
arco-pro_production-mode + exec 2.92 s ± 68 ms 2.72 s ± 79 ms -6.84 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.96 s ± 123 ms 2.82 s ± 28 ms -4.54 %
arco-pro_production-mode_persistent-cold + exec 3.01 s ± 122 ms 2.91 s ± 212 ms -3.53 %
arco-pro_production-mode_persistent-hot + exec 1.64 s ± 44 ms 1.65 s ± 54 ms +0.32 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.92 s ± 107 ms 2.8 s ± 157 ms -3.91 %
large-dyn-imports_development-mode + exec 1.58 s ± 82 ms 1.6 s ± 60 ms +1.42 %
large-dyn-imports_production-mode + exec 1.61 s ± 48 ms 1.72 s ± 79 ms +7.02 %
threejs_development-mode_10x + exec 1.3 s ± 12 ms 1.25 s ± 31 ms -3.76 %
threejs_development-mode_10x_hmr + exec 920 ms ± 5.6 ms 885 ms ± 14 ms -3.73 %
threejs_production-mode_10x + exec 3.96 s ± 170 ms 3.87 s ± 39 ms -2.25 %
threejs_production-mode_10x_persistent-cold + exec 4.11 s ± 242 ms 4 s ± 21 ms -2.70 %
threejs_production-mode_10x_persistent-hot + exec 3.53 s ± 28 ms 3.51 s ± 219 ms -0.68 %
10000_big_production-mode_disable-minimize + rss memory 5372 MiB ± 150 MiB 5400 MiB ± 156 MiB +0.53 %
10000_development-mode + rss memory 564 MiB ± 19.3 MiB 574 MiB ± 18 MiB +1.80 %
10000_development-mode_hmr + rss memory 732 MiB ± 25.5 MiB 734 MiB ± 22.8 MiB +0.26 %
10000_development-mode_noop-loader + rss memory 854 MiB ± 19.5 MiB 873 MiB ± 7.71 MiB +2.21 %
10000_production-mode + rss memory 612 MiB ± 35 MiB 629 MiB ± 54.2 MiB +2.66 %
10000_production-mode_persistent-cold + rss memory 697 MiB ± 42.3 MiB 701 MiB ± 43.8 MiB +0.49 %
10000_production-mode_persistent-hot + rss memory 691 MiB ± 44.7 MiB 693 MiB ± 48.8 MiB +0.33 %
arco-pro_development-mode + rss memory 480 MiB ± 75 MiB 516 MiB ± 59 MiB +7.51 %
arco-pro_development-mode_hmr + rss memory 390 MiB ± 12.1 MiB 431 MiB ± 15.1 MiB +10.50 %
arco-pro_production-mode + rss memory 601 MiB ± 55.4 MiB 598 MiB ± 43 MiB -0.42 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 597 MiB ± 82.1 MiB 632 MiB ± 33.6 MiB +5.95 %
arco-pro_production-mode_persistent-cold + rss memory 645 MiB ± 44.1 MiB 691 MiB ± 69 MiB +6.99 %
arco-pro_production-mode_persistent-hot + rss memory 521 MiB ± 58.5 MiB 521 MiB ± 82.8 MiB -0.01 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 586 MiB ± 119 MiB 596 MiB ± 59.3 MiB +1.82 %
large-dyn-imports_development-mode + rss memory 584 MiB ± 6.95 MiB 584 MiB ± 5.67 MiB +0.07 %
large-dyn-imports_production-mode + rss memory 541 MiB ± 9.63 MiB 542 MiB ± 13.8 MiB +0.21 %
threejs_development-mode_10x + rss memory 522 MiB ± 24.7 MiB 536 MiB ± 19.9 MiB +2.77 %
threejs_development-mode_10x_hmr + rss memory 760 MiB ± 39.4 MiB 729 MiB ± 6.4 MiB -4.07 %
threejs_production-mode_10x + rss memory 682 MiB ± 128 MiB 704 MiB ± 126 MiB +3.19 %
threejs_production-mode_10x_persistent-cold + rss memory 757 MiB ± 76.6 MiB 725 MiB ± 27.8 MiB -4.27 %
threejs_production-mode_10x_persistent-hot + rss memory 596 MiB ± 63.7 MiB 589 MiB ± 67.5 MiB -1.19 %

Threshold exceeded: ["large-dyn-imports_production-mode + exec"]

@ahabhgk ahabhgk requested a review from SyMind December 11, 2025 06:04
@CPunisher CPunisher enabled auto-merge (squash) December 11, 2025 06:26
@CPunisher CPunisher merged commit 3c56e8c into main Dec 12, 2025
58 checks passed
@CPunisher CPunisher deleted the 12-10-refactor/rope branch December 12, 2025 07:57
@CPunisher CPunisher mentioned this pull request Dec 17, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants