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: improve FlagDependencyExportsPlugin for large JSON by depth #8802

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hai-x
Copy link
Contributor

@hai-x hai-x commented Dec 21, 2024

Summary

Aligned with webpack/webpack#19058.

I will update doc later.

Checklist

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

@CLAassistant
Copy link

CLAassistant commented Dec 21, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the release: performance release: performance related release(mr only) label Dec 21, 2024
Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 610aaf0
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/676977f8710fa600088250b9

@hai-x hai-x force-pushed the hai-x/feat-support-dyn-exp-for-url branch from 84ce1e2 to cad432f Compare December 22, 2024 06:12
Copy link

codspeed-hq bot commented Dec 22, 2024

CodSpeed Performance Report

Merging #8802 will not alter performance

Comparing hai-x:hai-x/feat-support-dyn-exp-for-url (610aaf0) with main (a4aa3a9)

🎉 Hooray! codspeed-node just leveled up to 4.0.0!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 3 untouched benchmarks

@LingyuCoder LingyuCoder requested a review from JSerFeng December 23, 2024 01:54
Copy link
Contributor

@ahabhgk ahabhgk left a comment

Choose a reason for hiding this comment

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

Generally looks good to me

@@ -13,13 +13,15 @@ pub struct JsonExportsDependency {
id: DependencyId,
#[cacheable(with=AsPreset)]
data: JsonValue,
exports_depth: f64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
exports_depth: f64,
exports_depth: u32,

u32 should be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense.

@@ -32,7 +32,9 @@ mod utils;

#[cacheable]
#[derive(Debug)]
struct JsonParserAndGenerator;
struct JsonParserAndGenerator {
pub exports_depth: f64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub exports_depth: f64,
pub exports_depth: u32,

D(
module.parser[JSON_MODULE_TYPE],
"exportsDepth",
mode === "development" ? 1 : Number.POSITIVE_INFINITY
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mode === "development" ? 1 : Number.POSITIVE_INFINITY
mode === "development" ? 1 : Number.MAX_SAFE_INTEGER

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is Infinity in webpack. Should we align?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think both is fine, but I'm not sure what will pass to rust side by napi-rs if we use Infinity here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense. After tested napi locally. I Found that:

js pass Infinity & rust declare f64 => exportsDepth: f64::INFINITY(rust side)
js pass Infinity & rust declare u32 => exportsDepth: 0

js pass MAX_SAFE_INTEGER & rust declare f64 => exportsDepth: 9007199254740991 (2^53-1)
js pass MAX_SAFE_INTEGER & rust declare u32 => exportsDepth: 4294967295 (2^32-1)

Should we keep f64 + Infinity to align?

Copy link
Contributor

Choose a reason for hiding this comment

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

Both fine to me, but I prefer u32 a little bit :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both fine to me, but I prefer u32 a little bit :)

No problem. Let we use u32. I think it's more efficient in rust side.

When there is feedback from users, we can make further changes.

I will update it later.

@hai-x hai-x requested a review from ahabhgk December 23, 2024 14:19
@hai-x hai-x force-pushed the hai-x/feat-support-dyn-exp-for-url branch from bb05fe4 to 610aaf0 Compare December 23, 2024 14:47
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants