Diff
Modified: trunk/Source/WebCore/ChangeLog (276647 => 276648)
--- trunk/Source/WebCore/ChangeLog 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebCore/ChangeLog 2021-04-27 18:13:56 UTC (rev 276648)
@@ -1,3 +1,17 @@
+2021-04-27 Chris Dumez <[email protected]>
+
+ Ask LocalStorage database to free as much memory as possible on memory pressure
+ https://bugs.webkit.org/show_bug.cgi?id=225109
+
+ Reviewed by Geoffrey Garen.
+
+ Add releaseMemory() function to SQLiteDatabase that calls sqlite3_db_release_memory()
+ to free as much memory as possible.
+
+ * platform/sql/SQLiteDatabase.cpp:
+ (WebCore::SQLiteDatabase::releaseMemory):
+ * platform/sql/SQLiteDatabase.h:
+
2021-04-27 Brent Fulgham <[email protected]>
[iOS] [GPU] The UI process should issue the mach sandbox extension to 'com.apple.AGXCompilerService'
Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (276647 => 276648)
--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp 2021-04-27 18:13:56 UTC (rev 276648)
@@ -635,4 +635,12 @@
sqlite3_create_collation_v2(m_db, collationName.utf8().data(), SQLITE_UTF8, nullptr, nullptr, nullptr);
}
+void SQLiteDatabase::releaseMemory()
+{
+ if (!m_db)
+ return;
+
+ sqlite3_db_release_memory(m_db);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.h (276647 => 276648)
--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.h 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.h 2021-04-27 18:13:56 UTC (rev 276648)
@@ -146,6 +146,8 @@
WEBCORE_EXPORT static void setIsDatabaseOpeningForbidden(bool);
+ WEBCORE_EXPORT void releaseMemory();
+
private:
static int authorizerFunction(void*, int, const char*, const char*, const char*, const char*);
Modified: trunk/Source/WebKit/ChangeLog (276647 => 276648)
--- trunk/Source/WebKit/ChangeLog 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/ChangeLog 2021-04-27 18:13:56 UTC (rev 276648)
@@ -1,3 +1,30 @@
+2021-04-27 Chris Dumez <[email protected]>
+
+ Ask LocalStorage database to free as much memory as possible on memory pressure
+ https://bugs.webkit.org/show_bug.cgi?id=225109
+
+ Reviewed by Geoffrey Garen.
+
+ Ask LocalStorage database to free as much memory as possible on memory pressure.
+ Some of the strings in the database can be large and we don't want SQLite to be
+ holding on to those for performance reason when we are under memory pressure.
+
+ This seems to be a ~1.75% improvement on PLUM/nytimes-home and a ~1% improvement
+ on PLUM/wikipedia, sadly not enough to show an impact on the overal PLUM score.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::lowMemoryHandler):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
+ (WebKit::LocalStorageDatabase::handleLowMemoryWarning):
+ * NetworkProcess/WebStorage/LocalStorageDatabase.h:
+ * NetworkProcess/WebStorage/StorageArea.cpp:
+ (WebKit::StorageArea::handleLowMemoryWarning):
+ * NetworkProcess/WebStorage/StorageArea.h:
+ * NetworkProcess/WebStorage/StorageManagerSet.cpp:
+ (WebKit::StorageManagerSet::handleLowMemoryWarning):
+ * NetworkProcess/WebStorage/StorageManagerSet.h:
+
2021-04-27 Don Olmstead <[email protected]>
[CMake] Don't use FORWARDING_HEADERS_DIR for GTK WebKit headers
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2021-04-27 18:13:56 UTC (rev 276648)
@@ -309,6 +309,8 @@
networkSession.clearPrefetchCache();
});
+ m_storageManagerSet->handleLowMemoryWarning();
+
#if ENABLE(SERVICE_WORKER)
for (auto& swServer : m_swServers.values())
swServer->handleLowMemoryWarning();
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2021-04-27 18:13:56 UTC (rev 276648)
@@ -549,7 +549,7 @@
HashMap<PAL::SessionID, std::unique_ptr<NetworkSession>> m_networkSessions;
HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions;
- RefPtr<StorageManagerSet> m_storageManagerSet;
+ Ref<StorageManagerSet> m_storageManagerSet;
#if PLATFORM(COCOA)
void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp 2021-04-27 18:13:56 UTC (rev 276648)
@@ -362,4 +362,10 @@
return !query.getColumnInt(0);
}
+void LocalStorageDatabase::handleLowMemoryWarning()
+{
+ if (m_database.isOpen())
+ m_database.releaseMemory();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h 2021-04-27 18:13:56 UTC (rev 276648)
@@ -59,6 +59,8 @@
// Will block until all pending changes have been written to disk.
void close();
+ void handleLowMemoryWarning();
+
private:
LocalStorageDatabase(Ref<WorkQueue>&&, Ref<LocalStorageDatabaseTracker>&&, const WebCore::SecurityOriginData&);
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp 2021-04-27 18:13:56 UTC (rev 276648)
@@ -227,4 +227,10 @@
m_localStorageDatabase->close();
}
+void StorageArea::handleLowMemoryWarning()
+{
+ if (m_localStorageDatabase)
+ m_localStorageDatabase->handleLowMemoryWarning();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageArea.h 2021-04-27 18:13:56 UTC (rev 276648)
@@ -73,6 +73,8 @@
void syncToDatabase();
void close();
+ void handleLowMemoryWarning();
+
private:
void dispatchEvents(IPC::Connection::UniqueID sourceConnection, StorageAreaImplIdentifier, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.cpp 2021-04-27 18:13:56 UTC (rev 276648)
@@ -129,6 +129,15 @@
});
}
+void StorageManagerSet::handleLowMemoryWarning()
+{
+ ASSERT(RunLoop::isMain());
+ m_queue->dispatch([this, protectedThis = makeRef(*this)] {
+ for (auto& storageArea : m_storageAreas.values())
+ storageArea->handleLowMemoryWarning();
+ });
+}
+
void StorageManagerSet::waitUntilTasksFinished()
{
ASSERT(RunLoop::isMain());
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h (276647 => 276648)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h 2021-04-27 18:10:58 UTC (rev 276647)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h 2021-04-27 18:13:56 UTC (rev 276648)
@@ -57,6 +57,7 @@
void addConnection(IPC::Connection&);
void removeConnection(IPC::Connection&);
+ void handleLowMemoryWarning();
void waitUntilTasksFinished();
void waitUntilSyncingLocalStorageFinished();
void suspend(CompletionHandler<void()>&&);