-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix 1037 (rebased against master) #1377
Conversation
Thanks for your pull request and interest in making D better, @timotheecour! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. |
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.
Finally looked through this line by line. Looks good apart from the added GC allocation and ConfigEntry
should be called PackageConfigs
or similar. I can make those changes separately, though, as to not further delay this PR unnecessarily.
@@ -142,7 +156,8 @@ class DependencyResolver(CONFIGS, CONFIG) { | |||
|
|||
// get the current config/version of the current dependency | |||
sizediff_t childidx = package_indices[basepack]; | |||
if (all_configs[childidx].length == 1 && all_configs[childidx][0] == CONFIG.invalid) { | |||
auto child = configs[childidx]; | |||
if (child.allConfigs == [CONFIG.invalid]) { |
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.
Produces a GC allocation in the inner loop.
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.
did you measure whether it actually had a performance impact?
also, if it does, StaticArray(Config.invalid) could be used
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.
oh wow that actually uses the GC... who would have thought if you could simply put that array in a separate line as static immutable
to not do that.
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.
Yes, in the sense that I got huge speedups with all allocations removed from that loop. Pretty stupid that this is not optimized away by the compiler automatically.
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.
dlang/druntime#2093 [WIP] core.array.staticArray static array litteral: staticArray(1, 2, 3)
#2093
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.
Definitely an improvement, although I still think that the compiler should be smarter about array literals. It could for example simply infer the possible const
ness of the literal, and if it is not required to be mutable, it can safely allocate a static array instead of issuing a GC allocation (marking it as @nogc
, too).
just a rebase of #1154 from @WebFreak001 against master