The culprits seem to be consteval_only_p and check_out_of_consteval_use, each accounting for about 10% of compile time (this is with an --enable-checking=release build). $ perf stat -r5 g++-16 -std=c++26 -fsyntax-only libstdc++-v3/include/precompiled/stdc++.h ... Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.42 ... $ perf stat -r5 g++-16 -std=c++26 -fsyntax-only -freflection libstdc++-v3/include/precompiled/stdc++.h ... Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.69 ...
The main problem is that we don't cache consteval_only flag on types. We could cache a 3 state (known to be consteval-only, known not to be consteval-only, unknown), either just on class types or on array/pointer/reference types as well. The main reason for not implementing that was that we don't know what will happen with consteval-only types vs. consteval-only values, i.e. whether it won't be a wasted effort.
Guess we want to meassure this again now.
$ perf stat -r5 xg++ -std=c++26 -fsyntax-only stdc++.h Performance counter stats for 'xg++ -std=c++26 -fsyntax-only stdc++.h' (5 runs): 0 context-switches:u # 0.0 cs/sec cs_per_second 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second 80,458 page-faults:u # 16307.1 faults/sec page_faults_per_second ( +- 0.02% ) 4,933.92 msec task-clock:u # nan CPUs CPUs_utilized ( +- 0.16% ) 101,038,872 branch-misses:u # 1.0 % branch_miss_rate ( +- 0.42% ) (50.01%) 10,492,969,039 branches:u # 2126.7 M/sec branch_frequency ( +- 0.06% ) (50.03%) 26,909,357,524 cpu-cycles:u # 5.5 GHz cycles_frequency ( +- 0.09% ) (66.69%) 58,033,354,072 instructions:u # 2.2 instructions insn_per_cycle ( +- 0.18% ) (50.02%) 8,773,812,719 stalled-cycles-frontend:u # 0.33 frontend_cycles_idle ( +- 0.44% ) (50.00%) 4.943746813 +- 0.007941643 seconds time elapsed ( +- 0.16% ) $ perf stat -r5 xg++ -std=c++26 -fsyntax-only -freflection stdc++.h Performance counter stats for 'xg++ -std=c++26 -fsyntax-only -freflection stdc++.h' (5 runs): 0 context-switches:u # 0.0 cs/sec cs_per_second 0 cpu-migrations:u # 0.0 migrations/sec migrations_per_second 81,099 page-faults:u # 16254.4 faults/sec page_faults_per_second ( +- 0.00% ) 4,989.36 msec task-clock:u # nan CPUs CPUs_utilized ( +- 0.66% ) 102,726,834 branch-misses:u # 1.0 % branch_miss_rate ( +- 0.58% ) (49.98%) 10,681,074,259 branches:u # 2140.8 M/sec branch_frequency ( +- 0.06% ) (50.01%) 27,347,396,329 cpu-cycles:u # 5.5 GHz cycles_frequency ( +- 0.45% ) (66.67%) 59,028,719,550 instructions:u # 2.2 instructions insn_per_cycle ( +- 0.05% ) (50.04%) 8,835,672,943 stalled-cycles-frontend:u # 0.32 frontend_cycles_idle ( +- 0.61% ) (50.01%) 4.999518199 +- 0.033349767 seconds time elapsed ( +- 0.67% )
...which is about 1.12812% increase. So I think it's fixed.