Bug 213705

Summary: RunLoop::dispatch should only call wakeUp when needed
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: New BugsAssignee: Geoffrey Garen <ggaren>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, beidson, benjamin, cdumez, cmarcelo, ews-watchlist, sam, sihui_liu, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Geoffrey Garen 2020-06-28 16:05:09 PDT
RunLoop::dispatch should only call wakeUp when needed
Comment 1 Geoffrey Garen 2020-06-28 16:06:25 PDT
Created attachment 403013 [details]
Patch
Comment 2 Geoffrey Garen 2020-06-28 16:09:01 PDT
Comment on attachment 403013 [details]
Patch

Oops! I had planned to remove the functionsHandled behavior separately from this patch -- but it's actually not correct until you do both, since functionsHandled is willing to exit without a wakeUp. :(
Comment 3 Geoffrey Garen 2020-06-28 16:33:11 PDT
Created attachment 403014 [details]
Patch
Comment 4 Sam Weinig 2020-06-28 17:23:51 PDT
Comment on attachment 403014 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403014&action=review

> Source/WTF/ChangeLog:10
> +        RunLoop::wakeUp is super expensive (at least on Darwin platforms). Back
> +        when IndexedDB used RunLoop::dispatch, RunLoop::wakeUp accounted for 15%
> +        of all database lookup time.

Out of interest (and for the historical record) what makes it so expensive?
Comment 5 Geoffrey Garen 2020-06-28 20:03:25 PDT
Most of the cost seemed to be its usage of pthread mutexes.
Comment 6 Sam Weinig 2020-06-28 20:22:36 PDT
(In reply to Geoffrey Garen from comment #5)
> Most of the cost seemed to be its usage of pthread mutexes.

Is "its" here CFRunLoopWakeUp()? Or something we are doing in WTF?
Comment 7 Geoffrey Garen 2020-06-28 21:28:24 PDT
Created attachment 403027 [details]
Patch
Comment 8 Geoffrey Garen 2020-06-28 21:29:09 PDT
> Is "its" here CFRunLoopWakeUp()? Or something we are doing in WTF?

It's CFRunLoopSourceSignal and CFRunLoopWakeUp.
Comment 9 Geoffrey Garen 2020-06-30 21:54:01 PDT
Created attachment 403264 [details]
Patch
Comment 10 Geoffrey Garen 2020-07-01 21:24:48 PDT
Created attachment 403343 [details]
Patch
Comment 11 Geoffrey Garen 2020-07-02 15:34:39 PDT
Created attachment 403408 [details]
Patch
Comment 12 Geoffrey Garen 2020-07-02 16:16:46 PDT
Comment on attachment 403408 [details]
Patch

Looks like EWS is happy now.
Comment 13 EWS 2020-07-06 10:15:54 PDT
Committed r263973: <https://trac.webkit.org/changeset/263973>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403408 [details].
Comment 14 Radar WebKit Bug Importer 2020-07-06 10:16:18 PDT
<rdar://problem/65137000>