Title: [178611] trunk/PerformanceTests
Revision
178611
Author
[email protected]
Date
2015-01-16 16:10:59 -0800 (Fri, 16 Jan 2015)

Log Message

bmalloc: added the tiniest bit of testing for aligned allocation
https://bugs.webkit.org/show_bug.cgi?id=140573

Reviewed by Andreas Kling.

Just good enoug to catch two bugs in a preliminary implementation.

* MallocBench/MallocBench.xcodeproj/project.pbxproj:
* MallocBench/MallocBench/Benchmark.cpp:
* MallocBench/MallocBench/mbmalloc.cpp:
* MallocBench/MallocBench/mbmalloc.h:
* MallocBench/MallocBench/memalign.cpp: Added.
(benchmark_memalign):
* MallocBench/MallocBench/memalign.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/PerformanceTests/ChangeLog (178610 => 178611)


--- trunk/PerformanceTests/ChangeLog	2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/ChangeLog	2015-01-17 00:10:59 UTC (rev 178611)
@@ -1,3 +1,20 @@
+2015-01-16  Geoffrey Garen  <[email protected]>
+
+        bmalloc: added the tiniest bit of testing for aligned allocation
+        https://bugs.webkit.org/show_bug.cgi?id=140573
+
+        Reviewed by Andreas Kling.
+
+        Just good enoug to catch two bugs in a preliminary implementation.
+
+        * MallocBench/MallocBench.xcodeproj/project.pbxproj:
+        * MallocBench/MallocBench/Benchmark.cpp:
+        * MallocBench/MallocBench/mbmalloc.cpp:
+        * MallocBench/MallocBench/mbmalloc.h:
+        * MallocBench/MallocBench/memalign.cpp: Added.
+        (benchmark_memalign):
+        * MallocBench/MallocBench/memalign.h: Added.
+
 2014-12-09  Myles C. Maxfield  <[email protected]>
 
         Add performance test related to font fallback

Modified: trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp (178610 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp	2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/Benchmark.cpp	2015-01-17 00:10:59 UTC (rev 178611)
@@ -33,8 +33,10 @@
 #include "fragment.h"
 #include "list.h"
 #include "medium.h"
+#include "memalign.h"
 #include "message.h"
 #include "reddit.h"
+#include "realloc.h"
 #include "stress.h"
 #include "theverge.h"
 #include "tree.h"
@@ -69,8 +71,10 @@
     { "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 },
+    { "realloc", benchmark_realloc },
     { "reddit", benchmark_reddit },
     { "reddit_memory_warning", benchmark_reddit_memory_warning },
     { "stress", benchmark_stress },

Modified: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp (178610 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp	2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.cpp	2015-01-17 00:10:59 UTC (rev 178611)
@@ -35,6 +35,13 @@
     return malloc(size);
 }
 
+void* mbmemalign(size_t alignment, size_t size)
+{
+    void* result;
+    posix_memalign(&result, alignment, size);
+    return result;
+}
+
 void mbfree(void* p, size_t)
 {
     return free(p);

Modified: trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h (178610 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h	2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench/mbmalloc.h	2015-01-17 00:10:59 UTC (rev 178611)
@@ -35,6 +35,7 @@
 extern "C" {
 
 void* mbmalloc(size_t);
+void* mbmemalign(size_t, size_t);
 void mbfree(void*, size_t);
 void* mbrealloc(void*, size_t, size_t);
 void mbscavenge();

Added: trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp (0 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp	                        (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/memalign.cpp	2015-01-17 00:10:59 UTC (rev 178611)
@@ -0,0 +1,56 @@
+/*
+ * 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 "mbmalloc.h"
+
+void benchmark_memalign(bool isParallel)
+{
+    {
+        size_t alignment = 128;
+        size_t size = 8;
+        void* result = mbmemalign(alignment, size);
+
+        assert(result);
+        assert(((uintptr_t)result & (alignment - 1)) == 0);
+        
+        mbfree(result, size);
+    }
+    
+    {
+        size_t alignment = 2048 * 1024 * 1024;
+        size_t size = 8;
+        void* result = mbmemalign(alignment, size);
+
+        assert(result);
+        assert(((uintptr_t)result & (alignment - 1)) == 0);
+        
+        mbfree(result, size);
+    }
+}

Added: trunk/PerformanceTests/MallocBench/MallocBench/memalign.h (0 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench/memalign.h	                        (rev 0)
+++ trunk/PerformanceTests/MallocBench/MallocBench/memalign.h	2015-01-17 00:10:59 UTC (rev 178611)
@@ -0,0 +1,32 @@
+/*
+ * 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
+
+void benchmark_memalign(bool isParallel);
+
+#endif // memalign_h
+

Modified: trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj (178610 => 178611)


--- trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj	2015-01-17 00:10:18 UTC (rev 178610)
+++ trunk/PerformanceTests/MallocBench/MallocBench.xcodeproj/project.pbxproj	2015-01-17 00:10:59 UTC (rev 178611)
@@ -34,6 +34,7 @@
 		14CC393C18EA812B004AFE34 /* libmbmalloc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 14CC393818EA811F004AFE34 /* libmbmalloc.dylib */; settings = {ATTRIBUTES = (Required, ); }; };
 		14CC393F18EA8184004AFE34 /* mbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CC391C18EA6759004AFE34 /* mbmalloc.cpp */; };
 		14CE4A6017BD355800288DAA /* big.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CE4A5E17BD355800288DAA /* big.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 */; };
 /* End PBXBuildFile section */
@@ -103,6 +104,8 @@
 		14CC393818EA811F004AFE34 /* libmbmalloc.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmbmalloc.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		14CE4A5E17BD355800288DAA /* big.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = big.cpp; path = MallocBench/big.cpp; sourceTree = "<group>"; };
 		14CE4A5F17BD355800288DAA /* big.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = big.h; path = MallocBench/big.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>"; };
@@ -205,6 +208,8 @@
 				14976EC7177E3649006B819A /* list.h */,
 				1451FAEB18B14B7100DB6D47 /* medium.cpp */,
 				1451FAEC18B14B7100DB6D47 /* medium.h */,
+				14D6322C1A69BE0B00A8F84F /* memalign.cpp */,
+				14D6322D1A69BE0B00A8F84F /* memalign.h */,
 				1444AE94177E8DF200F8030A /* message.cpp */,
 				1444AE95177E8DF200F8030A /* message.h */,
 				14105E8018E13EEC003A106E /* realloc.cpp */,
@@ -319,6 +324,7 @@
 				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 */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to