Skip to content

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Sep 24, 2025

Summary

This PR removes the usage of CachedSource wrapper around file_manifest.source when creating compilation assets, simplifying the asset creation process by directly using the source.

  • Eliminates unnecessary CachedSource::new(...).boxed() wrapper
  • Simplifies asset creation by passing source directly to CompilationAsset::new

Relate PR: rstackjs/rspack-sources#183

This PR refactors ReplaceSource and CachedSource to use trait objects (BoxSource) instead of generic type parameters, improving ergonomics and enabling runtime type checking. The key optimization checks if a BoxSource already wraps a CachedSource to avoid double-caching.

Key Changes:

  • Converted ReplaceSource<T> and CachedSource<T> from generic structs to concrete structs using BoxSource
  • Added optimization in CachedSource::new() to detect and unwrap existing CachedSource instances
  • Removed original() methods from both structs since the inner source is now a trait object

Related links

Checklist

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

Copilot AI review requested due to automatic review settings September 24, 2025 09:14
@netlify
Copy link

netlify bot commented Sep 24, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 6d9cad2
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69007ce913a79c0008c2a2fd

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 removes the usage of CachedSource wrapper around file_manifest.source when creating compilation assets, simplifying the asset creation process by directly using the source.

  • Eliminates unnecessary CachedSource::new(...).boxed() wrapper
  • Simplifies asset creation by passing source directly to CompilationAsset::new

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Sep 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

📦 Binary Size-limit

Comparing 6d9cad2 to fix: type definitions for devtool module filename templates (#12013) by neverland

🎉 Size decreased by 29.88KB from 47.85MB to 47.82MB (⬇️0.06%)

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 24, 2025

CodSpeed Performance Report

Merging #11754 will not alter performance

Comparing chore-rm-no-need-cached-source (6d9cad2) with main (abef4de)

Summary

✅ 17 untouched

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

📝 Benchmark detail: Open

Name Base (2025-10-28 aa4ad88) Current Change
10000_big_production-mode_disable-minimize + exec 27.5 s ± 764 ms 27.5 s ± 1.01 s -0.06 %
10000_development-mode + exec 1.33 s ± 30 ms 1.31 s ± 40 ms -1.16 %
10000_development-mode_hmr + exec 648 ms ± 4.1 ms 644 ms ± 10 ms -0.56 %
10000_development-mode_noop-loader + exec 2.22 s ± 71 ms 2.23 s ± 46 ms +0.49 %
10000_production-mode + exec 1.42 s ± 31 ms 1.43 s ± 132 ms +0.08 %
10000_production-mode_persistent-cold + exec 1.57 s ± 21 ms 1.52 s ± 28 ms -3.41 %
10000_production-mode_persistent-hot + exec 1.1 s ± 30 ms 1.08 s ± 26 ms -1.44 %
arco-pro_development-mode + exec 1.58 s ± 37 ms 1.59 s ± 88 ms +1.00 %
arco-pro_development-mode_hmr + exec 359 ms ± 2.2 ms 359 ms ± 2.3 ms -0.06 %
arco-pro_production-mode + exec 2.97 s ± 99 ms 2.93 s ± 113 ms -1.33 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.06 s ± 82 ms 2.98 s ± 48 ms -2.64 %
arco-pro_production-mode_persistent-cold + exec 3.06 s ± 164 ms 3.01 s ± 183 ms -1.78 %
arco-pro_production-mode_persistent-hot + exec 1.72 s ± 61 ms 1.7 s ± 91 ms -1.30 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.98 s ± 86 ms 2.94 s ± 89 ms -1.58 %
large-dyn-imports_development-mode + exec 1.6 s ± 49 ms 1.6 s ± 70 ms +0.28 %
large-dyn-imports_production-mode + exec 1.64 s ± 42 ms 1.62 s ± 77 ms -1.20 %
threejs_development-mode_10x + exec 1.32 s ± 41 ms 1.31 s ± 10 ms -0.55 %
threejs_development-mode_10x_hmr + exec 917 ms ± 20 ms 912 ms ± 16 ms -0.50 %
threejs_production-mode_10x + exec 4.13 s ± 84 ms 4.07 s ± 137 ms -1.29 %
threejs_production-mode_10x_persistent-cold + exec 4.24 s ± 193 ms 4.21 s ± 201 ms -0.70 %
threejs_production-mode_10x_persistent-hot + exec 3.72 s ± 41 ms 3.7 s ± 39 ms -0.64 %
10000_big_production-mode_disable-minimize + rss memory 8723 MiB ± 296 MiB 8744 MiB ± 54.5 MiB +0.25 %
10000_development-mode + rss memory 654 MiB ± 14.6 MiB 619 MiB ± 25.2 MiB -5.48 %
10000_development-mode_hmr + rss memory 819 MiB ± 4.78 MiB 770 MiB ± 14.9 MiB -6.04 %
10000_development-mode_noop-loader + rss memory 968 MiB ± 11.8 MiB 906 MiB ± 39.9 MiB -6.44 %
10000_production-mode + rss memory 685 MiB ± 33.9 MiB 637 MiB ± 34.7 MiB -7.05 %
10000_production-mode_persistent-cold + rss memory 753 MiB ± 38.7 MiB 720 MiB ± 27.9 MiB -4.36 %
10000_production-mode_persistent-hot + rss memory 755 MiB ± 43.3 MiB 717 MiB ± 54.6 MiB -5.15 %
arco-pro_development-mode + rss memory 532 MiB ± 40.1 MiB 540 MiB ± 30.5 MiB +1.43 %
arco-pro_development-mode_hmr + rss memory 428 MiB ± 24.1 MiB 412 MiB ± 7.91 MiB -3.85 %
arco-pro_production-mode + rss memory 678 MiB ± 57.8 MiB 637 MiB ± 67 MiB -6.08 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 677 MiB ± 91.1 MiB 654 MiB ± 108 MiB -3.48 %
arco-pro_production-mode_persistent-cold + rss memory 761 MiB ± 132 MiB 733 MiB ± 125 MiB -3.66 %
arco-pro_production-mode_persistent-hot + rss memory 574 MiB ± 93.5 MiB 555 MiB ± 109 MiB -3.30 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 695 MiB ± 74.2 MiB 627 MiB ± 64.2 MiB -9.74 %
large-dyn-imports_development-mode + rss memory 691 MiB ± 11.4 MiB 635 MiB ± 12.8 MiB -8.12 %
large-dyn-imports_production-mode + rss memory 626 MiB ± 4.5 MiB 568 MiB ± 6.24 MiB -9.34 %
threejs_development-mode_10x + rss memory 574 MiB ± 9.52 MiB 563 MiB ± 20.8 MiB -1.83 %
threejs_development-mode_10x_hmr + rss memory 806 MiB ± 37.3 MiB 787 MiB ± 24 MiB -2.40 %
threejs_production-mode_10x + rss memory 770 MiB ± 193 MiB 820 MiB ± 181 MiB +6.58 %
threejs_production-mode_10x_persistent-cold + rss memory 832 MiB ± 26.6 MiB 815 MiB ± 24.8 MiB -2.11 %
threejs_production-mode_10x_persistent-hot + rss memory 686 MiB ± 30.1 MiB 666 MiB ± 38.2 MiB -2.93 %

@SyMind SyMind force-pushed the chore-rm-no-need-cached-source branch from 20dfacc to e88ff46 Compare October 28, 2025 04:35
@SyMind SyMind force-pushed the chore-rm-no-need-cached-source branch 3 times, most recently from 15b1ffb to 36ca351 Compare October 28, 2025 07:09
@SyMind SyMind force-pushed the chore-rm-no-need-cached-source branch from 36ca351 to 6d9cad2 Compare October 28, 2025 08:20
@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

📝 Ecosystem CI detail: Open

suite result
rspress ✅ success
rstest ✅ success
rslib ❌ failure
examples ✅ success
modernjs ❌ failure
devserver ❌ failure
rsbuild ✅ success
nuxt ✅ success
rsdoctor ✅ success
plugin ❌ failure
lynx-stack ❌ failure

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Oct 28, 2025
@SyMind SyMind merged commit 505c743 into main Oct 28, 2025
63 checks passed
@SyMind SyMind deleted the chore-rm-no-need-cached-source branch October 28, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants