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

            Bug ID: 129265
           Summary: [15/16 Regression] [modules] lazy loading ineffective
                    since GCC 15.1
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bas.van.dijk at cern dot ch
  Target Milestone: ---

a module exports 320 classes that refer to each other in pairs through
std::vector and std::map, plus one small unrelated class Small (holds a
std::string). t.cpp imports the module and only uses Small. With GCC 14 the
importer takes about 0.05 s. Since GCC 15.1 it takes as long as with
-fno-module-lazy, as if the whole module were loaded.

-------------------------------------------------------------------------------
// m.cppm
module;
#include <map>
#include <string>
#include <vector>
export module m;
export struct Small { std::string s; };
#define PAIR(i) export struct A##i; export struct B##i; \
  export struct A##i { std::vector<B##i*> v; std::map<int, B##i*> m; }; \
  export struct B##i { std::vector<A##i*> v; };
#define TEN(x) PAIR(x##0) PAIR(x##1) PAIR(x##2) PAIR(x##3) PAIR(x##4) \
               PAIR(x##5) PAIR(x##6) PAIR(x##7) PAIR(x##8) PAIR(x##9)
TEN(a) TEN(b) TEN(c) TEN(d) TEN(e) TEN(f) TEN(g) TEN(h)
TEN(i) TEN(j) TEN(k) TEN(l) TEN(m) TEN(n) TEN(o) TEN(p)
-------------------------------------------------------------------------------
// t.cpp
import m;
int main() { Small s; return (int)s.s.size(); }
-------------------------------------------------------------------------------
g++ -std=c++20 -fmodules-ts -x c++ -c m.cppm -o m.o
time g++ -std=c++20 -fmodules-ts -fsyntax-only t.cpp                   (lazy,
default)
time g++ -std=c++20 -fmodules-ts -fno-module-lazy -fsyntax-only t.cpp  (not
lazy)

Compiler        Lazy / not lazy
14.3.0          0.047 s / 0.585 s
15.1.0          0.533 s / 0.707 s
15.2.0          0.680 s / 0.701 s
16.1.0          0.726 s / 0.745 s

Reply via email to