-
Notifications
You must be signed in to change notification settings - Fork 71
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] lib/compiler.js makes too many stat() calls #167
Comments
If you want to see for yourself:
You may have to remount If you just want to count the number of system calls:
|
This problem is slowing down @ritch I would like to bump up the priority of this issue and fix the performance in both |
I can spend some time on this in the week of January 16. LMK if I should. |
@bnoordhuis thank you for the offer, any help is welcome! Specifically in loopback-boot, I think there is another place where we are repeating the same filesystem query - see Lines 685 to 694 in 9cb3d06
function resolveAppScriptPath(rootDir, relativePath, resolveOptions) {
var resolvedPath = resolveAppPath(rootDir, relativePath, resolveOptions);
if (!resolvedPath) {
return false;
}
var sourceDir = path.dirname(resolvedPath);
var files = tryReadDir(sourceDir);
var fixedFile = fixFileExtension(resolvedPath, files, false);
return (fixedFile === undefined ? resolvedPath : fixedFile);
} Whenever we are trying to resolve an extension-less name to a real require-able file name, we read the content of the directory. I don't have profiling data to prove this adds significant overhead, it's just my guess. Other places calling |
I created a simple breakdown of how long the different parts of
This break-down shows that the execution of loopback-boot takes only about ~10% of the startup time. Most of the time is spent loading ( Given this data, I think optimising filesystem access in loopback-boot is not worth our effort right now, because the effect on real applications will be minimal. @bnoordhuis thoughts? Can you advise how to analyse which (sub)dependencies of loopback and strong-globalize are contributing most to the unusually high load time? BTW when I had loopback-boot npm-linked into loopback-workspace, the load time went from ~38ms to ~429ms. I think this suggests loopback-boot is sharing quite few dependencies with loopback (npm@3 is using flat layout in node_modules, when loopback-boot is installed locally then it can use the same |
I'll take a look, I have time today. What loopback-boot version did you benchmark? Master? |
loopback-boot branch |
Since there was no activity here for almost two years, and our focus is on LB4+ now, I am closing this issue as stale/abandoned. |
Profiling loopback-sample-app start-up time, from the ~6500 stat() system calls, about 2000 originate from
fixFileExtension()
and to a lesser extenttryResolveAppPath()
inlib/compiler.js
(thefs.existsSync()
call - why are you using that?)Related, I managed to bring down the number of calls from node.js core to ~2800 from ~4700 in nodejs/node#4575 by caching more aggressively. Perhaps a similar strategy is possible in
lib/compiler.js
?The text was updated successfully, but these errors were encountered: