MallocBench: consolidate regression testing for aligned allocation
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 19:39:38 +0000 (19:39 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 19:39:38 +0000 (19:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155762

Reviewed by Michael Saboff.

* MallocBench/MallocBench.xcodeproj/project.pbxproj:
* MallocBench/MallocBench/Benchmark.cpp:
* MallocBench/MallocBench/memalign.cpp: Removed.
* MallocBench/MallocBench/memalign.h: Removed. The stress_aligned test
covers this and much more.

* MallocBench/MallocBench/stress_aligned.cpp:
(benchmark_stress_aligned): Include specific tests for extreme sizes
and alignments.

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

PerformanceTests/ChangeLog
PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj
PerformanceTests/MallocBench/MallocBench/Benchmark.cpp
PerformanceTests/MallocBench/MallocBench/memalign.cpp [deleted file]
PerformanceTests/MallocBench/MallocBench/memalign.h [deleted file]
PerformanceTests/MallocBench/MallocBench/stress_aligned.cpp

index 5c43644..f2740e0 100644 (file)
@@ -1,3 +1,20 @@
+2016-03-22  Geoffrey Garen  <ggaren@apple.com>
+
+        MallocBench: consolidate regression testing for aligned allocation
+        https://bugs.webkit.org/show_bug.cgi?id=155762
+
+        Reviewed by Michael Saboff.
+
+        * MallocBench/MallocBench.xcodeproj/project.pbxproj:
+        * MallocBench/MallocBench/Benchmark.cpp:
+        * MallocBench/MallocBench/memalign.cpp: Removed.
+        * MallocBench/MallocBench/memalign.h: Removed. The stress_aligned test
+        covers this and much more.
+
+        * MallocBench/MallocBench/stress_aligned.cpp:
+        (benchmark_stress_aligned): Include specific tests for extreme sizes
+        and alignments.
+
 2016-03-21  Jon Lee  <jonlee@apple.com>
 
         Update benchmark tests
index 1ff3167..3a61c7d 100644 (file)
@@ -36,7 +36,6 @@
                14CC393F18EA8184004AFE34 /* mbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CC391C18EA6759004AFE34 /* mbmalloc.cpp */; };
                14CE4A6017BD355800288DAA /* big.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CE4A5E17BD355800288DAA /* big.cpp */; };
                14D0BFF31A6F4D3B00109F31 /* stress_aligned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D0BFF11A6F4D3B00109F31 /* stress_aligned.cpp */; };
-               14D6322E1A69BE0B00A8F84F /* memalign.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D6322C1A69BE0B00A8F84F /* memalign.cpp */; };
                14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14E11930177ECC8B003A8D15 /* CPUCount.cpp */; };
                14FCA36119A7C917001CFDA9 /* stress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FCA35F19A7C917001CFDA9 /* stress.cpp */; };
                65E401A61C657A87003C6E9C /* nimlang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E401A41C657A87003C6E9C /* nimlang.cpp */; };
                14CE4A5F17BD355800288DAA /* big.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = big.h; path = MallocBench/big.h; sourceTree = "<group>"; };
                14D0BFF11A6F4D3B00109F31 /* stress_aligned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stress_aligned.cpp; path = MallocBench/stress_aligned.cpp; sourceTree = "<group>"; };
                14D0BFF21A6F4D3B00109F31 /* stress_aligned.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stress_aligned.h; path = MallocBench/stress_aligned.h; sourceTree = "<group>"; };
-               14D6322C1A69BE0B00A8F84F /* memalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = memalign.cpp; path = MallocBench/memalign.cpp; sourceTree = "<group>"; };
-               14D6322D1A69BE0B00A8F84F /* memalign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = memalign.h; path = MallocBench/memalign.h; sourceTree = "<group>"; };
                14E11930177ECC8B003A8D15 /* CPUCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUCount.cpp; sourceTree = "<group>"; };
                14E11931177ECC8B003A8D15 /* CPUCount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUCount.h; sourceTree = "<group>"; };
                14E11934177F5219003A8D15 /* mbmalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mbmalloc.h; path = MallocBench/mbmalloc.h; sourceTree = "<group>"; };
                                14976EC7177E3649006B819A /* list.h */,
                                1451FAEB18B14B7100DB6D47 /* medium.cpp */,
                                1451FAEC18B14B7100DB6D47 /* medium.h */,
-                               14D6322C1A69BE0B00A8F84F /* memalign.cpp */,
-                               14D6322D1A69BE0B00A8F84F /* memalign.h */,
                                1444AE94177E8DF200F8030A /* message.cpp */,
                                1444AE95177E8DF200F8030A /* message.h */,
                                14105E8018E13EEC003A106E /* realloc.cpp */,
                                14C5009318403DA0007A531D /* Interpreter.cpp in Sources */,
                                1447AE9118FB584200B3D7FF /* reddit.cpp in Sources */,
                                14E11932177ECC8B003A8D15 /* CPUCount.cpp in Sources */,
-                               14D6322E1A69BE0B00A8F84F /* memalign.cpp in Sources */,
                                1444AE93177E79BB00F8030A /* fragment.cpp in Sources */,
                                14105E8218E13EEC003A106E /* realloc.cpp in Sources */,
                                14105E7F18DF7D73003A106E /* balloon.cpp in Sources */,
index 250ee5b..12ee541 100644 (file)
@@ -34,7 +34,6 @@
 #include "fragment.h"
 #include "list.h"
 #include "medium.h"
-#include "memalign.h"
 #include "message.h"
 #include "nimlang.h"
 #include "reddit.h"
@@ -75,7 +74,6 @@ static const BenchmarkPair benchmarkPairs[] = {
     { "list_allocate", benchmark_list_allocate },
     { "list_traverse", benchmark_list_traverse },
     { "medium", benchmark_medium },
-    { "memalign", benchmark_memalign },
     { "message_many", benchmark_message_many },
     { "message_one", benchmark_message_one },
     { "nimlang", benchmark_nimlang },
diff --git a/PerformanceTests/MallocBench/MallocBench/memalign.cpp b/PerformanceTests/MallocBench/MallocBench/memalign.cpp
deleted file mode 100644 (file)
index 34af059..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include <assert.h>
-#include "memalign.h"
-#include <memory>
-#include <stddef.h>
-#include "CommandLine.h"
-
-#include "mbmalloc.h"
-
-void test(size_t alignment, size_t size)
-{
-    void* result = mbmemalign(alignment, size);
-
-    assert(result);
-    assert(!((uintptr_t)result & (alignment - 1)));
-    
-    mbfree(result, size);
-}
-
-void benchmark_memalign(CommandLine&)
-{
-    for (size_t alignment = 2; alignment < 4096; alignment *= 2) {
-        for (size_t size = 0; size < 4096; ++size)
-            test(alignment, size);
-    }
-
-    test(1 * 1024 * 1024, 8);
-    test(8 * 1024 * 1024, 8);
-    test(32 * 1024 * 1024, 8);
-    test(64 * 1024 * 1024, 8);
-    test(1 * 1024 * 1024, 8 * 1024 * 1024);
-    test(1 * 1024 * 1024, 16 * 1024 * 1024);
-}
diff --git a/PerformanceTests/MallocBench/MallocBench/memalign.h b/PerformanceTests/MallocBench/MallocBench/memalign.h
deleted file mode 100644 (file)
index a392b82..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef memalign_h
-#define memalign_h
-
-#include "CommandLine.h"
-
-void benchmark_memalign(CommandLine&);
-
-#endif // memalign_h
-
index 5b02fa8..88214f9 100644 (file)
@@ -145,6 +145,24 @@ void benchmark_stress_aligned(CommandLine&)
     
     srandom(1); // For consistency between runs.
 
+    size_t limit = 0x000007fffffffffful;
+    
+    for (size_t size = 0; size < limit; size = std::max(size, sizeof(void*)) * 2) {
+        for (size_t alignment = sizeof(void*); alignment < limit; alignment *= 2) {
+            void* object = mbmemalign(alignment, size);
+            if (reinterpret_cast<uintptr_t>(object) & (alignment - 1))
+                abort();
+            mbfree(object, size);
+        }
+
+        for (size_t alignment = sizeof(void*); alignment < limit / 4; alignment *= 2) {
+            void* object = mbmemalign(alignment, size + 128);
+            if (reinterpret_cast<uintptr_t>(object) & (alignment - 1))
+                abort();
+            mbfree(object, size + 128);
+        }
+    }
+
     std::vector<Object> objects;
     
     SizeStream sizeStream;