Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize JS communication with lazy getters #7163

Merged
merged 11 commits into from
Jul 17, 2024
Merged

Conversation

SyMind
Copy link
Member

@SyMind SyMind commented Jul 15, 2024

Summary

This optimization uses getters to lazily create JavaScript values in Rust.

This enhances performance, as illustrated by JsStatsModule. In JsStatsModule, fields such as identifier, name, and nameForCondition are not always read. They are accessed only when module.built, module.codeGenerated, or options.cachedModules is true. Therefore, creating these JavaScript values in Rust when they are not used is unnecessary and inefficient.

Below are the results for an internal project when stats.all = true:

Before Optimization:

context.getInner(compilation).getChunks(): 38.889s
factory.create(`${type}.chunks`, chunks, context): 18.691s

After Optimization:

context.getInner(compilation).getChunks(): 1.829s
factory.create(`${type}.chunks`, chunks, context): 24.547s

Checklist

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

@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 Jul 15, 2024
Copy link

netlify bot commented Jul 15, 2024

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 6d79bc7
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66975d8d57e1fe00082b36d7

@SyMind SyMind force-pushed the perf-stats-js-side branch from ec84411 to c58f2ec Compare July 16, 2024 02:35
@SyMind SyMind changed the title perf: use Reference to share JsStatsModule js instance perf: optimize JS communication with lazy getters Jul 16, 2024
@SyMind SyMind force-pushed the perf-stats-js-side branch from 698c461 to aee2cd6 Compare July 17, 2024 03:57
@SyMind SyMind force-pushed the perf-stats-js-side branch from 60dca30 to 6d79bc7 Compare July 17, 2024 05:58
@SyMind SyMind merged commit 2fe5430 into main Jul 17, 2024
33 checks passed
@SyMind SyMind deleted the perf-stats-js-side branch July 17, 2024 06:31
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.

2 participants