[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

ggaren at apple.com ggaren at apple.com
Fri Feb 26 22:25:13 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit aa7b3c18fe4eedcc4aa3e53fd3438d094d2f62b3
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Feb 18 22:15:34 2010 +0000

    Fixed a portion of:
    <rdar://problem/7165917> | https://bugs.webkit.org/show_bug.cgi?id=28676
    Safari 4 does not release memory back to the operating system fast enough (28676)
    
    Reviewed by Oliver Hunt.
    
    This patch fixes a surprisingly common edge case in which the page heap
    would have only one free span, but that span would be larger than the
    minimum free size, so we would decide not to free it, even though it
    could be as large as 100MB or more!
    
    SunSpider reports no change on Mac or Windows.
    
    * wtf/FastMalloc.cpp:
    (WTF::TCMalloc_PageHeap::scavenge): Call shouldContinueScavenging() instead
    of doing the math ourselves. Don't keep a local value for pagesDecommitted
    because that lets free_committed_pages_ be wrong temporarily. Instead,
    update free_committed_pages_ as we go. ASSERT that we aren't releasing
    a span that has already been released, because we think this is impossible.
    Finally, don't be afraid to release all free memory in the page heap when
    scavenging. We only scavenge after 5 seconds of the application's working
    set not growing, and we keep both thread caches and a central cache on
    top of the page heap, so the extra free pages in the page heap were just
    overkill.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54988 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6447fa4..101b79e 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-02-17  Geoffrey Garen  <ggaren at apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Fixed a portion of:
+        <rdar://problem/7165917> | https://bugs.webkit.org/show_bug.cgi?id=28676
+        Safari 4 does not release memory back to the operating system fast enough (28676)
+        
+        This patch fixes a surprisingly common edge case in which the page heap
+        would have only one free span, but that span would be larger than the
+        minimum free size, so we would decide not to free it, even though it
+        could be as large as 100MB or more!
+        
+        SunSpider reports no change on Mac or Windows.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::TCMalloc_PageHeap::scavenge): Call shouldContinueScavenging() instead
+        of doing the math ourselves. Don't keep a local value for pagesDecommitted
+        because that lets free_committed_pages_ be wrong temporarily. Instead,
+        update free_committed_pages_ as we go. ASSERT that we aren't releasing
+        a span that has already been released, because we think this is impossible.
+        Finally, don't be afraid to release all free memory in the page heap when
+        scavenging. We only scavenge after 5 seconds of the application's working
+        set not growing, and we keep both thread caches and a central cache on
+        top of the page heap, so the extra free pages in the page heap were just
+        overkill.
+
 2010-02-17  Gavin Barraclough  <barraclough at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/JavaScriptCore/wtf/FastMalloc.cpp b/JavaScriptCore/wtf/FastMalloc.cpp
index 79d2bfb..90d1e3f 100644
--- a/JavaScriptCore/wtf/FastMalloc.cpp
+++ b/JavaScriptCore/wtf/FastMalloc.cpp
@@ -1248,13 +1248,6 @@ static const int kScavengeTimerDelayInSeconds = 5;
 // Number of free committed pages that we want to keep around.
 static const size_t kMinimumFreeCommittedPageCount = 512;
 
-// During a scavenge, we'll release up to a fraction of the free committed pages.
-#if OS(WINDOWS)
-// We are slightly less aggressive in releasing memory on Windows due to performance reasons.
-static const int kMaxScavengeAmountFactor = 3;
-#else
-static const int kMaxScavengeAmountFactor = 2;
-#endif
 #endif
 
 class TCMalloc_PageHeap {
@@ -1507,39 +1500,35 @@ ALWAYS_INLINE void TCMalloc_PageHeap::signalScavenger()
 
 #endif
 
-void TCMalloc_PageHeap::scavenge() 
+void TCMalloc_PageHeap::scavenge()
 {
-    // If we have to commit memory in the last 5 seconds, it means we don't have enough free committed pages
-    // for the amount of allocations that we do.  So hold off on releasing memory back to the system.
+    // If we've recently commited pages, our working set is growing, so now is
+    // not a good time to free pages.
     if (pages_committed_since_last_scavenge_ > 0) {
         pages_committed_since_last_scavenge_ = 0;
         return;
     }
-    Length pagesDecommitted = 0;
-    for (int i = kMaxPages; i >= 0; i--) {
+
+    for (int i = kMaxPages; i >= 0 && shouldContinueScavenging(); i--) {
         SpanList* slist = (static_cast<size_t>(i) == kMaxPages) ? &large_ : &free_[i];
         if (!DLL_IsEmpty(&slist->normal)) {
             // Release the last span on the normal portion of this list
             Span* s = slist->normal.prev; 
-            // Only decommit up to a fraction of the free committed pages if pages_allocated_since_last_scavenge_ > 0.
-            if ((pagesDecommitted + s->length) * kMaxScavengeAmountFactor > free_committed_pages_)
-                continue;
             DLL_Remove(s);
-            TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift),
-                                   static_cast<size_t>(s->length << kPageShift));
+            ASSERT(!s->decommitted);
             if (!s->decommitted) {
-                pagesDecommitted += s->length;
+                TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift),
+                                       static_cast<size_t>(s->length << kPageShift));
+                ASSERT(free_committed_pages_ >= s->length);
+                free_committed_pages_ -= s->length;
                 s->decommitted = true;
             }
             DLL_Prepend(&slist->returned, s);
-            // We can stop scavenging if the number of free committed pages left is less than or equal to the minimum number we want to keep around.
-            if (free_committed_pages_ <= kMinimumFreeCommittedPageCount + pagesDecommitted)
-                break;
         }
     }
+
+    ASSERT(!shouldContinueScavenging());
     pages_committed_since_last_scavenge_ = 0;
-    ASSERT(free_committed_pages_ >= pagesDecommitted);
-    free_committed_pages_ -= pagesDecommitted;
 }
 
 ALWAYS_INLINE bool TCMalloc_PageHeap::shouldContinueScavenging() const 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list