Bug 231418 - Clearly distinguish serial from concurrent WorkQueue
Summary: Clearly distinguish serial from concurrent WorkQueue
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jean-Yves Avenard [:jya]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-08 03:54 PDT by Jean-Yves Avenard [:jya]
Modified: 2021-10-13 17:39 PDT (History)
21 users (show)

See Also:


Attachments
Patch (46.08 KB, patch)
2021-10-09 00:48 PDT, Jean-Yves Avenard [:jya]
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (47.78 KB, patch)
2021-10-09 02:08 PDT, Jean-Yves Avenard [:jya]
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (47.82 KB, patch)
2021-10-09 02:40 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (47.95 KB, patch)
2021-10-09 05:08 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (47.96 KB, patch)
2021-10-09 05:47 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (49.57 KB, patch)
2021-10-12 00:58 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (49.44 KB, patch)
2021-10-12 16:04 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (49.33 KB, patch)
2021-10-13 15:20 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (48.06 KB, patch)
2021-10-13 15:46 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Yves Avenard [:jya] 2021-10-08 03:54:42 PDT
Currently we have a unique WorkQueue object, which can be configured at construction time to be either a concurrent or a serial one.

A concurrent WorkQueue doesn't guarantee the order in which the queued tasks will run.

That makes for a footgun if a consumer takes a WorkQueue and is expecting it to be a serial one.

We should split the WorkQueue into a ConcurrentWorkQueue object, and make WorkQueue be a serial one.
Comment 1 Radar WebKit Bug Importer 2021-10-08 03:55:03 PDT
<rdar://problem/84021977>
Comment 2 Jean-Yves Avenard [:jya] 2021-10-09 00:48:02 PDT
Created attachment 440702 [details]
Patch
Comment 3 Jean-Yves Avenard [:jya] 2021-10-09 02:08:22 PDT
Created attachment 440705 [details]
Patch
Comment 4 Jean-Yves Avenard [:jya] 2021-10-09 02:40:31 PDT
Created attachment 440706 [details]
Patch
Comment 5 Jean-Yves Avenard [:jya] 2021-10-09 05:08:16 PDT
Created attachment 440708 [details]
Patch
Comment 6 Jean-Yves Avenard [:jya] 2021-10-09 05:47:46 PDT
Created attachment 440709 [details]
Patch
Comment 7 Jean-Yves Avenard [:jya] 2021-10-12 00:58:28 PDT
Created attachment 440905 [details]
Patch
Comment 8 Chris Dumez 2021-10-12 09:56:07 PDT
Comment on attachment 440905 [details]
Patch

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

EWS is red.

> Source/WTF/wtf/WorkQueue.h:59
> +    enum class Type {

: bool

> Source/WTF/wtf/WorkQueue.h:63
> +    static Ref<WorkQueueBase> create(const char* name, Type, QOS);

Why is this factory function still here? We shouldn't need it.

> Source/WTF/wtf/WorkQueue.h:87
> +class WorkQueue : public WorkQueueBase {

Should be marked as final.

> Source/WTF/wtf/WorkQueue.h:97
> +protected:

Why protected? Seems the constructor should be private. Are there any subclasses of WorkQueue?

> Source/WTF/wtf/WorkQueue.h:115
> +class ConcurrentWorkQueue : public WorkQueueBase {

final
Comment 9 Jean-Yves Avenard [:jya] 2021-10-12 14:39:47 PDT
Comment on attachment 440905 [details]
Patch

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

>> Source/WTF/wtf/WorkQueue.h:59
>> +    enum class Type {
> 
> : bool

when it's existing code like this being moved, I typically keep it as-is.

>> Source/WTF/wtf/WorkQueue.h:87
>> +class WorkQueue : public WorkQueueBase {
> 
> Should be marked as final.

There's SuspendableWorkQueue ; this class and how the IOCache works is the primary reason I went with WebKitBase over the templated version we talked about.

I believe it's WorkQueue people should be inheriting from rather than WorkQueueBase.

>> Source/WTF/wtf/WorkQueue.h:97
>> +protected:
> 
> Why protected? Seems the constructor should be private. Are there any subclasses of WorkQueue?

yes SuspendableWorkQueue
Comment 10 Chris Dumez 2021-10-12 14:41:27 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #9)
> Comment on attachment 440905 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=440905&action=review
> 
> >> Source/WTF/wtf/WorkQueue.h:59
> >> +    enum class Type {
> > 
> > : bool
> 
> when it's existing code like this being moved, I typically keep it as-is.

Not the WebKit policy though. In WebKit we clean up as we modify existing code since we rarely do pure clean up commits.

> 
> >> Source/WTF/wtf/WorkQueue.h:87
> >> +class WorkQueue : public WorkQueueBase {
> > 
> > Should be marked as final.
> 
> There's SuspendableWorkQueue ; this class and how the IOCache works is the
> primary reason I went with WebKitBase over the templated version we talked
> about.
> 
> I believe it's WorkQueue people should be inheriting from rather than
> WorkQueueBase.
> 
> >> Source/WTF/wtf/WorkQueue.h:97
> >> +protected:
> > 
> > Why protected? Seems the constructor should be private. Are there any subclasses of WorkQueue?
> 
> yes SuspendableWorkQueue
Comment 11 Jean-Yves Avenard [:jya] 2021-10-12 16:04:56 PDT
Created attachment 441010 [details]
Patch

rebase, apply comments
Comment 12 Chris Dumez 2021-10-13 10:05:04 PDT
Comment on attachment 441010 [details]
Patch

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

> Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h:53
> +    // For safety, it should use a serial WorkQueue (see https://bugs.webkit.org/show_bug.cgi?id=231472)

I still don't understand this comment and I don't think it is accurate. Cocoa uses a concurrent WorkQueue and the code is safe.
Comment 13 Jean-Yves Avenard [:jya] 2021-10-13 14:00:34 PDT
Comment on attachment 441010 [details]
Patch

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

>> Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h:53
>> +    // For safety, it should use a serial WorkQueue (see https://bugs.webkit.org/show_bug.cgi?id=231472)
> 
> I still don't understand this comment and I don't think it is accurate. Cocoa uses a concurrent WorkQueue and the code is safe.

Yes, this comment is incorrect. Forgot to remove it
Comment 14 Chris Dumez 2021-10-13 14:01:09 PDT
Comment on attachment 441010 [details]
Patch

Ok, r=me but please drop the comment.
Comment 15 Chris Dumez 2021-10-13 14:01:35 PDT
Comment on attachment 441010 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:11
> +        Reviewed by NOBODY (OOPS!).

This is supposed to be above the description, not under.

> Source/WTF/ChangeLog:19
> +        Reviewed by NOBODY (OOPS!).

This is supposed to be above the description, not under.
Comment 16 Jean-Yves Avenard [:jya] 2021-10-13 15:20:42 PDT
Created attachment 441145 [details]
Patch
Comment 17 Jean-Yves Avenard [:jya] 2021-10-13 15:33:28 PDT
grrr another rebasing issue
Comment 18 Jean-Yves Avenard [:jya] 2021-10-13 15:46:58 PDT
Created attachment 441151 [details]
Patch

rebase
Comment 19 EWS 2021-10-13 17:09:25 PDT
Committed r284135 (242955@main): <https://commits.webkit.org/242955@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 441151 [details].
Comment 20 Yusuke Suzuki 2021-10-13 17:39:29 PDT
Committed r284137 (242957@main): <https://commits.webkit.org/242957@main>