Title: [219705] trunk/Source/WebKit
Revision
219705
Author
[email protected]
Date
2017-07-20 14:09:26 -0700 (Thu, 20 Jul 2017)

Log Message

Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
https://bugs.webkit.org/show_bug.cgi?id=174686

Reviewed by Geoffrey Garen.

Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords(). The most common
call site is already on the right thread.

* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
* UIProcess/WebResourceLoadStatisticsStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (219704 => 219705)


--- trunk/Source/WebKit/ChangeLog	2017-07-20 21:09:12 UTC (rev 219704)
+++ trunk/Source/WebKit/ChangeLog	2017-07-20 21:09:26 UTC (rev 219705)
@@ -1,5 +1,22 @@
 2017-07-20  Chris Dumez  <[email protected]>
 
+        Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
+        https://bugs.webkit.org/show_bug.cgi?id=174686
+
+        Reviewed by Geoffrey Garen.
+
+        Avoid unnecessary WorkQueue dispatch in WebResourceLoadStatisticsStore::processStatisticsAndDataRecords(). The most common
+        call site is already on the right thread.
+
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (-[WKWebsiteDataStore _resourceLoadStatisticsProcessStatisticsAndDataRecords]):
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
+        (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+
+2017-07-20  Chris Dumez  <[email protected]>
+
         Regression(ITP): May get frequently logged out of wsj.com
         https://bugs.webkit.org/show_bug.cgi?id=174661
         <rdar://problem/32343256>

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (219704 => 219705)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2017-07-20 21:09:12 UTC (rev 219704)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2017-07-20 21:09:26 UTC (rev 219705)
@@ -378,7 +378,7 @@
     if (!store)
         return;
 
-    store->processStatisticsAndDataRecords();
+    store->scheduleStatisticsAndDataRecordsProcessing();
 }
 
 - (void)_resourceLoadStatisticsUpdateCookiePartitioning

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (219704 => 219705)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-07-20 21:09:12 UTC (rev 219704)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2017-07-20 21:09:26 UTC (rev 219705)
@@ -204,27 +204,35 @@
     });
 }
 
+void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing()
+{
+    ASSERT(RunLoop::isMain());
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
+        processStatisticsAndDataRecords();
+    });
+}
+
 void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
 {
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] () {
-        if (m_parameters.shouldClassifyResourcesBeforeDataRecordsRemoval) {
-            for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
-                if (!resourceStatistic.isPrevalentResource && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
-                    resourceStatistic.isPrevalentResource = true;
-            }
-        }
-        removeDataRecords();
-        
-        pruneStatisticsIfNeeded();
+    ASSERT(!RunLoop::isMain());
 
-        if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
-            RunLoop::main().dispatch([] {
-                WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
-            });
+    if (m_parameters.shouldClassifyResourcesBeforeDataRecordsRemoval) {
+        for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
+            if (!resourceStatistic.isPrevalentResource && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
+                resourceStatistic.isPrevalentResource = true;
         }
+    }
+    removeDataRecords();
 
-        m_persistentStorage.scheduleOrWriteMemoryStore();
-    });
+    pruneStatisticsIfNeeded();
+
+    if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
+        RunLoop::main().dispatch([] {
+            WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
+        });
+    }
+
+    m_persistentStorage.scheduleOrWriteMemoryStore();
 }
 
 void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& origins)

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (219704 => 219705)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2017-07-20 21:09:12 UTC (rev 219704)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2017-07-20 21:09:26 UTC (rev 219705)
@@ -93,7 +93,7 @@
     void setSubresourceUniqueRedirectTo(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedTo);
     void scheduleCookiePartitioningUpdate();
     void scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, ShouldClearFirst);
-    void processStatisticsAndDataRecords();
+    void scheduleStatisticsAndDataRecordsProcessing();
     void submitTelemetry();
     void scheduleCookiePartitioningStateReset();
 
@@ -139,6 +139,7 @@
     void updateCookiePartitioningForDomains(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, ShouldClearFirst);
     void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
     WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
+    void processStatisticsAndDataRecords();
 
     void resetCookiePartitioningState();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to