IconDatabase: Move icon retain/release off of the main thread.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 21:49:43 +0000 (21:49 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 21:49:43 +0000 (21:49 +0000)
commit3dcb8761a6f0189a1b9f71ab32ad4848b036b2e1
tree5937001e797bad1ddb8c7db1cc3d48f708a53c91
parent0e70bf856b0d68f06552bc07780697c9e01b1a0d
IconDatabase: Move icon retain/release off of the main thread.
<http://webkit.org/b/85799>
<rdar://problem/9507113>

Reviewed by Brady Eidson.

Batch up the retain/release operations and execute them as part of the sync thread loop.
The batch execution is guarded by a new mutex (m_urlsToRetainOrReleaseLock.)
This avoids blocking the main thread on m_urlAndIconLock for basic retain/release.

There is one exception; if there are pending retain/release operations in synchronousIconForPageURL,
it will acquire the lock and flush the operations.

There should be no behavior change, this is only meant to reduce lock contention.

* loader/icon/PageURLRecord.h:
(WebCore::PageURLRecord::retain):
(WebCore::PageURLRecord::release):

    Added a 'count' argument to these so we can batch up the operations in IconDatabase.

* loader/icon/IconDatabase.h:
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::performScheduleOrDeferSyncTimer):
(WebCore::IconDatabase::performScheduleOrDeferSyncTimerOnMainThread):
(WebCore::IconDatabase::scheduleOrDeferSyncTimer):

    Perform the the timer scheduling on the main thread as it can be done on a different
    thread by way of retainIconForPageURL or releaseIconForPageURL.

(WebCore::IconDatabase::synchronousIconForPageURL):
(WebCore::IconDatabase::retainIconForPageURL):
(WebCore::IconDatabase::performRetainIconForPageURL):
(WebCore::IconDatabase::releaseIconForPageURL):
(WebCore::IconDatabase::performReleaseIconForPageURL):
(WebCore::IconDatabase::retainedPageURLCount):
(WebCore::IconDatabase::IconDatabase):
(WebCore::IconDatabase::performURLImport):
(WebCore::IconDatabase::syncThreadMainLoop):
(WebCore::IconDatabase::performPendingRetainAndReleaseOperations):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117501 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconDatabase.h
Source/WebCore/loader/icon/PageURLRecord.h