WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
311452
Build Time Improvement: Move variant-heavy inline functions from CalcTree headers to .cpp files
https://bugs.webkit.org/show_bug.cgi?id=311452
Summary
Build Time Improvement: Move variant-heavy inline functions from CalcTree hea...
Brent Fulgham
Reported
2026-04-03 17:07:20 PDT
The CSSCalc::Node (38-type variant) and Style::Calculation::Node (33-type variant) trigger expensive mpark::variant template instantiations (constructor, destructor, move_constructor, switchOn dispatch) in every translation unit that includes their headers. This patch moves convenience functions that create, move, or switchOn these variant types from inline definitions in headers to their corresponding .cpp files. This avoids unnecessary variant template instantiation in files that include the headers but don't call these functions. (1) CSSCalcTree.h => CSSCalcTree.cpp: * isNumeric() (switchOn over 38-type variant)add(), multiply(), subtract() * makeChildWithValueBasedOn() (4 overloads) (2) StyleCalculationTree.h => StyleCalculationTree.cpp: * number(), percentage(), dimension() * add(), multiply(), subtract(), blend() Note: Trivial move constructors/operators (Children, ChildOrNone) were left inline to avoid runtime overhead on hot paths.
Attachments
Add attachment
proposed patch, testcase, etc.
Brent Fulgham
Comment 1
2026-04-03 17:35:41 PDT
Build data from -ftrace-time comparing builds: 1. -21.13s (21.26s -> 0.12s, -99.4%) [221 -> 1 TUs] WebCore::CSSCalc::Child::switchOn<(lambda ... 2. -21.01s (21.13s -> 0.12s, -99.4%) [221 -> 1 TUs] WTF::visitOneVariant<0UL, WTF::Visitor<(lambda ... 3. -4.60s (4.64s -> 0.03s, -99.3%) [221 -> 1 TUs] WTF::visitOneVariant<32UL, WTF::Visitor<(lambda ... 4. -2.90s (2.90s -> 0.00s, -100.0%) [200 -> 0 TUs] WebCore::CSSCalc::Child::switchOn<(lambda ... 5. -2.84s (2.84s -> 0.00s, -100.0%) [200 -> 0 TUs] WTF::visitOneVariant<0UL, WTF::Visitor<(lambda ... 6. -1.46s (1.46s -> 0.00s, -99.7%) [229 -> 1 TUs] WebCore::Style::Calculation::makeChild<WebCore::Style::Calculation::Blend> 7. -1.41s (1.42s -> 0.00s, -99.7%) [229 -> 1 TUs] WebCore::Style::Calculation::ChildConstruction<WebCore::Style::Calculation::Blend>::make 8. -1.15s (1.15s -> 0.00s, -99.6%) [221 -> 1 TUs] WebCore::CSSCalc::makeChild<WebCore::CSSCalc::Negate> 9. -1.11s (1.11s -> 0.00s, -99.6%) [221 -> 1 TUs] WebCore::CSSCalc::ChildConstruction<WebCore::CSSCalc::Negate>::make 10. -0.99s (0.99s -> 0.00s, -99.6%) [229 -> 1 TUs] WebCore::Style::Calculation::makeChild<WebCore::Style::Calculation::Negate>
Radar WebKit Bug Importer
Comment 2
2026-04-03 17:35:57 PDT
<
rdar://problem/174049948
>
Brent Fulgham
Comment 3
2026-04-03 17:38:39 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/62009
EWS
Comment 4
2026-04-07 11:12:47 PDT
Committed
310727@main
(0bd48dfc0abc): <
https://commits.webkit.org/310727@main
> Reviewed commits have been landed. Closing PR #62009 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug