WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
278700
Reduce ThreadSafeRefCounted compile time
https://bugs.webkit.org/show_bug.cgi?id=278700
Summary
Reduce ThreadSafeRefCounted compile time
Gerald Squelart
Reported
2024-08-26 22:29:12 PDT
Found with -ftime-trace and ClangBuildAnalyzer, the top-3 "templates that took longest to instantiate" are:
> 110395 ms (35802 times, avg 3 ms): WTF::Function<void ()>::Function<(lambda at /Volumes/WebKit/Internal/WebKit/WebKitBuild/Debug/usr/local/include/wtf/ThreadSafeRefCounted.h:143:27), void> > 76389 ms (35802 times, avg 2 ms): WTF::makeUnique<WTF::Detail::CallableWrapper<(lambda at /Volumes/WebKit/Internal/WebKit/WebKitBuild/Debug/usr/local/include/wtf/ThreadSafeRefCounted.h:143:27), void>, (lambda at /Volumes/WebKit/Internal/WebKit/WebKitBuil... > 66481 ms (35802 times, avg 1 ms): std::make_unique<WTF::Detail::CallableWrapper<(lambda at /Volumes/WebKit/Internal/WebKit/WebKitBuild/Debug/usr/local/include/wtf/ThreadSafeRefCounted.h:143:27), void>, (lambda at /Volumes/WebKit/Internal/WebKit/WebKitBui...
And at #25 of "Template sets that took longest to instantiate":
> 129369 ms (35838 times, avg 3 ms): WTF::ThreadSafeRefCounted<$>::deref
This is due to ThreadSafeRefCounted<T, DestructionThread>::deref doing a `switch` on the templated enum `DestructionThread`, and for some of them moving a lambda into a `WTF::Function`, which itself always calls WTF::makeUnique. By changing this `switch` into a sequence of `if constexpr` blocks, it's possible to pretty much squash these big compile times out of the top-1000, only leaving a small template set taking less than 4% of the original time:
> 4666 ms (2065 times, avg 2 ms): WTF::ThreadSafeRefCounted<$>::deref
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-08-26 22:29:20 PDT
<
rdar://problem/134756505
>
Gerald Squelart
Comment 2
2024-08-26 22:40:28 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/32749
EWS
Comment 3
2024-08-28 15:25:48 PDT
Committed
282871@main
(9ed2e706b2c7): <
https://commits.webkit.org/282871@main
> Reviewed commits have been landed. Closing PR #32749 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