haikuwebkit/PerformanceTests/MallocBench/MallocBench/message.cpp

234 lines
6.1 KiB
C++
Raw Permalink Normal View History

Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
/*
* 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 "CPUCount.h"
#include "message.h"
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
#include <condition_variable>
#include <deque>
#include <functional>
#include <mutex>
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
#include <stdlib.h>
#include <strings.h>
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
#include <thread>
#include <vector>
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
#include "mbmalloc.h"
namespace {
size_t hash(size_t hash, unsigned short a, unsigned short b)
{
hash += a ^ b;
return hash;
}
class Node {
static const size_t payloadCount = 128;
public:
void* operator new(size_t size)
{
return mbmalloc(size);
}
void operator delete(void* p, size_t size)
{
mbfree(p, size);
}
Node()
: m_payload()
{
}
size_t hash(size_t hash)
{
for (size_t i = 0; i < payloadCount; i += 2)
hash = ::hash(hash, m_payload[i], m_payload[i + 1]);
return hash;
}
private:
unsigned short m_payload[payloadCount];
};
class Message {
static const size_t nodeCount = 1 * 1024;
public:
void* operator new(size_t size)
{
return mbmalloc(size);
}
void operator delete(void* p, size_t size)
{
mbfree(p, size);
}
Message()
: m_buffer(static_cast<Node**>(mbmalloc(nodeCount * sizeof(Node**))))
{
for (size_t i = 0; i < nodeCount; ++i)
m_buffer[i] = new Node;
}
~Message()
{
for (size_t i = 0; i < nodeCount; ++i)
delete m_buffer[i];
mbfree(m_buffer, nodeCount * sizeof(Node**));
}
size_t hash()
{
size_t hash = 0;
for (size_t i = 0; i < nodeCount; ++i)
hash = m_buffer[i]->hash(hash);
return hash;
}
private:
Node** m_buffer;
};
} // namespace
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
class WorkQueue {
public:
WorkQueue()
{
m_thread = std::thread([&] {
while (true) {
std::function<void()> target;
{
std::unique_lock<std::mutex> locker(m_mutex);
m_condition.wait(locker, [&] { return !m_queue.empty(); });
auto queued = m_queue.front();
m_queue.pop_front();
if (!queued)
return;
target = std::move(queued);
}
target();
}
});
}
~WorkQueue() {
{
std::unique_lock<std::mutex> locker(m_mutex);
m_queue.push_back(nullptr);
m_condition.notify_one();
}
m_thread.join();
}
void dispatchAsync(std::function<void()> target)
{
std::unique_lock<std::mutex> locker(m_mutex);
m_queue.push_back(target);
m_condition.notify_one();
}
void dispatchSync(std::function<void()> target)
{
std::mutex syncMutex;
std::condition_variable syncCondition;
std::unique_lock<std::mutex> locker(syncMutex);
bool done = false;
dispatchAsync([&] {
target();
{
std::unique_lock<std::mutex> locker(syncMutex);
done = true;
syncCondition.notify_one();
}
});
syncCondition.wait(locker, [&] { return done; });
}
private:
std::mutex m_mutex;
std::condition_variable m_condition;
std::deque<std::function<void()>> m_queue;
std::thread m_thread;
};
MallocBench: Added recording for nimlang website, new recording details and added new options https://bugs.webkit.org/show_bug.cgi?id=154485 Reviewed by Geoff Garen. Added new capabilities to MallocBench. These include: Added a recording of http://nim-lang.org/docs/lib.html. Added thread id to the recording and the ability to playback switching threads in MallocBench Added aligned allocations to recordings and the ability to playback Added --use-thread-id option to honor recorded thread ids Added --detailed-report to output remaining allocations by size after playback Added --no-warmup to not run the warm up iteration Changed the way that options are passed down to the benchmarks. Instead of passing individual boolean or numeric option values, just pass a reference the CommandLine itself. Each benchmark can access the options that are appropriate. The Benchmark class also uses the options for is parallel, run counts and warm up. Added thread id and aligned malloc to the Op by noticing that structure padding and Opcode allowed for another 32 bits of data. Breaking that unused 32 bits into a 16 bit thread id value and a 16 bit log base 2 of the alignment for aligned malloc allowed for existing recordings to playback without any incompatibilities. Threaded operation is simulated by creating threads as needed. As long as the next Op's thread id is the same as the last, operation continues as normal. When the next Op has a different thread id, we switch to that thread using the shared Op stream to continue playing back. There is a mutex to assure that only one thread is really running at a time and a condition variable used to wait that the current thread id matches each block thread's thread id. This doesn't simulate true concurrent threading, but is instead plays back Ops recorded for multiple thread faithfully. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (deallocateHeap): (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::run): * MallocBench/MallocBench/Benchmark.h: (Benchmark::isValid): * MallocBench/MallocBench/CommandLine.cpp: (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::useThreadID): (CommandLine::detailedReport): (CommandLine::warmUp): (CommandLine::heapSize): (CommandLine::runs): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::Interpreter): (Interpreter::run): (Interpreter::readOps): (Interpreter::doOnSameThread): (Interpreter::switchToThread): (Interpreter::detailedReport): (compute2toPower): (writeData): (Interpreter::doMallocOp): (Interpreter::Thread::Thread): (Interpreter::Thread::stop): (Interpreter::Thread::~Thread): (Interpreter::Thread::runThread): (Interpreter::Thread::waitToRun): (Interpreter::Thread::switchTo): * MallocBench/MallocBench/Interpreter.h: (Interpreter::Thread::isMainThread): * MallocBench/MallocBench/alloc_free.cpp: Added. (benchmark_alloc_free): * MallocBench/MallocBench/alloc_free.h: Added. * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/balloon.h: * MallocBench/MallocBench/big.cpp: (benchmark_big): * MallocBench/MallocBench/big.h: * MallocBench/MallocBench/churn.cpp: (benchmark_churn): * MallocBench/MallocBench/churn.h: * MallocBench/MallocBench/facebook.cpp: (benchmark_facebook): * MallocBench/MallocBench/facebook.h: * MallocBench/MallocBench/flickr.cpp: (benchmark_flickr): (benchmark_flickr_memory_warning): * MallocBench/MallocBench/flickr.h: * MallocBench/MallocBench/fragment.cpp: (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: * MallocBench/MallocBench/list.cpp: (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: * MallocBench/MallocBench/main.cpp: (main): * MallocBench/MallocBench/medium.cpp: (benchmark_medium): * MallocBench/MallocBench/medium.h: * MallocBench/MallocBench/memalign.cpp: (test): (benchmark_memalign): * MallocBench/MallocBench/memalign.h: * MallocBench/MallocBench/message.cpp: (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: * MallocBench/MallocBench/nimlang.cpp: Added. (benchmark_nimlang): * MallocBench/MallocBench/nimlang.h: Added. * MallocBench/MallocBench/nimlang.ops: Added. * MallocBench/MallocBench/realloc.cpp: (benchmark_realloc): * MallocBench/MallocBench/realloc.h: * MallocBench/MallocBench/reddit.cpp: (benchmark_reddit): (benchmark_reddit_memory_warning): * MallocBench/MallocBench/reddit.h: * MallocBench/MallocBench/stress.cpp: (deallocate): (benchmark_stress): * MallocBench/MallocBench/stress.h: * MallocBench/MallocBench/stress_aligned.cpp: (benchmark_stress_aligned): * MallocBench/MallocBench/stress_aligned.h: * MallocBench/MallocBench/theverge.cpp: (benchmark_theverge): (benchmark_theverge_memory_warning): * MallocBench/MallocBench/theverge.h: * MallocBench/MallocBench/tree.cpp: (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: * MallocBench/run-malloc-benchmarks: Canonical link: https://commits.webkit.org/172661@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-22 22:02:24 +00:00
void benchmark_message_one(CommandLine& commandLine)
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
{
MallocBench: Added recording for nimlang website, new recording details and added new options https://bugs.webkit.org/show_bug.cgi?id=154485 Reviewed by Geoff Garen. Added new capabilities to MallocBench. These include: Added a recording of http://nim-lang.org/docs/lib.html. Added thread id to the recording and the ability to playback switching threads in MallocBench Added aligned allocations to recordings and the ability to playback Added --use-thread-id option to honor recorded thread ids Added --detailed-report to output remaining allocations by size after playback Added --no-warmup to not run the warm up iteration Changed the way that options are passed down to the benchmarks. Instead of passing individual boolean or numeric option values, just pass a reference the CommandLine itself. Each benchmark can access the options that are appropriate. The Benchmark class also uses the options for is parallel, run counts and warm up. Added thread id and aligned malloc to the Op by noticing that structure padding and Opcode allowed for another 32 bits of data. Breaking that unused 32 bits into a 16 bit thread id value and a 16 bit log base 2 of the alignment for aligned malloc allowed for existing recordings to playback without any incompatibilities. Threaded operation is simulated by creating threads as needed. As long as the next Op's thread id is the same as the last, operation continues as normal. When the next Op has a different thread id, we switch to that thread using the shared Op stream to continue playing back. There is a mutex to assure that only one thread is really running at a time and a condition variable used to wait that the current thread id matches each block thread's thread id. This doesn't simulate true concurrent threading, but is instead plays back Ops recorded for multiple thread faithfully. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (deallocateHeap): (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::run): * MallocBench/MallocBench/Benchmark.h: (Benchmark::isValid): * MallocBench/MallocBench/CommandLine.cpp: (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::useThreadID): (CommandLine::detailedReport): (CommandLine::warmUp): (CommandLine::heapSize): (CommandLine::runs): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::Interpreter): (Interpreter::run): (Interpreter::readOps): (Interpreter::doOnSameThread): (Interpreter::switchToThread): (Interpreter::detailedReport): (compute2toPower): (writeData): (Interpreter::doMallocOp): (Interpreter::Thread::Thread): (Interpreter::Thread::stop): (Interpreter::Thread::~Thread): (Interpreter::Thread::runThread): (Interpreter::Thread::waitToRun): (Interpreter::Thread::switchTo): * MallocBench/MallocBench/Interpreter.h: (Interpreter::Thread::isMainThread): * MallocBench/MallocBench/alloc_free.cpp: Added. (benchmark_alloc_free): * MallocBench/MallocBench/alloc_free.h: Added. * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/balloon.h: * MallocBench/MallocBench/big.cpp: (benchmark_big): * MallocBench/MallocBench/big.h: * MallocBench/MallocBench/churn.cpp: (benchmark_churn): * MallocBench/MallocBench/churn.h: * MallocBench/MallocBench/facebook.cpp: (benchmark_facebook): * MallocBench/MallocBench/facebook.h: * MallocBench/MallocBench/flickr.cpp: (benchmark_flickr): (benchmark_flickr_memory_warning): * MallocBench/MallocBench/flickr.h: * MallocBench/MallocBench/fragment.cpp: (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: * MallocBench/MallocBench/list.cpp: (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: * MallocBench/MallocBench/main.cpp: (main): * MallocBench/MallocBench/medium.cpp: (benchmark_medium): * MallocBench/MallocBench/medium.h: * MallocBench/MallocBench/memalign.cpp: (test): (benchmark_memalign): * MallocBench/MallocBench/memalign.h: * MallocBench/MallocBench/message.cpp: (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: * MallocBench/MallocBench/nimlang.cpp: Added. (benchmark_nimlang): * MallocBench/MallocBench/nimlang.h: Added. * MallocBench/MallocBench/nimlang.ops: Added. * MallocBench/MallocBench/realloc.cpp: (benchmark_realloc): * MallocBench/MallocBench/realloc.h: * MallocBench/MallocBench/reddit.cpp: (benchmark_reddit): (benchmark_reddit_memory_warning): * MallocBench/MallocBench/reddit.h: * MallocBench/MallocBench/stress.cpp: (deallocate): (benchmark_stress): * MallocBench/MallocBench/stress.h: * MallocBench/MallocBench/stress_aligned.cpp: (benchmark_stress_aligned): * MallocBench/MallocBench/stress_aligned.h: * MallocBench/MallocBench/theverge.cpp: (benchmark_theverge): (benchmark_theverge_memory_warning): * MallocBench/MallocBench/theverge.h: * MallocBench/MallocBench/tree.cpp: (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: * MallocBench/run-malloc-benchmarks: Canonical link: https://commits.webkit.org/172661@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-22 22:02:24 +00:00
if (commandLine.isParallel())
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
abort();
const size_t times = 2048;
const size_t quantum = 16;
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
WorkQueue workQueue;
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
for (size_t i = 0; i < times; i += quantum) {
for (size_t j = 0; j < quantum; ++j) {
Message* message = new Message;
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
workQueue.dispatchAsync([message] {
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
size_t hash = message->hash();
if (hash)
abort();
delete message;
});
}
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
workQueue.dispatchSync([] { });
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
}
[Linux] Port MallocBench https://bugs.webkit.org/show_bug.cgi?id=177856 Reviewed by Filip Pizlo. .: * CMakeLists.txt: PerformanceTests: We would like to optimize locking in bmalloc in Linux by using futex APIs. So we should have the way to ensure this actually improves / does not regress the performance. This patch ports MallocBench to Linux to measure/ensure the effect of bmalloc patch in Linux. While we replace the dispatch serial queue in message.cpp, we still use libdispatch in Benchmark.cpp since we do not have priority mechanism in C++11 threading implementation. We also extend run-malloc-benchmarks to accept cmake style layout of build product directory. And we also support building MallocBench in CMake environment including CMake Mac ports. Currently, we do not support Windows yet. Based on the measurement, we can say the following observation. glibc's malloc performance is not so bad. While bmalloc shows 3.8x (in geomean) performance improvement, bmalloc in Linux shows 2.0x improvement. Since both numbers in bmalloc are similar, we can think that bmalloc's optimization is actually working in Linux too. And even though glibc's malloc perofmrnace is not so bad, bmalloc still offers performance improvement. * CMakeLists.txt: Added. * MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::currentMemoryBytes): Deleted. * MallocBench/MallocBench/Benchmark.h: (Benchmark::Memory::Memory): Deleted. (Benchmark::Memory::operator-): Deleted. * MallocBench/MallocBench/CMakeLists.txt: Added. * MallocBench/MallocBench/CPUCount.cpp: (cpuCount): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::doMallocOp): * MallocBench/MallocBench/Memory.cpp: Added. (currentMemoryBytes): * MallocBench/MallocBench/Memory.h: Copied from PerformanceTests/MallocBench/MallocBench/CPUCount.cpp. (Memory::Memory): (Memory::operator-): * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/mbmalloc.cpp: * MallocBench/MallocBench/message.cpp: (WorkQueue::WorkQueue): (WorkQueue::~WorkQueue): (WorkQueue::dispatchAsync): (WorkQueue::dispatchSync): (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/nimlang.cpp: (benchmark_nimlang): * MallocBench/MallocBench/stress.cpp: (SizeStream::next): * MallocBench/MallocBench/stress_aligned.cpp: * MallocBench/run-malloc-benchmarks: Source/bmalloc: * CMakeLists.txt: Canonical link: https://commits.webkit.org/194175@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-05 07:05:44 +00:00
workQueue.dispatchSync([] { });
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
}
MallocBench: Added recording for nimlang website, new recording details and added new options https://bugs.webkit.org/show_bug.cgi?id=154485 Reviewed by Geoff Garen. Added new capabilities to MallocBench. These include: Added a recording of http://nim-lang.org/docs/lib.html. Added thread id to the recording and the ability to playback switching threads in MallocBench Added aligned allocations to recordings and the ability to playback Added --use-thread-id option to honor recorded thread ids Added --detailed-report to output remaining allocations by size after playback Added --no-warmup to not run the warm up iteration Changed the way that options are passed down to the benchmarks. Instead of passing individual boolean or numeric option values, just pass a reference the CommandLine itself. Each benchmark can access the options that are appropriate. The Benchmark class also uses the options for is parallel, run counts and warm up. Added thread id and aligned malloc to the Op by noticing that structure padding and Opcode allowed for another 32 bits of data. Breaking that unused 32 bits into a 16 bit thread id value and a 16 bit log base 2 of the alignment for aligned malloc allowed for existing recordings to playback without any incompatibilities. Threaded operation is simulated by creating threads as needed. As long as the next Op's thread id is the same as the last, operation continues as normal. When the next Op has a different thread id, we switch to that thread using the shared Op stream to continue playing back. There is a mutex to assure that only one thread is really running at a time and a condition variable used to wait that the current thread id matches each block thread's thread id. This doesn't simulate true concurrent threading, but is instead plays back Ops recorded for multiple thread faithfully. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (deallocateHeap): (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::run): * MallocBench/MallocBench/Benchmark.h: (Benchmark::isValid): * MallocBench/MallocBench/CommandLine.cpp: (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::useThreadID): (CommandLine::detailedReport): (CommandLine::warmUp): (CommandLine::heapSize): (CommandLine::runs): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::Interpreter): (Interpreter::run): (Interpreter::readOps): (Interpreter::doOnSameThread): (Interpreter::switchToThread): (Interpreter::detailedReport): (compute2toPower): (writeData): (Interpreter::doMallocOp): (Interpreter::Thread::Thread): (Interpreter::Thread::stop): (Interpreter::Thread::~Thread): (Interpreter::Thread::runThread): (Interpreter::Thread::waitToRun): (Interpreter::Thread::switchTo): * MallocBench/MallocBench/Interpreter.h: (Interpreter::Thread::isMainThread): * MallocBench/MallocBench/alloc_free.cpp: Added. (benchmark_alloc_free): * MallocBench/MallocBench/alloc_free.h: Added. * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/balloon.h: * MallocBench/MallocBench/big.cpp: (benchmark_big): * MallocBench/MallocBench/big.h: * MallocBench/MallocBench/churn.cpp: (benchmark_churn): * MallocBench/MallocBench/churn.h: * MallocBench/MallocBench/facebook.cpp: (benchmark_facebook): * MallocBench/MallocBench/facebook.h: * MallocBench/MallocBench/flickr.cpp: (benchmark_flickr): (benchmark_flickr_memory_warning): * MallocBench/MallocBench/flickr.h: * MallocBench/MallocBench/fragment.cpp: (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: * MallocBench/MallocBench/list.cpp: (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: * MallocBench/MallocBench/main.cpp: (main): * MallocBench/MallocBench/medium.cpp: (benchmark_medium): * MallocBench/MallocBench/medium.h: * MallocBench/MallocBench/memalign.cpp: (test): (benchmark_memalign): * MallocBench/MallocBench/memalign.h: * MallocBench/MallocBench/message.cpp: (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: * MallocBench/MallocBench/nimlang.cpp: Added. (benchmark_nimlang): * MallocBench/MallocBench/nimlang.h: Added. * MallocBench/MallocBench/nimlang.ops: Added. * MallocBench/MallocBench/realloc.cpp: (benchmark_realloc): * MallocBench/MallocBench/realloc.h: * MallocBench/MallocBench/reddit.cpp: (benchmark_reddit): (benchmark_reddit_memory_warning): * MallocBench/MallocBench/reddit.h: * MallocBench/MallocBench/stress.cpp: (deallocate): (benchmark_stress): * MallocBench/MallocBench/stress.h: * MallocBench/MallocBench/stress_aligned.cpp: (benchmark_stress_aligned): * MallocBench/MallocBench/stress_aligned.h: * MallocBench/MallocBench/theverge.cpp: (benchmark_theverge): (benchmark_theverge_memory_warning): * MallocBench/MallocBench/theverge.h: * MallocBench/MallocBench/tree.cpp: (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: * MallocBench/run-malloc-benchmarks: Canonical link: https://commits.webkit.org/172661@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-22 22:02:24 +00:00
void benchmark_message_many(CommandLine& commandLine)
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
{
MallocBench: Added recording for nimlang website, new recording details and added new options https://bugs.webkit.org/show_bug.cgi?id=154485 Reviewed by Geoff Garen. Added new capabilities to MallocBench. These include: Added a recording of http://nim-lang.org/docs/lib.html. Added thread id to the recording and the ability to playback switching threads in MallocBench Added aligned allocations to recordings and the ability to playback Added --use-thread-id option to honor recorded thread ids Added --detailed-report to output remaining allocations by size after playback Added --no-warmup to not run the warm up iteration Changed the way that options are passed down to the benchmarks. Instead of passing individual boolean or numeric option values, just pass a reference the CommandLine itself. Each benchmark can access the options that are appropriate. The Benchmark class also uses the options for is parallel, run counts and warm up. Added thread id and aligned malloc to the Op by noticing that structure padding and Opcode allowed for another 32 bits of data. Breaking that unused 32 bits into a 16 bit thread id value and a 16 bit log base 2 of the alignment for aligned malloc allowed for existing recordings to playback without any incompatibilities. Threaded operation is simulated by creating threads as needed. As long as the next Op's thread id is the same as the last, operation continues as normal. When the next Op has a different thread id, we switch to that thread using the shared Op stream to continue playing back. There is a mutex to assure that only one thread is really running at a time and a condition variable used to wait that the current thread id matches each block thread's thread id. This doesn't simulate true concurrent threading, but is instead plays back Ops recorded for multiple thread faithfully. * MallocBench/MallocBench.xcodeproj/project.pbxproj: * MallocBench/MallocBench/Benchmark.cpp: (deallocateHeap): (Benchmark::Benchmark): (Benchmark::runOnce): (Benchmark::run): * MallocBench/MallocBench/Benchmark.h: (Benchmark::isValid): * MallocBench/MallocBench/CommandLine.cpp: (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::useThreadID): (CommandLine::detailedReport): (CommandLine::warmUp): (CommandLine::heapSize): (CommandLine::runs): * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::Interpreter): (Interpreter::run): (Interpreter::readOps): (Interpreter::doOnSameThread): (Interpreter::switchToThread): (Interpreter::detailedReport): (compute2toPower): (writeData): (Interpreter::doMallocOp): (Interpreter::Thread::Thread): (Interpreter::Thread::stop): (Interpreter::Thread::~Thread): (Interpreter::Thread::runThread): (Interpreter::Thread::waitToRun): (Interpreter::Thread::switchTo): * MallocBench/MallocBench/Interpreter.h: (Interpreter::Thread::isMainThread): * MallocBench/MallocBench/alloc_free.cpp: Added. (benchmark_alloc_free): * MallocBench/MallocBench/alloc_free.h: Added. * MallocBench/MallocBench/balloon.cpp: (benchmark_balloon): * MallocBench/MallocBench/balloon.h: * MallocBench/MallocBench/big.cpp: (benchmark_big): * MallocBench/MallocBench/big.h: * MallocBench/MallocBench/churn.cpp: (benchmark_churn): * MallocBench/MallocBench/churn.h: * MallocBench/MallocBench/facebook.cpp: (benchmark_facebook): * MallocBench/MallocBench/facebook.h: * MallocBench/MallocBench/flickr.cpp: (benchmark_flickr): (benchmark_flickr_memory_warning): * MallocBench/MallocBench/flickr.h: * MallocBench/MallocBench/fragment.cpp: (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: * MallocBench/MallocBench/list.cpp: (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: * MallocBench/MallocBench/main.cpp: (main): * MallocBench/MallocBench/medium.cpp: (benchmark_medium): * MallocBench/MallocBench/medium.h: * MallocBench/MallocBench/memalign.cpp: (test): (benchmark_memalign): * MallocBench/MallocBench/memalign.h: * MallocBench/MallocBench/message.cpp: (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: * MallocBench/MallocBench/nimlang.cpp: Added. (benchmark_nimlang): * MallocBench/MallocBench/nimlang.h: Added. * MallocBench/MallocBench/nimlang.ops: Added. * MallocBench/MallocBench/realloc.cpp: (benchmark_realloc): * MallocBench/MallocBench/realloc.h: * MallocBench/MallocBench/reddit.cpp: (benchmark_reddit): (benchmark_reddit_memory_warning): * MallocBench/MallocBench/reddit.h: * MallocBench/MallocBench/stress.cpp: (deallocate): (benchmark_stress): * MallocBench/MallocBench/stress.h: * MallocBench/MallocBench/stress_aligned.cpp: (benchmark_stress_aligned): * MallocBench/MallocBench/stress_aligned.h: * MallocBench/MallocBench/theverge.cpp: (benchmark_theverge): (benchmark_theverge_memory_warning): * MallocBench/MallocBench/theverge.h: * MallocBench/MallocBench/tree.cpp: (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: * MallocBench/run-malloc-benchmarks: Canonical link: https://commits.webkit.org/172661@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-22 22:02:24 +00:00
if (commandLine.isParallel())
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
abort();
const size_t times = 768;
const size_t quantum = 16;
const size_t queueCount = cpuCount() - 1;
auto queues = std::make_unique<WorkQueue[]>(queueCount);
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
for (size_t i = 0; i < times; i += quantum) {
for (size_t j = 0; j < quantum; ++j) {
for (size_t k = 0; k < queueCount; ++k) {
Message* message = new Message;
queues[k].dispatchAsync([message] {
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
size_t hash = message->hash();
if (hash)
abort();
delete message;
});
}
}
for (size_t i = 0; i < queueCount; ++i)
queues[i].dispatchSync([] { });
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
}
for (size_t i = 0; i < queueCount; ++i)
queues[i].dispatchSync([] { });
Let's benchmark malloc https://bugs.webkit.org/show_bug.cgi?id=131118 Reviewed by Mark Hahnenberg. I want to replace fastMalloc with something faster (fasterMalloc?). I wrote these benchmarks to test / drive development. * MallocBench: Added. * MallocBench/MallocBench: Added. * MallocBench/MallocBench.xcodeproj: Added. * MallocBench/MallocBench.xcodeproj/project.pbxproj: Added. * MallocBench/MallocBench/Benchmark.cpp: Added. (allocateHeap): (deallocateHeap): (Benchmark::Benchmark): (Benchmark::printBenchmarks): (Benchmark::runOnce): (Benchmark::run): (Benchmark::printReport): (Benchmark::currentTimeMS): (Benchmark::currentMemoryBytes): * MallocBench/MallocBench/Benchmark.h: Added. (Benchmark::Memory::Memory): (Benchmark::Memory::operator-): (Benchmark::isValid): * MallocBench/MallocBench/CPUCount.cpp: Added. (cpuCount): * MallocBench/MallocBench/CPUCount.h: Added. * MallocBench/MallocBench/CommandLine.cpp: Added. (CommandLine::printUsage): * MallocBench/MallocBench/CommandLine.h: Added. (CommandLine::isValid): (CommandLine::benchmarkName): (CommandLine::isParallel): (CommandLine::heapSize): (CommandLine::measureHeap): * MallocBench/MallocBench/Interpreter.cpp: Added. (Interpreter::Interpreter): (Interpreter::~Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Added. * MallocBench/MallocBench/balloon.cpp: Added. (benchmark_balloon): * MallocBench/MallocBench/balloon.h: Added. * MallocBench/MallocBench/big.cpp: Added. (benchmark_big): * MallocBench/MallocBench/big.h: Added. * MallocBench/MallocBench/churn.cpp: Added. (HeapDouble::operator new): (HeapDouble::operator delete): (HeapDouble::HeapDouble): (HeapDouble::operator+=): (benchmark_churn): * MallocBench/MallocBench/churn.h: Added. * MallocBench/MallocBench/crash.ops: Added. * MallocBench/MallocBench/facebook.cpp: Added. (benchmark_facebook): * MallocBench/MallocBench/facebook.h: Added. * MallocBench/MallocBench/facebook.ops: Added. * MallocBench/MallocBench/fragment.cpp: Added. (validate): (benchmark_fragment): (benchmark_fragment_iterate): * MallocBench/MallocBench/fragment.h: Added. * MallocBench/MallocBench/list.cpp: Added. (benchmark_list_allocate): (benchmark_list_traverse): * MallocBench/MallocBench/list.h: Added. * MallocBench/MallocBench/main.cpp: Added. (main): * MallocBench/MallocBench/mbmalloc.cpp: Added. * MallocBench/MallocBench/mbmalloc.h: Added. * MallocBench/MallocBench/medium.cpp: Added. (benchmark_medium): * MallocBench/MallocBench/medium.h: Added. * MallocBench/MallocBench/message.cpp: Added. (benchmark_message_one): (benchmark_message_many): * MallocBench/MallocBench/message.h: Added. * MallocBench/MallocBench/realloc.cpp: Added. (benchmark_realloc): * MallocBench/MallocBench/realloc.h: Added. * MallocBench/MallocBench/tree.cpp: Added. (benchmark_tree_allocate): (benchmark_tree_traverse): (benchmark_tree_churn): * MallocBench/MallocBench/tree.h: Added. * MallocBench/run-malloc-benchmarks: Added. Canonical link: https://commits.webkit.org/149171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-02 21:38:49 +00:00
}