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: http://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 a4290d2..96b87ef 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 12ee541..d2d842c 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 26a7463..fc9b7e9 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 5dcf1e7..bd607c5 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 09ddcc3..e1e75ec 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 b0d3a64..c6c1f18 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 9517f42..6bc1ba3 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 88214f9..49b91bc 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 0b98b72..1ee0458 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"