<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[149965] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/149965">149965</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2013-05-12 10:50:58 -0700 (Sun, 12 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simplify AutodrainedPool
https://bugs.webkit.org/show_bug.cgi?id=115986

Reviewed by Andreas Kling.

Source/WebCore:

Remove calls to AutodrainedPool::cycle as well as the iteration counter passed to the constructor.
Instead, just declare RAII pools where it seems necessary.

* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::databaseThread):
* fileapi/FileThread.cpp:
(WebCore::FileThread::runLoop):
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::setIconDataForIconURL):
(WebCore::IconDatabase::performURLImport):
(WebCore::IconDatabase::readFromDatabase):

Source/WTF:

Remove the ability to cycle an AutodrainedPool, as well as the iteration count.
Creating and draining pools is fast enough now that we don't need to try to be clever about it.

* wtf/AutodrainedPool.h:
(AutodrainedPool):
(WTF::AutodrainedPool::AutodrainedPool):
* wtf/AutodrainedPoolMac.mm:
(WTF::AutodrainedPool::AutodrainedPool):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfAutodrainedPoolh">trunk/Source/WTF/wtf/AutodrainedPool.h</a></li>
<li><a href="#trunkSourceWTFwtfAutodrainedPoolMacmm">trunk/Source/WTF/wtf/AutodrainedPoolMac.mm</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseDatabaseThreadcpp">trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp</a></li>
<li><a href="#trunkSourceWebCorefileapiFileThreadcpp">trunk/Source/WebCore/fileapi/FileThread.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadericonIconDatabasecpp">trunk/Source/WebCore/loader/icon/IconDatabase.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WTF/ChangeLog        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2013-05-12  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Simplify AutodrainedPool
+        https://bugs.webkit.org/show_bug.cgi?id=115986
+
+        Reviewed by Andreas Kling.
+
+        Remove the ability to cycle an AutodrainedPool, as well as the iteration count.
+        Creating and draining pools is fast enough now that we don't need to try to be clever about it.
+
+        * wtf/AutodrainedPool.h:
+        (AutodrainedPool):
+        (WTF::AutodrainedPool::AutodrainedPool):
+        * wtf/AutodrainedPoolMac.mm:
+        (WTF::AutodrainedPool::AutodrainedPool):
+
+2013-05-12  Anders Carlsson  &lt;andersca@apple.com&gt;
+
</ins><span class="cx">         Move RemoteMemoryReader into FastMalloc.cpp
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=115985
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFwtfAutodrainedPoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/AutodrainedPool.h (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/AutodrainedPool.h        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WTF/wtf/AutodrainedPool.h        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -39,20 +39,15 @@
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(AutodrainedPool);
</span><span class="cx"> public:
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    WTF_EXPORT_PRIVATE explicit AutodrainedPool(int iterationLimit = 1);
</del><ins>+    WTF_EXPORT_PRIVATE AutodrainedPool();
</ins><span class="cx">     WTF_EXPORT_PRIVATE ~AutodrainedPool();
</span><del>-
-    WTF_EXPORT_PRIVATE void cycle();
</del><span class="cx"> #else
</span><del>-    explicit AutodrainedPool(int = 1) { }
</del><ins>+    explicit AutodrainedPool() { }
</ins><span class="cx">     ~AutodrainedPool() { }
</span><del>-    void cycle() { }
</del><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    int m_iterationLimit;
-    int m_iterationCount;
</del><span class="cx">     NSAutoreleasePool* m_pool;
</span><span class="cx"> #endif
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWTFwtfAutodrainedPoolMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/AutodrainedPoolMac.mm (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/AutodrainedPoolMac.mm        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WTF/wtf/AutodrainedPoolMac.mm        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -33,10 +33,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="cx"> 
</span><del>-AutodrainedPool::AutodrainedPool(int iterationLimit)
-    : m_iterationLimit(iterationLimit)
-    , m_iterationCount(0)
-    , m_pool([[NSAutoreleasePool alloc] init])
</del><ins>+AutodrainedPool::AutodrainedPool()
+    : m_pool([[NSAutoreleasePool alloc] init])
</ins><span class="cx"> { 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -45,13 +43,4 @@
</span><span class="cx">     [m_pool drain];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void AutodrainedPool::cycle()
-{
-    if (++m_iterationCount == m_iterationLimit) {
-        [m_pool drain];
-        m_pool = [[NSAutoreleasePool alloc] init];
-        m_iterationCount = 0;
-    }
-}
-
</del><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WebCore/ChangeLog        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2013-05-12  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Simplify AutodrainedPool
+        https://bugs.webkit.org/show_bug.cgi?id=115986
+
+        Reviewed by Andreas Kling.
+
+        Remove calls to AutodrainedPool::cycle as well as the iteration counter passed to the constructor.
+        Instead, just declare RAII pools where it seems necessary.
+
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::databaseThread):
+        * fileapi/FileThread.cpp:
+        (WebCore::FileThread::runLoop):
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::IconDatabase::setIconDataForIconURL):
+        (WebCore::IconDatabase::performURLImport):
+        (WebCore::IconDatabase::readFromDatabase):
+
</ins><span class="cx"> 2013-05-12  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Apply FINAL to the Node hierarchy.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseDatabaseThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -107,10 +107,10 @@
</span><span class="cx">         LOG(StorageAPI, &quot;Started DatabaseThread %p&quot;, this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    AutodrainedPool pool;
</del><span class="cx">     while (OwnPtr&lt;DatabaseTask&gt; task = m_queue.waitForMessage()) {
</span><ins>+        AutodrainedPool pool;
+
</ins><span class="cx">         task-&gt;performTask();
</span><del>-        pool.cycle();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Clean up the list of all pending transactions on this database thread
</span></span></pre></div>
<a id="trunkSourceWebCorefileapiFileThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/fileapi/FileThread.cpp (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/fileapi/FileThread.cpp        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WebCore/fileapi/FileThread.cpp        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -98,10 +98,10 @@
</span><span class="cx">         LOG(FileAPI, &quot;Started FileThread %p&quot;, this);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    AutodrainedPool pool;
</del><span class="cx">     while (OwnPtr&lt;Task&gt; task = m_queue.waitForMessage()) {
</span><ins>+        AutodrainedPool pool;
+
</ins><span class="cx">         task-&gt;performTask();
</span><del>-        pool.cycle();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     LOG(FileAPI, &quot;About to detach thread %i and clear the ref to FileThread %p, which currently has %i ref(s)&quot;, m_threadID, this, refCount());
</span></span></pre></div>
<a id="trunkSourceWebCoreloadericonIconDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/icon/IconDatabase.cpp (149964 => 149965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/icon/IconDatabase.cpp        2013-05-12 17:47:29 UTC (rev 149964)
+++ trunk/Source/WebCore/loader/icon/IconDatabase.cpp        2013-05-12 17:50:58 UTC (rev 149965)
</span><span class="lines">@@ -586,15 +586,11 @@
</span><span class="cx">         // Start the timer to commit this change - or further delay the timer if it was already started
</span><span class="cx">         scheduleOrDeferSyncTimer();
</span><span class="cx"> 
</span><del>-        // Informal testing shows that draining the autorelease pool every 25 iterations is about as low as we can go
-        // before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up        
-        AutodrainedPool pool(25);
-
</del><span class="cx">         for (unsigned i = 0; i &lt; pageURLs.size(); ++i) {
</span><ins>+            AutodrainedPool pool;
+
</ins><span class="cx">             LOG(IconDatabase, &quot;Dispatching notification that retaining pageURL %s has a new icon&quot;, urlForLogging(pageURLs[i]).ascii().data());
</span><span class="cx">             m_client-&gt;didChangeIconForPageURL(pageURLs[i]);
</span><del>-
-            pool.cycle();
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -1231,18 +1227,15 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    // Informal testing shows that draining the autorelease pool every 25 iterations is about as low as we can go
-    // before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
-    AutodrainedPool pool(25);
-        
</del><span class="cx">     int result = query.step();
</span><span class="cx">     while (result == SQLResultRow) {
</span><ins>+        AutodrainedPool pool;
</ins><span class="cx">         String pageURL = query.getColumnText(0);
</span><span class="cx">         String iconURL = query.getColumnText(1);
</span><span class="cx"> 
</span><span class="cx">         {
</span><span class="cx">             MutexLocker locker(m_urlAndIconLock);
</span><del>-            
</del><ins>+
</ins><span class="cx">             PageURLRecord* pageRecord = m_pageURLToRecordMap.get(pageURL);
</span><span class="cx">             
</span><span class="cx">             // If the pageRecord doesn't exist in this map, then no one has retained this pageURL
</span><span class="lines">@@ -1278,8 +1271,6 @@
</span><span class="cx">             if (m_pageURLsPendingImport.contains(pageURL)) {
</span><span class="cx">                 dispatchDidImportIconURLForPageURLOnMainThread(pageURL);
</span><span class="cx">                 m_pageURLsPendingImport.remove(pageURL);
</span><del>-            
-                pool.cycle();
</del><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="lines">@@ -1350,12 +1341,12 @@
</span><span class="cx">     LOG(IconDatabase, &quot;Notifying %lu interested page URLs that their icon URL is known due to the import&quot;, static_cast&lt;unsigned long&gt;(urlsToNotify.size()));
</span><span class="cx">     // Now that we don't hold any locks, perform the actual notifications
</span><span class="cx">     for (unsigned i = 0; i &lt; urlsToNotify.size(); ++i) {
</span><ins>+        AutodrainedPool pool;
+
</ins><span class="cx">         LOG(IconDatabase, &quot;Notifying icon info known for pageURL %s&quot;, urlsToNotify[i].ascii().data());
</span><span class="cx">         dispatchDidImportIconURLForPageURLOnMainThread(urlsToNotify[i]);
</span><span class="cx">         if (shouldStopThreadActivity())
</span><span class="cx">             return;
</span><del>-
-        pool.cycle();
</del><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     // Notify the client that the URL import is complete in case it's managing its own pending notifications.
</span><span class="lines">@@ -1599,20 +1590,14 @@
</span><span class="cx">         if (shouldStopThreadActivity())
</span><span class="cx">             return didAnyWork;
</span><span class="cx">         
</span><del>-        // Informal testing shows that draining the autorelease pool every 25 iterations is about as low as we can go
-        // before performance starts to drop off, but we don't want to increase this number because then accumulated memory usage will go up
-        AutodrainedPool pool(25);
-
</del><span class="cx">         // Now that we don't hold any locks, perform the actual notifications
</span><del>-        HashSet&lt;String&gt;::iterator iter = urlsToNotify.begin();
-        HashSet&lt;String&gt;::iterator end = urlsToNotify.end();
-        for (unsigned iteration = 0; iter != end; ++iter, ++iteration) {
-            LOG(IconDatabase, &quot;Notifying icon received for pageURL %s&quot;, urlForLogging(*iter).ascii().data());
-            dispatchDidImportIconDataForPageURLOnMainThread(*iter);
</del><ins>+        for (HashSet&lt;String&gt;::const_iterator it = urlsToNotify.begin(), end = urlsToNotify.end(); it != end; ++it) {
+            AutodrainedPool pool;
+
+            LOG(IconDatabase, &quot;Notifying icon received for pageURL %s&quot;, urlForLogging(*it).ascii().data());
+            dispatchDidImportIconDataForPageURLOnMainThread(*it);
</ins><span class="cx">             if (shouldStopThreadActivity())
</span><span class="cx">                 return didAnyWork;
</span><del>-            
-            pool.cycle();
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         LOG(IconDatabase, &quot;Done notifying %i pageURLs who just received their icons&quot;, urlsToNotify.size());
</span></span></pre>
</div>
</div>

</body>
</html>