-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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: analyze cjs re-exports in parallel #23894
perf: analyze cjs re-exports in parallel #23894
Conversation
ext/node/analyze.rs
Outdated
.unwrap(); | ||
let mut analyze_futures: FuturesUnordered< | ||
LocalBoxFuture<Result<_, AnyError>>, | ||
> = FuturesUnordered::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create an unsync version of this (not joinset, which will spawn futures)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea. Can you open an issue in deno_unsync
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext/node/analyze.rs
Outdated
.unwrap(); | ||
let mut analyze_futures: FuturesUnordered< | ||
LocalBoxFuture<Result<_, AnyError>>, | ||
> = FuturesUnordered::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea. Can you open an issue in deno_unsync
?
ext/node/analyze.rs
Outdated
if !handled_reexports.insert(reexport_specifier.clone()) { | ||
continue; | ||
} | ||
let mut handled_reexports: HashSet<ModuleSpecifier> = HashSet::default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-allocate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't know how many modules there will be.
ext/node/analyze.rs
Outdated
}; | ||
analysis_result = analyze_futures.select_next_some() => { | ||
// 2. Look at the analysis result and resolve its exports and re-exports | ||
let (reexport_specifier, referrer, analysis) = analysis_result?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I just realized is we should make the errors deterministic if there are multiple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a1291ce
This causes it to go concurrently through cjs modules handling re-exports as they're discovered rather than in batches.
In very simple scenarios this will be about the same performance or a few ms slower, but in worst case scenarios it will be much faster (this is with a fresh node analysis cache on each run):
Note that with a cache it's a few ms slower:
Closes #23859