Title: [253621] trunk
Revision
253621
Author
you...@apple.com
Date
2019-12-17 03:50:27 -0800 (Tue, 17 Dec 2019)

Log Message

Bump the priority of CacheStorageEngine write operations
https://bugs.webkit.org/show_bug.cgi?id=205329

Reviewed by Antti Koivisto.

Source/WebKit:

Introduce an IOChannel extra optional parameter to set the QOS.
Use this parameter for IOChannels created by CacheStorageEngine when writing files to increase the priority to default.
Increase the priority of the CacheStorageEngine background queue to default.
No observable change of behavior except potential speed increase.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::Engine):
(WebKit::CacheStorage::Engine::writeFile):
* NetworkProcess/cache/NetworkCacheIOChannel.h:
(WebKit::NetworkCache::IOChannel::open):
* NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
(WebKit::NetworkCache::dispatchQueueFromPriority):
(WebKit::NetworkCache::IOChannel::IOChannel):
(WebKit::NetworkCache::IOChannel::open):
* NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
(WebKit::NetworkCache::IOChannel::open):
* NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
(WebKit::NetworkCache::IOChannel::open):

LayoutTests:

* http/tests/cache-storage/page-cache-domcachestorage-pending-promise.html:
Increase timer.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253620 => 253621)


--- trunk/LayoutTests/ChangeLog	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/LayoutTests/ChangeLog	2019-12-17 11:50:27 UTC (rev 253621)
@@ -1,3 +1,13 @@
+2019-12-17  youenn fablet  <you...@apple.com>
+
+        Bump the priority of CacheStorageEngine write operations
+        https://bugs.webkit.org/show_bug.cgi?id=205329
+
+        Reviewed by Antti Koivisto.
+
+        * http/tests/cache-storage/page-cache-domcachestorage-pending-promise.html:
+        Increase timer.
+
 2019-12-17  Thibault Saunier  <tsaun...@igalia.com>
 
         [GStreamer][WPE] Fix regressions related to our 'Fix GStreamer capturer mock' patch

Modified: trunk/LayoutTests/http/tests/cache-storage/page-cache-domcachestorage-pending-promise.html (253620 => 253621)


--- trunk/LayoutTests/http/tests/cache-storage/page-cache-domcachestorage-pending-promise.html	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/LayoutTests/http/tests/cache-storage/page-cache-domcachestorage-pending-promise.html	2019-12-17 11:50:27 UTC (rev 253621)
@@ -30,7 +30,7 @@
         if (window.internals)
             console.log(await internals.cacheStorageEngineRepresentation());
         finishJSTest();
-    }, 10000);
+    }, 20000);
 
     caches.open('test').then(() => {
        clearTimeout(handle1);

Modified: trunk/Source/WebKit/ChangeLog (253620 => 253621)


--- trunk/Source/WebKit/ChangeLog	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/ChangeLog	2019-12-17 11:50:27 UTC (rev 253621)
@@ -1,5 +1,31 @@
 2019-12-17  youenn fablet  <you...@apple.com>
 
+        Bump the priority of CacheStorageEngine write operations
+        https://bugs.webkit.org/show_bug.cgi?id=205329
+
+        Reviewed by Antti Koivisto.
+
+        Introduce an IOChannel extra optional parameter to set the QOS.
+        Use this parameter for IOChannels created by CacheStorageEngine when writing files to increase the priority to default.
+        Increase the priority of the CacheStorageEngine background queue to default.
+        No observable change of behavior except potential speed increase.
+
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::Engine):
+        (WebKit::CacheStorage::Engine::writeFile):
+        * NetworkProcess/cache/NetworkCacheIOChannel.h:
+        (WebKit::NetworkCache::IOChannel::open):
+        * NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
+        (WebKit::NetworkCache::dispatchQueueFromPriority):
+        (WebKit::NetworkCache::IOChannel::IOChannel):
+        (WebKit::NetworkCache::IOChannel::open):
+        * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
+        (WebKit::NetworkCache::IOChannel::open):
+        * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
+        (WebKit::NetworkCache::IOChannel::open):
+
+2019-12-17  youenn fablet  <you...@apple.com>
+
         WebKitTestRunner should report service worker process crashes
         https://bugs.webkit.org/show_bug.cgi?id=205267
 

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (253620 => 253621)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2019-12-17 11:50:27 UTC (rev 253621)
@@ -266,7 +266,7 @@
     , m_rootPath(WTFMove(rootPath))
 {
     if (!m_rootPath.isNull())
-        m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background);
+        m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serial.default", WorkQueue::Type::Serial, WorkQueue::QOS::Default);
 }
 
 void Engine::open(const WebCore::ClientOrigin& origin, const String& cacheName, CacheIdentifierCallback&& callback)
@@ -466,7 +466,7 @@
         if (!FileSystem::fileExists(directoryPath))
             FileSystem::makeAllDirectories(directoryPath);
 
-        auto channel = IOChannel::open(filename, IOChannel::Type::Create);
+        auto channel = IOChannel::open(filename, IOChannel::Type::Create, WorkQueue::QOS::Default);
         channel->write(0, data, nullptr, [this, weakThis = WTFMove(weakThis), identifier](int error) mutable {
             ASSERT(RunLoop::isMain());
             if (!weakThis)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h (253620 => 253621)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h	2019-12-17 11:50:27 UTC (rev 253621)
@@ -42,7 +42,7 @@
 class IOChannel : public ThreadSafeRefCounted<IOChannel> {
 public:
     enum class Type { Read, Write, Create };
-    static Ref<IOChannel> open(const String& file, Type);
+    static Ref<IOChannel> open(const String& file, Type type, Optional<WorkQueue::QOS> qos = { }) { return adoptRef(*new IOChannel(file, type, qos)); }
 
     // Using nullptr as queue submits the result to the main queue.
     // FIXME: We should add WorkQueue::main() instead.
@@ -61,7 +61,7 @@
     ~IOChannel();
 
 private:
-    IOChannel(const String& filePath, IOChannel::Type);
+    IOChannel(const String& filePath, IOChannel::Type, Optional<WorkQueue::QOS>);
 
 #if USE(SOUP)
     void readSyncInThread(size_t offset, size_t, WorkQueue*, Function<void (Data&, int error)>&&);

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm (253620 => 253621)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm	2019-12-17 11:50:27 UTC (rev 253621)
@@ -37,7 +37,21 @@
 namespace WebKit {
 namespace NetworkCache {
 
-IOChannel::IOChannel(const String& filePath, Type type)
+static long dispatchQueueIdentifier(WorkQueue::QOS qos)
+{
+    switch (qos) {
+    case WorkQueue::QOS::UserInteractive:
+    case WorkQueue::QOS::UserInitiated:
+    case WorkQueue::QOS::Default:
+        return DISPATCH_QUEUE_PRIORITY_DEFAULT;
+    case WorkQueue::QOS::Utility:
+        return DISPATCH_QUEUE_PRIORITY_LOW;
+    case WorkQueue::QOS::Background:
+        return DISPATCH_QUEUE_PRIORITY_BACKGROUND;
+    }
+}
+
+IOChannel::IOChannel(const String& filePath, Type type, Optional<WorkQueue::QOS> qos)
     : m_path(filePath)
     , m_type(type)
 {
@@ -44,7 +58,7 @@
     auto path = FileSystem::fileSystemRepresentation(filePath);
     int oflag;
     mode_t mode;
-    bool useLowIOPriority = false;
+    WorkQueue::QOS dispatchQOS;
 
     switch (m_type) {
     case Type::Create:
@@ -52,22 +66,23 @@
         unlink(path.data());
         oflag = O_RDWR | O_CREAT | O_NONBLOCK;
         mode = S_IRUSR | S_IWUSR;
-        useLowIOPriority = true;
+        dispatchQOS = qos.valueOr(WorkQueue::QOS::Background);
         break;
     case Type::Write:
         oflag = O_WRONLY | O_NONBLOCK;
         mode = S_IRUSR | S_IWUSR;
-        useLowIOPriority = true;
+        dispatchQOS = qos.valueOr(WorkQueue::QOS::Background);
         break;
     case Type::Read:
         oflag = O_RDONLY | O_NONBLOCK;
         mode = 0;
+        dispatchQOS = qos.valueOr(WorkQueue::QOS::Default);
     }
 
     int fd = ::open(path.data(), oflag, mode);
     m_fileDescriptor = fd;
 
-    m_dispatchIO = adoptOSObject(dispatch_io_create(DISPATCH_IO_RANDOM, fd, dispatch_get_global_queue(useLowIOPriority ? DISPATCH_QUEUE_PRIORITY_BACKGROUND : DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [fd](int) {
+    m_dispatchIO = adoptOSObject(dispatch_io_create(DISPATCH_IO_RANDOM, fd, dispatch_get_global_queue(dispatchQueueIdentifier(dispatchQOS), 0), [fd](int) {
         close(fd);
     }));
     ASSERT(m_dispatchIO.get());
@@ -81,11 +96,6 @@
     RELEASE_ASSERT(!m_wasDeleted.exchange(true));
 }
 
-Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type)
-{
-    return adoptRef(*new IOChannel(filePath, type));
-}
-
 void IOChannel::read(size_t offset, size_t size, WorkQueue* queue, Function<void (Data&, int error)>&& completionHandler)
 {
     RefPtr<IOChannel> channel(this);

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp (253620 => 253621)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2019-12-17 11:50:27 UTC (rev 253621)
@@ -31,7 +31,7 @@
 namespace WebKit {
 namespace NetworkCache {
 
-IOChannel::IOChannel(const String& filePath, Type type)
+IOChannel::IOChannel(const String& filePath, Type type, Optional<WorkQueue::QOS>)
     : m_path(filePath)
     , m_type(type)
 {
@@ -55,11 +55,6 @@
     FileSystem::closeFile(m_fileDescriptor);
 }
 
-Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type)
-{
-    return adoptRef(*new IOChannel(filePath, type));
-}
-
 static inline void runTaskInQueue(Function<void()>&& task, WorkQueue* queue)
 {
     if (queue) {

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp (253620 => 253621)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp	2019-12-17 11:33:17 UTC (rev 253620)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp	2019-12-17 11:50:27 UTC (rev 253621)
@@ -37,7 +37,7 @@
 
 static const size_t gDefaultReadBufferSize = 4096;
 
-IOChannel::IOChannel(const String& filePath, Type type)
+IOChannel::IOChannel(const String& filePath, Type type, Optional<WorkQueue::QOS>)
     : m_path(filePath)
     , m_type(type)
 {
@@ -68,11 +68,6 @@
     RELEASE_ASSERT(!m_wasDeleted.exchange(true));
 }
 
-Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type)
-{
-    return adoptRef(*new IOChannel(filePath, type));
-}
-
 static inline void runTaskInQueue(Function<void ()>&& task, WorkQueue* queue)
 {
     if (queue) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to