Bug 278700
Summary: | Reduce ThreadSafeRefCounted compile time | ||
---|---|---|---|
Product: | WebKit | Reporter: | Gerald Squelart <g_squelart> |
Component: | Web Template Framework | Assignee: | Gerald Squelart <g_squelart> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | |||
Bug Blocks: | 278821 |
Gerald Squelart
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
<rdar://problem/134756505>
Gerald Squelart
Pull request: https://github.com/WebKit/WebKit/pull/32749
EWS
Committed 282871@main (9ed2e706b2c7): <https://commits.webkit.org/282871@main>
Reviewed commits have been landed. Closing PR #32749 and removing active labels.