[Issue 14431] [REG 2.067.0] huge slowdown of compilation speed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jun 27 13:57:50 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14431

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #12 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to Martin Nowak from comment #7)
> This slowdown comes from
> https://github.com/D-Programming-Language/dmd/pull/4384, which does
> instantiate additional templates in order to resolve link bugs.
> The problem is amplified by using single file compilation.

The trouble is the compiler would not instantiate a template if that template
was already instantiated by an imported model, on the assumption that the
instantiation would exist in the object code generated when the imported module
was separately compiled.

The problem was that if A imports B, and B imports A, A and B are compiled
separately, and so the template was never instantiated (see
https://issues.dlang.org/show_bug.cgi?id=2644). The 4384 fixed this by always
instantiating templates if the imported module also imported root modules, as
computed by TemplateInstance::needsCodegen().

The trouble with that, and the slowdown, is the commonplace practice of having
every module in a project import every other module.

An obvious workaround for users is to compile modules that mutually import each
other on the same command to dmd.

A possible solution to this was proposed by Martin Nowak:

"I think we should define a rule for which module is responsible for the
instantiation when they mutually import each other. I'd suggest that the module
with the lexicographically smaller module name does it."

--


More information about the Digitalmars-d-bugs mailing list