Conversation
…n -unittest is used
|
Thanks for your pull request and interest in making D better, @alexandrumc! 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. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10759" |
|
It should be possible to revert to the old behavior. Maybe extend the |
|
@alexandrumc Please add an explanation for all of these changes so that we don't have to speculate what the intent is. I assume that you haven't done so because this is a work in progress project, but I suggest that you do it anyway so that reviewers/community members are able to understand what you are trying to do and offer support. |
Done. |
|
You might also want to test what effect your change have on some sample code, e.g. the ones at https://perf.dlang.io/ |
|
How about creating a file Destroy. |
Importing |
Why would you get name clashes?
You will generate code for each template instance exactly once no matter in what module the instantiation is used + you get uniformity for the compilation with |
|
This seems to be obsolete now, given the recent template emission fixes. @alexandrumc please reopen if anything new is added. |
The idea of this PR is to decrease the compilation time when the
-unittestswitch is used.This has to do with the way the current algorithm that generates code for template instantiations works. The algorithm has two branches:
If
-unittestis used, then do code generation for every template that is instantiated and used in a root module, even if the same template is instantiated in some non-root module that is imported.Else (
unittestsnot enabled) prefer instantiations from non-root modules, to minimize object code size. If a template is ever instantiated by non-root modules, do not generate code for it, because it will be generated when the non-root module is compiled.So there are 3 options in my opinion:
the first one is to eliminate the branching and to adopt in every case the same behaviour performed when the
-unittestswitch is used: this might decrease the compile-time and will generate huge binaries because for almost every template instantiation code will be generated, but there will be a unified behaviour in the compilermake the non-unittest behaviour the default, keep binaries small, decrease compilation time when
-unittestis enabled but break a lot of code and force people to change the way they compile and write their codemake a better code generation algorithm for templates (that will use some kind of analysis to determine on which template instantiations code generation should be called and on which shouldn’t be called)
1. this probably will lead to an increase in the binary size (not a huge one, but most likely we won’t be able to do something fine-grained because of the amount of work/time needed)
2. and probably will break some code but not that much and will also decrease the
-unittestcompilation timeSo far I've eliminated the branching from the algorithm and I've made the "if
-unittestis used" behaviour the default one. The next step is to do some measurements regarding the compilation time and based on them to decide what should be done further. I'll update this description with the measurements when I'll have them.