-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Query glibc version only once to speed up JSTransformer on Linux #9117
Conversation
|
||
// $FlowFixMe | ||
let {glibcVersionRuntime} = process.report.getReport().header; | ||
|
||
async function loadOnMainThreadIfNeeded() { | ||
if ( | ||
!isLoadedOnMainThread && |
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.
hmm it's surprising to me that this is running more than once per thread given this check here. any idea why that's happening?
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.
isLoadedOnMainThread
is set to true
only if the legacy glibc version condition is met —
parcel/packages/transformers/js/src/JSTransformer.js
Lines 950 to 957 in db3bcae
if (glibcVersionRuntime && parseFloat(glibcVersionRuntime) <= 2.17) { | |
let api = WorkerFarm.getWorkerApi(); | |
await api.callMaster({ | |
location: __dirname + '/loadNative.js', | |
args: [], | |
}); | |
isLoadedOnMainThread = true; |
Else, its called once per transform —
parcel/packages/transformers/js/src/JSTransformer.js
Lines 308 to 314 in db3bcae
async transform({asset, config, options, logger}) { | |
let [code, originalMap] = await Promise.all([ | |
asset.getBuffer(), | |
asset.getMap(), | |
init, | |
loadOnMainThreadIfNeeded(), | |
]); |
I think moving the check outside might be better in that case?
if (glibcVersionRuntime && parseFloat(glibcVersionRuntime) <= 2.17) {
let api = WorkerFarm.getWorkerApi();
await api.callMaster({
location: __dirname + '/loadNative.js',
args: [],
});
}
isLoadedOnMainThread = true;
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.
Ah right
Moved the |
@devongovett do you mind approving the CI workflow whenever you can? Curious to see the effect this has on the parcel benchmark suite. |
Looks like the benchmark pipeline has been broken, and performance hasn't been published for a while according to — So nevermind, feel free to merge this if all looks good. |
↪️ Pull Request
While profiling Parcel as it ran on a large app at Atlassian, I noticed that calls to
process.report.getReport()
stood out in the trace —This function is in fact called once per transformation, to get the glibc version on linux and on an average takes 10ms per call. However, the version of glibc on a system isn't likely to change during a parcel run. Moving the call out so it is queried only once led to up to a ~35% improvement in overall build times on Linux.
This was tested on a 15 Core
c6i
AWS box, on Node16.15.0
, with both the SWC and Babel transformers enabled. The % improvement might vary based on individual setups, however, it is still likely to be significant.