https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125334

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <[email protected]>:

https://gcc.gnu.org/g:8a3aa549299337ffee8d808bf7d997b7cb1f99fe

commit r17-1385-g8a3aa549299337ffee8d808bf7d997b7cb1f99fe
Author: Patrick Palka <[email protected]>
Date:   Fri Jun 5 17:05:33 2026 -0400

    c++/modules: disable dependent ADL inside header unit [PR125334]

    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 <[email protected]>

Reply via email to