-
Notifications
You must be signed in to change notification settings - Fork 275
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: Performance improvements #4959
Conversation
|
||
const relativePath = file.path.slice(this.ownPath.length) | ||
// We use absolute paths so the first part of the split is always an empty string | ||
const [_, subpathSegment, nextSegment] = relativePath.split(path.sep) |
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.
Here I wasn't sure if we normalize everything to POSIX paths also for glob compatibility, or if we do need to use path.sep
so that windows paths get split correctly as well.
That probably would also impact the .startsWith
part above.
Wow! This is super awesome! 🚀 Huge thanks for such a great job! ✨ |
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.
Amazing work! Thank you! I've left a few non-blocking comments, LGTM! 💯
…ost of some more memory See https://github.com/nodejs/node/blob/main/doc/api/cli.md#useful-v8-options Also see https://www.alibabacloud.com/blog/better-node-application-performance-through-gc-optimization_595119 and nodejs/node#42511 for some details on impact
d256c3b
to
3e643e7
Compare
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.
💯 🚀
What this PR does / why we need it:
This PR adds a bunch of performance improvements, and replaces Bluebird with native promises.
Bluebird
Let's start off with Bluebird: The bluebird repo itself recommends moving to native promises and bluebird is no longer seeing any changes. Meanwhile native promises have seen big performance improvements and also usually show up better in stack traces and in performance profiles.
Repo scan tree indexing
The main performance improvement comes for
GARDEN_GIT_SCAN_MODE=repo
.It now indexes the list of files into a tree structure for faster access yielding large improvements in graph resolution speeds for large projects.
Here's a comparison between the current
main
version and the updated one, run on an M2 mac on a repo of 11032 files with 500 modules.Using
main
:Using this PR:
As you can see the overall performance improvements are still moderate, but the graph resolution is almost 2x faster.
This makes the
repo
scan mode the most performant option especially when running in our single binary build which seems to have a lot of overhead for the default scan mode.For comparison here are both scan modes with our current
0.13.12
binary version on the same repo:You can see that the
repo
scan mode shows identical performance to the version running just onnode
for development.Meanwhile graph resolution on the default scan mode with the binary takes 26 seconds to resolve the graph while just on
node
it's around 15 seconds (not in the outputs above since I didn't want to add even more noisy text here).So the new implementation with
repo
mode should outperform the default scan mode in the binary by a good 3x still when it comes to graph resolution.GC Improvements
We increase
max-semi-space
to 64M which should lead to less GC pauses and better performance at the cost of slightly higher memory consumption.See https://github.com/nodejs/node/blob/main/doc/api/cli.md#useful-v8-options
Also see https://www.alibabacloud.com/blog/better-node-application-performance-through-gc-optimization_595119 and nodejs/node#42511 for some details on impact.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: