Some MallocBench refinements
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Sep 2014 19:33:47 +0000 (19:33 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Sep 2014 19:33:47 +0000 (19:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136750

Reviewed by Sam Weinig.

* MallocBench/MallocBench/Interpreter.cpp:
(Interpreter::run): Allow for null entries in the object list so that
we can test in modes that exclude large or small allocations.

* MallocBench/MallocBench/churn.cpp:
(benchmark_churn):
* MallocBench/MallocBench/flickr.cpp:
(benchmark_flickr):
* MallocBench/MallocBench/fragment.cpp:
(benchmark_fragment_iterate):
* MallocBench/MallocBench/list.cpp:
(benchmark_list_allocate):
* MallocBench/MallocBench/reddit.cpp:
(benchmark_reddit): Updated test runtimes to weight them more equally,
for the sake of arithmetic mean.

* MallocBench/MallocBench/stress.cpp:
(Object::Object):
(allocate):
(deallocate):
(benchmark_stress): Verify the contents of memory as we go. Also,
force scavenging each time through the loop to test the scavenging path.

* MallocBench/MallocBench/theverge.cpp:
(benchmark_theverge):
* MallocBench/MallocBench/tree.cpp:
(benchmark_tree_churn): Re-weighted, as above.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173529 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/MallocBench/MallocBench/Interpreter.cpp
PerformanceTests/MallocBench/MallocBench/churn.cpp
PerformanceTests/MallocBench/MallocBench/flickr.cpp
PerformanceTests/MallocBench/MallocBench/fragment.cpp
PerformanceTests/MallocBench/MallocBench/list.cpp
PerformanceTests/MallocBench/MallocBench/reddit.cpp
PerformanceTests/MallocBench/MallocBench/stress.cpp
PerformanceTests/MallocBench/MallocBench/theverge.cpp
PerformanceTests/MallocBench/MallocBench/tree.cpp

index 93d6559..0087de2 100644 (file)
@@ -1,3 +1,38 @@
+2014-09-11  Geoffrey Garen  <ggaren@apple.com>
+
+        Some MallocBench refinements
+        https://bugs.webkit.org/show_bug.cgi?id=136750
+
+        Reviewed by Sam Weinig.
+
+        * MallocBench/MallocBench/Interpreter.cpp:
+        (Interpreter::run): Allow for null entries in the object list so that
+        we can test in modes that exclude large or small allocations.
+
+        * MallocBench/MallocBench/churn.cpp:
+        (benchmark_churn):
+        * MallocBench/MallocBench/flickr.cpp:
+        (benchmark_flickr):
+        * MallocBench/MallocBench/fragment.cpp:
+        (benchmark_fragment_iterate):
+        * MallocBench/MallocBench/list.cpp:
+        (benchmark_list_allocate):
+        * MallocBench/MallocBench/reddit.cpp:
+        (benchmark_reddit): Updated test runtimes to weight them more equally,
+        for the sake of arithmetic mean.
+
+        * MallocBench/MallocBench/stress.cpp:
+        (Object::Object):
+        (allocate):
+        (deallocate):
+        (benchmark_stress): Verify the contents of memory as we go. Also,
+        force scavenging each time through the loop to test the scavenging path.
+
+        * MallocBench/MallocBench/theverge.cpp:
+        (benchmark_theverge):
+        * MallocBench/MallocBench/tree.cpp:
+        (benchmark_tree_churn): Re-weighted, as above.
+
 2014-09-08  Myles C. Maxfield  <mmaxfield@apple.com>
 
         PerformanceTests/SVG/SVG-Text.html has unparsable output
index 81d6427..d9ea0ed 100644 (file)
@@ -101,13 +101,15 @@ void Interpreter::run()
                 break;
             }
             case op_free: {
-                assert(m_objects[op.slot].object);
+                if (!m_objects[op.slot].object)
+                    continue;
                 mbfree(m_objects[op.slot].object, m_objects[op.slot].size);
                 m_objects[op.slot] = { 0, 0 };
                 break;
             }
             case op_realloc: {
-                assert(m_objects[op.slot].object);
+                if (!m_objects[op.slot].object)
+                    continue;
                 m_objects[op.slot] = { mbrealloc(m_objects[op.slot].object, m_objects[op.slot].size, op.size), op.size };
                 break;
             }
index 56cdf96..3a3e0b3 100644 (file)
@@ -41,7 +41,7 @@ struct HeapDouble {
 
 void benchmark_churn(bool isParallel)
 {
-    size_t times = 10000000;
+    size_t times = 7000000;
     if (isParallel)
         times /= cpuCount();
 
index 79d86f6..59f5701 100644 (file)
@@ -44,7 +44,7 @@
 
 void benchmark_flickr(bool isParallel)
 {
-    size_t times = 1;
+    size_t times = 3;
 
     Interpreter interpreter("flickr.ops");
     for (size_t i = 0; i < times; ++i)
index 1e0c725..0125796 100644 (file)
@@ -110,7 +110,7 @@ void benchmark_fragment(bool isParallel)
 void benchmark_fragment_iterate(bool isParallel)
 {
     size_t nodeCount = 512 * 1024;
-    size_t times = 32;
+    size_t times = 20;
     if (isParallel)
         nodeCount /= cpuCount();
     size_t replaceCount = nodeCount / 4;
index e39de79..487f4c3 100644 (file)
@@ -99,7 +99,7 @@ struct Node {
 void benchmark_list_allocate(bool isParallel)
 {
     Node* head = 0;
-    size_t times = 96;
+    size_t times = 70;
     size_t nodes = 32 * 1024;
     if (isParallel) {
         nodes /= cpuCount();
index 8f3cc8f..87763db 100644 (file)
@@ -44,7 +44,7 @@
 
 void benchmark_reddit(bool isParallel)
 {
-    size_t times = 1;
+    size_t times = 6;
 
     Interpreter interpreter("reddit.ops");
     for (size_t i = 0; i < times; ++i)
index 755a4e6..5accaf2 100644 (file)
@@ -39,14 +39,16 @@ static const size_t kB = 1024;
 static const size_t MB = kB * kB;
 
 struct Object {
-    Object(void* pointer, size_t size)
+    Object(void* pointer, size_t size, long uuid)
         : pointer(pointer)
         , size(size)
+        , uuid(uuid)
     {
     }
 
     void* pointer;
     size_t size;
+    long uuid;
 };
 
 class SizeStream {
@@ -100,6 +102,24 @@ private:
     size_t m_count;
 };
 
+Object allocate(size_t size)
+{
+    Object object(mbmalloc(size), size, random());
+    for (size_t i = 0; i < size / sizeof(long); ++i)
+        (static_cast<long*>(object.pointer))[i] = object.uuid;
+    return object;
+}
+
+void deallocate(const Object& object)
+{
+    for (size_t i = 0; i < object.size / sizeof(long); ++i) {
+        if ((static_cast<long*>(object.pointer))[i] != object.uuid)
+            abort();
+    }
+
+    mbfree(object.pointer, object.size);
+}
+
 void benchmark_stress(bool isParallel)
 {
     const size_t heapSize = 100 * MB;
@@ -112,18 +132,17 @@ void benchmark_stress(bool isParallel)
     
     SizeStream sizeStream;
     
-    size_t lastSize = 0;
-    for (size_t remaining = heapSize; remaining; remaining -= std::min(remaining, lastSize)) {
-        lastSize = sizeStream.next();
-        Object object(mbmalloc(lastSize), lastSize);
-        objects.push_back(object);
+    size_t size = 0;
+    for (size_t remaining = heapSize; remaining; remaining -= std::min(remaining, size)) {
+        size = sizeStream.next();
+        objects.push_back(allocate(size));
     }
     
     for (size_t i = 0; i < churnCount; ++i) {
         std::vector<Object> objectsToFree;
-        for (size_t remaining = churnSize; remaining; remaining -= std::min(remaining, lastSize)) {
-            lastSize = sizeStream.next();
-            Object object(mbmalloc(lastSize), lastSize);
+        for (size_t remaining = churnSize; remaining; remaining -= std::min(remaining, size)) {
+            size = sizeStream.next();
+            Object object = allocate(size);
 
             size_t index = random() % objects.size();
             objectsToFree.push_back(objects[index]);
@@ -131,7 +150,9 @@ void benchmark_stress(bool isParallel)
         }
 
         for (auto& object : objectsToFree)
-            mbfree(object.pointer, object.size);
+            deallocate(object);
+        
+        mbscavenge();
     }
     
     for (auto& object : objects)
index c24d298..6a03672 100644 (file)
@@ -44,7 +44,7 @@
 
 void benchmark_theverge(bool isParallel)
 {
-    size_t times = 1;
+    size_t times = 3;
 
     Interpreter interpreter("theverge.ops");
     for (size_t i = 0; i < times; ++i)
index dc69cab..d9b7a57 100644 (file)
@@ -207,7 +207,7 @@ void benchmark_tree_traverse(bool isParallel)
 
 void benchmark_tree_churn(bool isParallel)
 {
-    size_t times = 160;
+    size_t times = 130;
     size_t depth = 15;
     if (isParallel) {
         times *= 4;