Bug 167387

Summary: Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS
Product: WebKit Reporter: Andreas Kling <kling>
Component: Web Template FrameworkAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, buildbot, cdumez, cmarcelo, commit-queue, dbates, kling, rniwa
Priority: P2 Keywords: InRadar, Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP
none
Patch for EWS
buildbot: commit-queue-
Patch for review
koivisto: review+
Archive of layout-test-results from ews107 for mac-elcapitan-wk2
none
Patch for EWS again
buildbot: commit-queue-
Archive of layout-test-results from ews106 for mac-elcapitan-wk2
none
Patch for landing none

Description Andreas Kling 2017-01-24 14:54:03 PST
Instead of manipulating the process assertion, let's implement the alwaysRunsAtBackgroundPriority setting by having a global thread QoS override.

<rdar://problem/29711409>
Comment 1 Andreas Kling 2017-01-24 14:56:01 PST
Created attachment 299634 [details]
WIP
Comment 2 WebKit Commit Bot 2017-01-24 14:57:07 PST
Attachment 299634 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/ChildProcessProxy.cpp:56:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/Threading.cpp:146:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/Threading.cpp:149:  Should have a space between // and comment  [whitespace/comments] [4]
ERROR: Source/WTF/wtf/Threading.cpp:150:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 4 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Andreas Kling 2017-01-24 15:27:49 PST
This hook point is not early enough, we're still creating some WorkQueues with too high QoS level.
Comment 4 Andreas Kling 2017-01-24 15:31:19 PST
Created attachment 299641 [details]
Patch for EWS

Okay, I think this will do the trick. Hooking in XPCServiceInitializer() means we set the QoS override before a ChildProcess object is constructed.
Comment 5 Andreas Kling 2017-01-24 15:46:24 PST
Created attachment 299643 [details]
Patch for review
Comment 6 Build Bot 2017-01-24 16:56:51 PST
Comment on attachment 299641 [details]
Patch for EWS

Attachment 299641 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2943433

New failing tests:
media/modern-media-controls/media-controller/media-controller-auto-hide-rewind-with-mouse-enter.html
media/modern-media-controls/media-controller/media-controller-auto-hide-mouse-leave-after-play.html
http/tests/misc/slow-loading-animated-image.html
accessibility/mac/aria-multiple-liveregions-notification.html
Comment 7 Build Bot 2017-01-24 16:56:56 PST
Created attachment 299655 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 8 Andreas Kling 2017-01-24 19:32:22 PST
Created attachment 299668 [details]
Patch for EWS again

Let's try that patch for EWS again, apparently there were a lot of flaky tests getting skipped today.
Comment 9 Build Bot 2017-01-24 21:17:25 PST
Comment on attachment 299668 [details]
Patch for EWS again

Attachment 299668 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/2944578

New failing tests:
media/modern-media-controls/media-controller/media-controller-auto-hide-rewind-with-mouse-enter.html
media/modern-media-controls/media-controller/media-controller-auto-hide-mouse-leave-after-play.html
http/tests/misc/slow-loading-animated-image.html
Comment 10 Build Bot 2017-01-24 21:17:30 PST
Created attachment 299680 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 11 Ryosuke Niwa 2017-01-24 21:28:38 PST
Wait, there are two patches listed here. Which one is the good one?
Comment 12 Andreas Kling 2017-01-24 21:44:32 PST
(In reply to comment #11)
> Wait, there are two patches listed here. Which one is the good one?

Sorry about the confusion. The "Patch for EWS" has the alwaysRunsAtBackgroundPriority setting hardcoded to "on", because I wanted to exercise the full suite of layout tests in this mode.

The "Patch for review" is the one to actually read and review :)

@Gavin, could you take a look at my changes and let me know what you think?
Comment 13 Antti Koivisto 2017-02-01 00:37:12 PST
Comment on attachment 299643 [details]
Patch for review

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

> Source/WTF/wtf/Threading.cpp:148
> +qos_class_t adjustedQOSClass(qos_class_t originalClass)
> +{
> +    if (globalQOSOverride != QOS_CLASS_UNSPECIFIED)
> +        return globalQOSOverride;
> +    return originalClass;
> +}

Since you are using setGlobalQOSOverride(QOS_CLASS_UTILITY) you are increasing the priority of the QOS_CLASS_BACKGROUND threads. Is that really the intention? Instead of an override should this rather be about setting a maximum QOS class?

> Source/WebKit2/UIProcess/ChildProcessProxy.cpp:34
> +ChildProcessProxy::ChildProcessProxy(bool alwaysRunsAtBackgroundPriority)

Enum would be more stylish.

> Source/bmalloc/bmalloc/Heap.h:73
> +    qos_class_t takeRequestedQOSClass() { return std::exchange(m_requestedQOSClass, QOS_CLASS_UNSPECIFIED); }
> +    void setQOSOverride(qos_class_t overrideClass) { m_requestedQOSClass = overrideClass; }

Should the names be more specific, like "ScavengerThreadQOSClass"?
Comment 14 Andreas Kling 2017-02-01 03:52:23 PST
Created attachment 300316 [details]
Patch for landing
Comment 15 WebKit Commit Bot 2017-02-01 06:56:26 PST
Comment on attachment 300316 [details]
Patch for landing

Clearing flags on attachment: 300316

Committed r211482: <http://trac.webkit.org/changeset/211482>
Comment 16 WebKit Commit Bot 2017-02-01 06:56:34 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 Chris Dumez 2017-02-03 10:56:12 PST
FYI, we have a fairly major Speedometer regression on iOS and this commit is in the range. This is not the only suspicious commit though.