This PR reports that building <bits/stdc++.h> as a header unit later
slows down initial std module stream-in by around 2x compared to if
the std module is built without the header unit, i.e.
g++ -fmodules -fsearch-include-path bits/std.cc
g++ -fmodules testcase.C # 15% slower vs before r16-6311
vs
g++ -fmodules -fsearch-include-path bits/stdc++.h bits/std.cc
g++ -fmodules testcase.C # 100% slower vs before r16-6311
This happens after the dependent ADL patch r16-6311. My initial theory
for the slowdown was that the ADL step adds in many more dependency edges
between entities and results in larger SCC clusters, making lazy loading
less lazy, but the number of overall clusters doesn't seem to significantly
before/after the patch. So I have no idea why there's such a big slowdown
and why header units are affected more.
But my basic understanding of the dependent ADL part of reachability
analysis is that it's not really needed when building a header unit
because header units don't discard or hide any entities.
So this patch disables it for header units which restores std module
stream-in back to pre r16-6311 levels when <bits/stdc++.h> is built as a
header unit. When built without the header unit then std module stream-in
is still about 15% slower. Maybe there's ways to safely speed up that
case too (e.g. only add dependency edges to GMF entities?) but I'll
leave that as future work.
PR c++/125334
gcc/cp/ChangeLog:
* module.cc (depset::hash::add_dependent_adl_entities):
Disable when inside a header unit.
Reviewed-by: Jason Merrill <jason@redhat.com>
depset::hash::add_dependent_adl_entities (tree expr)
{
gcc_checking_assert (!is_key_order ());
+
+ /* This is not needed for header units where everything is
+ visible to name lookup, nothing is discarded. */
+ if (header_module_p ())
+ return;
+
if (TREE_CODE (current->get_entity ()) != TEMPLATE_DECL)
return;