Query glibc version only once to speed up JSTransformer on Linux#9117
Conversation
|
|
||
| async function loadOnMainThreadIfNeeded() { | ||
| if ( | ||
| !isLoadedOnMainThread && |
There was a problem hiding this comment.
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.
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
Else, its called once per transform —
parcel/packages/transformers/js/src/JSTransformer.js
Lines 308 to 314 in db3bcae
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;|
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
c6iAWS 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.