-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Speed up Package.getPackageConfigs #2902
Speed up Package.getPackageConfigs #2902
Conversation
The only package that can have a config already created is the root package, and only if the `config` parameter isn't an empty string. Every other package is in the `configs` array iff it was added by a previous call to this function. The exact same configurations will be found if this function is called again for the same (p, c) pair and it will do needless work that won't modify anything.
✅ PR OK, no changes in deprecations or warnings Total deprecations: 0 Total warnings: 0 Build statistics: statistics (-before, +after)
-executable size=5347800 bin/dub
-rough build time=64s
+executable size=5364184 bin/dub
+rough build time=63s Full build output
|
Cherry-picking dlang/dub#2902.
Looks good as far as I can see. Two additional things caught my eye:
|
Turns out there is actually code that mutates the dependencies of a |
I considered speeding up |
Package.getPackageConfigs
was taking 3 seconds for a particular dub package, which was made worse by the fact it was called multiple times with different arguments. The changes in this PR bring it down to just under 200ms, which IMHO is still slow.Investigating led me to realise that
determineDependencyConfigs
was being called over and over again for the exact same packages, especially common dependencies likemir-algorithm
andunit-threaded
. This PR does two things:First, it makes the array of package dependencies smaller via
.sort.uniq
. This cut down the time by half to 1.5s.Secondly, after taking a while to understand the inner workings of the function, it returns early for packages that have already been analysed. This brought it further down to the 100ms range.