bmalloc: Misc improvements to MallocBench
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 23:50:25 +0000 (23:50 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 23:50:25 +0000 (23:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157004

Reviewed by Darin Adler.

* MallocBench/run-malloc-benchmarks: Added --memory and --memory_warning
modes for focused memory testing.

* MallocBench/MallocBench/Benchmark.cpp:
(Benchmark::printReport): Clarified output.

(Benchmark::currentMemoryBytes): Added compressed memory because top
does the same. (It always happens to zero in the benchmarks we run. But
this is good for sanity.)

* MallocBench/MallocBench/CommandLine.cpp: Moved up to 8 runs to reduce
variance.

* MallocBench/MallocBench/alloc_free.cpp:
(benchmark_alloc_free): Cycle a single allocation in order to stress
the effect of merging on calls to madvise.

* MallocBench/MallocBench/big.cpp:
(benchmark_big): Graduated to 8kB-128kB because medium tests up to 8 and
our large allocator doesn't kick in until 64kB.

* MallocBench/MallocBench/medium.cpp:
(benchmark_medium): Test all the way down to 1kB because our large
allocator used to service 1kB allocations and 1kB is an interesting
middle size where memory is unusually large but allocation throughput
still matters.

* MallocBench/MallocBench/stress.cpp:
(benchmark_stress): Reduced the churn count to match stress_aligned
because this test was taking too long to complete.

* MallocBench/MallocBench/stress_aligned.cpp:
(benchmark_stress_aligned): Our new large allocator can handle even
more absurdly large values.

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

PerformanceTests/ChangeLog
PerformanceTests/MallocBench/MallocBench/Benchmark.cpp
PerformanceTests/MallocBench/MallocBench/CommandLine.cpp
PerformanceTests/MallocBench/MallocBench/alloc_free.cpp
PerformanceTests/MallocBench/MallocBench/big.cpp
PerformanceTests/MallocBench/MallocBench/medium.cpp
PerformanceTests/MallocBench/MallocBench/stress.cpp
PerformanceTests/MallocBench/MallocBench/stress_aligned.cpp
PerformanceTests/MallocBench/run-malloc-benchmarks

index a4290d29b389f1b2f0c17e4bdfef33f0bcab4d66..96b87efe0c831819460aee119afcb6cccc12a203 100644 (file)
@@ -1,3 +1,45 @@
+2016-04-25  Geoffrey Garen  <ggaren@apple.com>
+
+        bmalloc: Misc improvements to MallocBench
+        https://bugs.webkit.org/show_bug.cgi?id=157004
+
+        Reviewed by Darin Adler.
+
+        * MallocBench/run-malloc-benchmarks: Added --memory and --memory_warning
+        modes for focused memory testing.
+
+        * MallocBench/MallocBench/Benchmark.cpp:
+        (Benchmark::printReport): Clarified output.
+
+        (Benchmark::currentMemoryBytes): Added compressed memory because top
+        does the same. (It always happens to zero in the benchmarks we run. But
+        this is good for sanity.)
+
+        * MallocBench/MallocBench/CommandLine.cpp: Moved up to 8 runs to reduce
+        variance.
+
+        * MallocBench/MallocBench/alloc_free.cpp:
+        (benchmark_alloc_free): Cycle a single allocation in order to stress
+        the effect of merging on calls to madvise.
+
+        * MallocBench/MallocBench/big.cpp:
+        (benchmark_big): Graduated to 8kB-128kB because medium tests up to 8 and
+        our large allocator doesn't kick in until 64kB.
+
+        * MallocBench/MallocBench/medium.cpp:
+        (benchmark_medium): Test all the way down to 1kB because our large
+        allocator used to service 1kB allocations and 1kB is an interesting
+        middle size where memory is unusually large but allocation throughput
+        still matters.
+
+        * MallocBench/MallocBench/stress.cpp:
+        (benchmark_stress): Reduced the churn count to match stress_aligned
+        because this test was taking too long to complete.
+
+        * MallocBench/MallocBench/stress_aligned.cpp:
+        (benchmark_stress_aligned): Our new large allocator can handle even
+        more absurdly large values.
+
 2016-04-25  Simon Fraser  <simon.fraser@apple.com>
 
         Add a content animation test that uses SVG animation.
index 12ee5412b7fb843cddd94c828eda93c7e38bfbba..d2d842c235b69c316f6c7cb2ba07ac256698711c 100644 (file)
@@ -201,8 +201,8 @@ void Benchmark::printReport()
     size_t kB = 1024;
 
     cout << "Time:       \t" << m_elapsedTime << "ms" << endl;
-    cout << "Memory:     \t" << m_memory.resident / kB << "kB" << endl;
     cout << "Peak Memory:\t" << m_memory.residentMax / kB << "kB" << endl;
+    cout << "Memory at End:     \t" << m_memory.resident / kB << "kB" << endl;
 }
 
 double Benchmark::currentTimeMS()
@@ -223,7 +223,7 @@ Benchmark::Memory Benchmark::currentMemoryBytes()
         exit(1);
     }
 
-    memory.resident = vm_info.internal - vm_info.purgeable_volatile_pmap;
+    memory.resident = vm_info.internal + vm_info.compressed - vm_info.purgeable_volatile_pmap;
     memory.residentMax = vm_info.resident_size_peak;
     return memory;
 }
index 26a7463198a11a36c946bbe5f6641ad50395a4d2..fc9b7e92b9f5dde8ebe8e1bc9692584015a5b9d9 100644 (file)
@@ -47,7 +47,7 @@ CommandLine::CommandLine(int argc, char** argv)
     , m_useThreadID(false)
     , m_warmUp(true)
     , m_heapSize(0)
-    , m_runs(4)
+    , m_runs(8)
 {
     int optionIndex = 0;
     int ch;
index 5dcf1e735a8d0062df90cf70b39e0b3e92c375a2..bd607c5c99efcee9d6eadcdef23eaa63c573d37d 100644 (file)
 
 void benchmark_alloc_free(CommandLine&)
 {
-    size_t loops = 1000000;
+    size_t loops = 40000;
 
-    size_t allocSize = 1030;
+    size_t allocSize = 128 * 1024;
     
-    char* dummy1 = (char*)mbmalloc(allocSize);
-    char* dummy2 = (char*)mbmalloc(allocSize);
-    dummy2[0] = 'a';
-    mbfree(dummy1, allocSize);
-
     while (--loops) {
         char* object = (char*)mbmalloc(allocSize);
 
index 09ddcc3a68bd0863ea860d8c5a342b97d665d0ed..e1e75ec5703ad6e843969ed8fd5259c5ab5bf44c 100644 (file)
@@ -44,8 +44,8 @@ void benchmark_big(CommandLine& commandLine)
     size_t times = 1;
 
     size_t vmSize = 1ul * 1024 * 1024 * 1024;
-    size_t objectSizeMin = 4 * 1024;
-    size_t objectSizeMax = 64 * 1024;
+    size_t objectSizeMin = 8 * 1024;
+    size_t objectSizeMax = 128 * 1024;
     if (commandLine.isParallel())
         vmSize /= cpuCount();
 
index b0d3a642f7cd4be3233f515c0a137d7146274142..c6c1f188b2fd1166c1173aa6888b98aa02ce486e 100644 (file)
@@ -44,7 +44,7 @@ void benchmark_medium(CommandLine& commandLine)
     size_t times = 1;
 
     size_t vmSize = 1ul * 1024 * 1024 * 1024;
-    size_t objectSizeMin = 2 * 1024;
+    size_t objectSizeMin = 1 * 1024;
     size_t objectSizeMax = 8 * 1024;
     if (commandLine.isParallel())
         vmSize /= cpuCount();
index 9517f42a8d93ae1aeb3ca0cb88c66418860fa68b..6bc1ba3152bd93be02cd3561cb39ce2dbfa0bd9f 100644 (file)
@@ -124,7 +124,7 @@ void benchmark_stress(CommandLine&)
 {
     const size_t heapSize = 100 * MB;
     const size_t churnSize = .05 * heapSize;
-    const size_t churnCount = 1000;
+    const size_t churnCount = 100;
     
     srandom(1); // For consistency between runs.
 
index 88214f9c7d54eb80214e902b43b929bae885c849..49b91bc3fae1c168ff84f90809d5644ef8f21383 100644 (file)
@@ -145,7 +145,7 @@ void benchmark_stress_aligned(CommandLine&)
     
     srandom(1); // For consistency between runs.
 
-    size_t limit = 0x000007fffffffffful;
+    size_t limit = 0x00001ffffffffffful;
     
     for (size_t size = 0; size < limit; size = std::max(size, sizeof(void*)) * 2) {
         for (size_t alignment = sizeof(void*); alignment < limit; alignment *= 2) {
@@ -155,7 +155,7 @@ void benchmark_stress_aligned(CommandLine&)
             mbfree(object, size);
         }
 
-        for (size_t alignment = sizeof(void*); alignment < limit / 4; alignment *= 2) {
+        for (size_t alignment = sizeof(void*); alignment < limit; alignment *= 2) {
             void* object = mbmemalign(alignment, size + 128);
             if (reinterpret_cast<uintptr_t>(object) & (alignment - 1))
                 abort();
index 0b98b725e8d65886e770de5037ef6d4690394759..1ee0458aae8a8eefde98cfc7cc27b88d399f4146 100755 (executable)
@@ -6,7 +6,7 @@ require 'pathname'
 $binDir = "#{File.expand_path(File.dirname(__FILE__))}"
 $productDir = `perl -e 'use lib \"#{$binDir}/../../Tools/Scripts\"; use webkitdirs; print productDir()'`
 
-$benchmarks = [
+$benchmarks_all = [
     # Single-threaded benchmarks.
     "churn",
     "list_allocate",
@@ -54,6 +54,21 @@ $benchmarks = [
     # "balloon"
 ]
 
+$benchmarks_memory = [
+    "facebook",
+    "reddit",
+    "flickr",
+    "theverge",
+    "nimlang"
+]
+
+$benchmarks_memory_warning = [
+    "reddit_memory_warning --runs 0",
+    "flickr_memory_warning --runs 0",
+    "theverge_memory_warning --runs 0",
+]
+
+$benchmarks = $benchmarks_all
 $heap = 0
 
 def usage
@@ -198,6 +213,8 @@ end
 def parseOptions
     GetoptLong.new(
         ['--benchmark', GetoptLong::REQUIRED_ARGUMENT],
+        ['--memory', GetoptLong::NO_ARGUMENT],
+        ['--memory_warning', GetoptLong::NO_ARGUMENT],
         ['--heap', GetoptLong::REQUIRED_ARGUMENT],
         ['--help', GetoptLong::NO_ARGUMENT],
     ).each {
@@ -205,6 +222,10 @@ def parseOptions
         case opt
         when '--benchmark'
             $benchmarks = [ arg ]
+        when '--memory'
+            $benchmarks = $benchmarks_memory
+        when '--memory_warning'
+            $benchmarks = $benchmarks_memory_warning
         when '--heap'
             $heap = arg
         when '--help'
@@ -274,8 +295,8 @@ def runBenchmarks(dylibs)
             splitOutput = output.split("\n")
 
             executionTime[-1].push(TimeStat.new(benchmark, splitOutput[1]))
-            peakMemory[-1].push(PeakMemoryStat.new(benchmark, splitOutput.length > 3 ? splitOutput[3] : "0"))
-            memoryAtEnd[-1].push(MemoryStat.new(benchmark, splitOutput.length > 2 ? splitOutput[2] : "0"))
+            peakMemory[-1].push(PeakMemoryStat.new(benchmark, splitOutput.length > 3 ? splitOutput[2] : "0"))
+            memoryAtEnd[-1].push(MemoryStat.new(benchmark, splitOutput.length > 2 ? splitOutput[3] : "0"))
         }
     }
     $stderr.print "\r                                                                                \n"