Ignore:
Timestamp:
May 3, 2010, 7:39:23 PM (15 years ago)
Author:
Stephanie Lewis
Message:

https://bugs.webkit.org/show_bug.cgi?id=38368
<rdar://problem/7834433> REGRESSSION: 1.5% PLT regression due to 56028
(return memory quicker).
Instead of returning everything but the smallest spans spread out
the spans kept over several size lists.

Reviewed by Geoff Garen.

  • wtf/FastMalloc.cpp:

(WTF::TCMalloc_PageHeap::scavenge):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r58355 r58730  
    12741274static const float kScavengePercentage = .5f;
    12751275
    1276 // Number of free committed pages that we want to keep around.
    1277 static const size_t kMinimumFreeCommittedPageCount = 512;
     1276// number of span lists to keep spans in when memory is returned.
     1277static const int kMinSpanListsWithSpans = 32;
     1278
     1279// Number of free committed pages that we want to keep around.  The minimum number of pages used when there
     1280// is 1 span in each of the first kMinSpanListsWithSpans spanlists.  Currently 528 pages.
     1281static const size_t kMinimumFreeCommittedPageCount = kMinSpanListsWithSpans * ((1.0f+kMinSpanListsWithSpans) / 2.0f);
    12781282
    12791283#endif
     
    15351539    size_t targetPageCount = std::max<size_t>(kMinimumFreeCommittedPageCount, free_committed_pages_ - pagesToRelease);
    15361540
    1537     for (int i = kMaxPages; i >= 0 && free_committed_pages_ > targetPageCount; i--) {
    1538         SpanList* slist = (static_cast<size_t>(i) == kMaxPages) ? &large_ : &free_[i];
    1539         while (!DLL_IsEmpty(&slist->normal) && free_committed_pages_ > targetPageCount) {
    1540             Span* s = slist->normal.prev;
    1541             DLL_Remove(s);
    1542             ASSERT(!s->decommitted);
    1543             if (!s->decommitted) {
    1544                 TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift),
    1545                                        static_cast<size_t>(s->length << kPageShift));
    1546                 ASSERT(free_committed_pages_ >= s->length);
    1547                 free_committed_pages_ -= s->length;
    1548                 s->decommitted = true;
     1541    while (free_committed_pages_ > targetPageCount) {
     1542        for (int i = kMaxPages; i > 0 && free_committed_pages_ >= targetPageCount; i--) {
     1543            SpanList* slist = (static_cast<size_t>(i) == kMaxPages) ? &large_ : &free_[i];
     1544            // If the span size is bigger than kMinSpanListsWithSpans pages return all the spans in the list, else return all but 1 span. 
     1545            // Return only 50% of a spanlist at a time so spans of size 1 are not the only ones left.
     1546            size_t numSpansToReturn = (i > kMinSpanListsWithSpans) ? DLL_Length(&slist->normal) : static_cast<size_t>(.5 * DLL_Length(&slist->normal));
     1547            for (int j = 0; static_cast<size_t>(j) < numSpansToReturn && !DLL_IsEmpty(&slist->normal) && free_committed_pages_ > targetPageCount; j++) {
     1548                Span* s = slist->normal.prev;
     1549                DLL_Remove(s);
     1550                ASSERT(!s->decommitted);
     1551                if (!s->decommitted) {
     1552                    TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift),
     1553                                           static_cast<size_t>(s->length << kPageShift));
     1554                    ASSERT(free_committed_pages_ >= s->length);
     1555                    free_committed_pages_ -= s->length;
     1556                    s->decommitted = true;
     1557                }
     1558                DLL_Prepend(&slist->returned, s);
    15491559            }
    1550             DLL_Prepend(&slist->returned, s);
    15511560        }
    15521561    }
Note: See TracChangeset for help on using the changeset viewer.