Author: [EMAIL PROTECTED]
Date: Fri Dec  5 09:37:12 2008
New Revision: 926

Modified:
    branches/bleeding_edge/src/zone.cc
    branches/bleeding_edge/src/zone.h

Log:
Partial fix for issue 173:
- Do not keep growing the zone segment size exponentially. By putting
   an upper limit on the segment size we limit the requirements for
   contiguous memory allocation.

Review URL: http://codereview.chromium.org/12984

Modified: branches/bleeding_edge/src/zone.cc
==============================================================================
--- branches/bleeding_edge/src/zone.cc  (original)
+++ branches/bleeding_edge/src/zone.cc  Fri Dec  5 09:37:12 2008
@@ -163,8 +163,23 @@
    // is to avoid excessive malloc() and free() overhead.
    Segment* head = Segment::head();
    int old_size = (head == NULL) ? 0 : head->size();
-  int new_size = sizeof(Segment) + kAlignment + size + (old_size << 1);
-  if (new_size < kMinimumSegmentSize) new_size = kMinimumSegmentSize;
+  static const int kSegmentOverhead = sizeof(Segment) + kAlignment;
+  int new_size = kSegmentOverhead + size + (old_size << 1);
+  if (new_size < kMinimumSegmentSize) {
+    new_size = kMinimumSegmentSize;
+  } else if (new_size > kMaximumSegmentSize) {
+    // Limit the size of new segments to avoid growing the segment size
+    // exponentially, thus putting pressure on contiguous virtual address
+    // space.
+    if (size > (kMaximumSegmentSize - kSegmentOverhead)) {
+      // Make sure to allocate a segment at large enough to hold the  
requested
+      // size.
+      new_size = kSegmentOverhead + size;
+    } else {
+      // Allocate a new segment of maximum size.
+      new_size = kMaximumSegmentSize;
+    }
+  }
    Segment* segment = Segment::New(new_size);
    if (segment == NULL) V8::FatalProcessOutOfMemory("Zone");


Modified: branches/bleeding_edge/src/zone.h
==============================================================================
--- branches/bleeding_edge/src/zone.h   (original)
+++ branches/bleeding_edge/src/zone.h   Fri Dec  5 09:37:12 2008
@@ -74,6 +74,9 @@

    // Never allocate segments smaller than this size in bytes.
    static const int kMinimumSegmentSize = 8 * KB;
+
+  // Never allocate segments larger than this size in bytes.
+  static const int kMaximumSegmentSize = 1 * MB;

    // Never keep segments larger than this size in bytes around.
    static const int kMaximumKeptSegmentSize = 64 * KB;

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to