Bug 167387 - Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS
Summary: Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: InRadar, Performance
Depends on:
Blocks:
 
Reported: 2017-01-24 14:54 PST by Andreas Kling
Modified: 2017-02-03 10:56 PST (History)
9 users (show)

See Also:


Attachments
WIP (13.70 KB, patch)
2017-01-24 14:56 PST, Andreas Kling
no flags Details | Formatted Diff | Diff
Patch for EWS (15.94 KB, patch)
2017-01-24 15:31 PST, Andreas Kling
buildbot: commit-queue-
Details | Formatted Diff | Diff
Patch for review (19.75 KB, patch)
2017-01-24 15:46 PST, Andreas Kling
koivisto: review+
Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (907.01 KB, application/zip)
2017-01-24 16:56 PST, Build Bot
no flags Details
Patch for EWS again (15.94 KB, patch)
2017-01-24 19:32 PST, Andreas Kling
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (1.09 MB, application/zip)
2017-01-24 21:17 PST, Build Bot
no flags Details
Patch for landing (20.09 KB, patch)
2017-02-01 03:52 PST, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.