Skip to content

perf: introduce pre-computed hashing for ArcPath#11651

Merged
SyMind merged 2 commits intomainfrom
perf-arc-path
Sep 12, 2025
Merged

perf: introduce pre-computed hashing for ArcPath#11651
SyMind merged 2 commits intomainfrom
perf-arc-path

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Sep 12, 2025

Summary

This PR introduces a significant performance optimization for ArcPath by pre-computing and caching its hash value. ArcPath is used extensively throughout the codebase as a key in HashMap and HashSet (including concurrent versions like DashMap). Previously, every hash operation (e.g., insert, get) required re-calculating the hash by iterating over the entire path string, leading to substantial and repetitive CPU overhead.

Related links

Checklist

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

@netlify
Copy link

netlify bot commented Sep 12, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit b545a24
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68c3c4d0ea79b5000888c7b9

@github-actions github-actions bot added release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack. labels Sep 12, 2025
@SyMind SyMind marked this pull request as ready for review September 12, 2025 06:50
@SyMind SyMind requested a review from quininer as a code owner September 12, 2025 06:50
Copilot AI review requested due to automatic review settings September 12, 2025 06:50
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

Optimizes path handling performance by introducing precomputed hash caching for ArcPath and replacing usage with specialized hash set types across the codebase.

  • Refactored ArcPath to store precomputed hash values for O(1) hashing operations
  • Introduced optimized collection types (ArcPathSet, ArcPathMap, etc.) using IdentityHasher
  • Updated all modules to use new path collection types instead of generic hash collections

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/rspack_paths/src/lib.rs Core implementation of optimized ArcPath with precomputed hashing and new collection type definitions
crates/rspack_paths/Cargo.toml Added required dependencies for hashing and concurrent collections
crates/rspack_plugin_lazy_compilation/src/module.rs Updated to use ArcPathSet instead of generic hash sets
crates/rspack_plugin_lazy_compilation/src/dependency.rs Updated dependency path collections to use optimized types
crates/rspack_plugin_extract_css/src/css_dependency.rs Migrated CSS dependency path collections to use FxArcPathSet
crates/rspack_fs/src/watcher/*.rs Updated file system watcher components to use ArcPathDashSet
crates/rspack_core/src/**/*.rs Comprehensive migration of core module path handling to optimized collection types

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

@SyMind SyMind changed the title perf: arc path with precomputed hash perf: introduce pre-computed hashing for ArcPath Sep 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2025

📝 Benchmark detail: Open

Name Base (2025-09-12 293975c) Current Change
10000_big_production-mode_disable-minimize + exec 28.2 s ± 611 ms 28.4 s ± 879 ms +0.61 %
10000_development-mode + exec 1.9 s ± 63 ms 1.9 s ± 40 ms +0.07 %
10000_development-mode_hmr + exec 701 ms ± 8.9 ms 697 ms ± 9.8 ms -0.56 %
10000_development-mode_noop-loader + exec 2.77 s ± 75 ms 2.81 s ± 127 ms +1.18 %
10000_production-mode + exec 1.86 s ± 53 ms 1.84 s ± 29 ms -1.07 %
10000_production-mode_persistent-cold + exec 2.05 s ± 55 ms 2.07 s ± 227 ms +1.14 %
10000_production-mode_persistent-hot + exec 1.38 s ± 42 ms 1.37 s ± 27 ms -0.20 %
arco-pro_development-mode + exec 1.79 s ± 82 ms 1.77 s ± 107 ms -0.83 %
arco-pro_development-mode_hmr + exec 369 ms ± 0.65 ms 370 ms ± 1.4 ms +0.05 %
arco-pro_production-mode + exec 3.3 s ± 71 ms 3.2 s ± 78 ms -3.02 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.31 s ± 114 ms 3.32 s ± 181 ms +0.27 %
arco-pro_production-mode_persistent-cold + exec 3.34 s ± 78 ms 3.29 s ± 134 ms -1.24 %
arco-pro_production-mode_persistent-hot + exec 2 s ± 94 ms 1.99 s ± 63 ms -0.68 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.27 s ± 69 ms 3.27 s ± 229 ms +0.07 %
large-dyn-imports_development-mode + exec 2.34 s ± 18 ms 2.31 s ± 27 ms -1.09 %
large-dyn-imports_production-mode + exec 2.18 s ± 66 ms 2.18 s ± 53 ms -0.07 %
threejs_development-mode_10x + exec 1.53 s ± 28 ms 1.51 s ± 27 ms -1.16 %
threejs_development-mode_10x_hmr + exec 947 ms ± 31 ms 931 ms ± 12 ms -1.74 %
threejs_production-mode_10x + exec 4.53 s ± 184 ms 4.56 s ± 142 ms +0.53 %
threejs_production-mode_10x_persistent-cold + exec 4.7 s ± 353 ms 4.66 s ± 85 ms -0.82 %
threejs_production-mode_10x_persistent-hot + exec 4.1 s ± 78 ms 4.11 s ± 55 ms +0.36 %
10000_big_production-mode_disable-minimize + rss memory 8553 MiB ± 526 MiB 8626 MiB ± 492 MiB +0.86 %
10000_development-mode + rss memory 691 MiB ± 22.4 MiB 684 MiB ± 14.7 MiB -1.03 %
10000_development-mode_hmr + rss memory 828 MiB ± 41.6 MiB 835 MiB ± 26.8 MiB +0.83 %
10000_development-mode_noop-loader + rss memory 974 MiB ± 29.4 MiB 958 MiB ± 13.1 MiB -1.71 %
10000_production-mode + rss memory 653 MiB ± 47 MiB 654 MiB ± 23.1 MiB +0.06 %
10000_production-mode_persistent-cold + rss memory 762 MiB ± 18.1 MiB 767 MiB ± 33.9 MiB +0.70 %
10000_production-mode_persistent-hot + rss memory 744 MiB ± 45.1 MiB 748 MiB ± 15.5 MiB +0.57 %
arco-pro_development-mode + rss memory 568 MiB ± 54.6 MiB 565 MiB ± 32.8 MiB -0.61 %
arco-pro_development-mode_hmr + rss memory 468 MiB ± 8.19 MiB 459 MiB ± 8.43 MiB -1.90 %
arco-pro_production-mode + rss memory 688 MiB ± 78.1 MiB 683 MiB ± 107 MiB -0.77 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 681 MiB ± 126 MiB 688 MiB ± 71.8 MiB +0.94 %
arco-pro_production-mode_persistent-cold + rss memory 778 MiB ± 101 MiB 765 MiB ± 52.2 MiB -1.76 %
arco-pro_production-mode_persistent-hot + rss memory 657 MiB ± 86.6 MiB 638 MiB ± 118 MiB -2.81 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 705 MiB ± 39 MiB 660 MiB ± 55.8 MiB -6.37 %
large-dyn-imports_development-mode + rss memory 690 MiB ± 8.99 MiB 689 MiB ± 2.56 MiB -0.12 %
large-dyn-imports_production-mode + rss memory 590 MiB ± 5.52 MiB 588 MiB ± 4.98 MiB -0.45 %
threejs_development-mode_10x + rss memory 592 MiB ± 22.5 MiB 585 MiB ± 16.7 MiB -1.17 %
threejs_development-mode_10x_hmr + rss memory 836 MiB ± 60.4 MiB 830 MiB ± 43.5 MiB -0.64 %
threejs_production-mode_10x + rss memory 797 MiB ± 198 MiB 740 MiB ± 138 MiB -7.15 %
threejs_production-mode_10x_persistent-cold + rss memory 820 MiB ± 58.8 MiB 822 MiB ± 33.5 MiB +0.21 %
threejs_production-mode_10x_persistent-hot + rss memory 708 MiB ± 34.1 MiB 703 MiB ± 27.7 MiB -0.76 %

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 12, 2025
@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing b545a24 to perf: fix drop regression (#11649) by harpsealjs

🙈 Size remains the same at 47.43MB

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 12, 2025

CodSpeed Performance Report

Merging #11651 will not alter performance

Comparing perf-arc-path (b545a24) with main (8be291d)

Summary

✅ 17 untouched

@SyMind SyMind merged commit cf49fa2 into main Sep 12, 2025
51 checks passed
@SyMind SyMind deleted the perf-arc-path branch September 12, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance related release(mr only) 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