Skip to content
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

Merged
merged 4 commits into from
Feb 14, 2018
Merged

Conversation

timotheecour
Copy link

just a rebase of #1154 from @WebFreak001 against master

@dlang-bot
Copy link
Collaborator

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • My PR follows the DStyle
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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.

@timotheecour timotheecour mentioned this pull request Feb 12, 2018
Copy link
Member

@s-ludwig s-ludwig left a 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]) {
Copy link
Member

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.

Copy link
Author

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

@timotheecour timotheecour Feb 14, 2018

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

Copy link
Member

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 constness 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants