RESOLVED FIXED311831
Build time improvement: Use extern template instantiation for high-traffic mpark::variant instantiations
https://bugs.webkit.org/show_bug.cgi?id=311831
Summary Build time improvement: Use extern template instantiation for high-traffic mp...
Brent Fulgham
Reported 2026-04-09 10:19:00 PDT
Reduce redundant template instantiation across translation units by adding explicit template instantiation for commonly used mpark::variant types in widely-included WebCore headers. This reduces compile time by avoiding the repeated template expansions (which have to be culled at link time). Currently every translation unit does a template expansion of the variant machinery, which has to be removed at a later build step. Both operations add time to the build. On my system, this current patch reduced build time by 5.4%.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-04-09 10:19:18 PDT
Brent Fulgham
Comment 2 2026-04-09 10:29:58 PDT
Brent Fulgham
Comment 4 2026-04-09 15:55:13 PDT
Results from my M4 MBP: ``` ==================================================================================================== AGGREGATE CATEGORY COMPARISON (matched TUs only) ==================================================================================================== Frontend 12256.4s -> 12232.8s (-23.6s, -0.2%) Backend 4271.6s -> 4273.3s (+1.7s, +0.0%) ParseClass 4611.2s -> 4537.8s (-73.4s, -1.6%) InstantiateFunction 12829.7s -> 12745.9s (-83.7s, -0.7%) InstantiateClass 5116.3s -> 5150.7s (+34.4s, +0.7%) PerformPendingInstantiations 2382.6s -> 2315.5s (-67.1s, -2.8%) CodeGen Function 516.6s -> 537.4s (+20.8s, +4.0%) OptFunction 1413.2s -> 1426.0s (+12.8s, +0.9%) OptModule 2554.0s -> 2532.5s (-21.5s, -0.8%) ==================================================================================================== FINAL SUMMARY — build IMPROVED by 18.0s (0.8%) ==================================================================================================== Total compile time: 16674.0s -> 16655.9s (-18.0s, -0.8%) Frontend -23.6s (-0.2%) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Backend +1.7s (+0.0%) >> ParseClass -73.4s (-1.6%) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< InstantiateFunction -83.7s (-0.7%) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< InstantiateClass +34.4s (+0.7%) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PerformPendingInstantiations -67.1s (-2.8%) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CodeGen Function +20.8s (+4.0%) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OptFunction +12.8s (+0.9%) >>>>>>>>>>>>>>>>>>>>> OptModule -21.5s (-0.8%) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Template instantiations (net): -49.3s time saved: -1266.0s (templates faster or removed) time added: +1216.7s (templates slower or new) ```
Brent Fulgham
Comment 5 2026-04-09 15:55:32 PDT
Note: The 5.4% was for a different patch. This small change only nets 0.8%.
EWS
Comment 6 2026-04-17 15:15:46 PDT
Committed 311479@main (c69a763f29d8): <https://commits.webkit.org/311479@main> Reviewed commits have been landed. Closing PR #62367 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.