haikuwebkit/PerformanceTests/MallocBench/MallocBench/Interpreter.h

92 lines
2.9 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.
*/
#ifndef Interpreter_h
#define Interpreter_h
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
#include <condition_variable>
#include <mutex>
#include <thread>
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 <vector>
class Interpreter {
public:
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
Interpreter(const char* fileName, bool shouldFreeAllObjects = true, bool useThreadId = false);
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
~Interpreter();
void run();
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 detailedReport();
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
private:
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
typedef unsigned short ThreadId; // 0 is the main thread
typedef unsigned short Log2Alignment; // log2(alignment) or ~0 for non power of 2.
enum Opcode { op_malloc, op_free, op_realloc, op_align_malloc };
struct Op { Opcode opcode; ThreadId threadId; Log2Alignment alignLog2; size_t slot; size_t size; };
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
struct Record { void* object; size_t size; };
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
class Thread
{
public:
Thread(Interpreter*, ThreadId);
~Thread();
void runThread();
void waitToRun();
void switchTo();
void stop();
bool isMainThread() { return m_threadId == 0; }
private:
ThreadId m_threadId;
Interpreter* m_myInterpreter;
std::condition_variable m_shouldRun;
std::thread m_thread;
};
bool readOps();
void doOnSameThread(ThreadId);
void switchToThread(ThreadId);
void doMallocOp(Op, ThreadId);
Added some more Membuster recordings to MallocBench https://bugs.webkit.org/show_bug.cgi?id=131862 Reviewed by Sam Weinig. * MallocBench/MallocBench/Benchmark.cpp: (Benchmark::Benchmark): (Benchmark::run): * MallocBench/MallocBench/Benchmark.h: * MallocBench/MallocBench/CommandLine.cpp: * MallocBench/MallocBench/CommandLine.h: (CommandLine::runs): Added a --runs option, so we can specify zero runs for memory warning benchmarks. Those benchmarks want zero runs so that they can perform a single warmup, which does not free all allocated objects, and then see how far back to 0MB they can get. Running multiple times would accumulate leaks, which is not representative of the simulated scenario. * MallocBench/MallocBench/Interpreter.cpp: (Interpreter::Interpreter): (Interpreter::run): * MallocBench/MallocBench/Interpreter.h: Support not deallocating all objects allocated during the recording, so we can do low memory warning memory use measurements, as above. * MallocBench/MallocBench/flickr.cpp: (benchmark_flickr_memory_warning): * MallocBench/MallocBench/main.cpp: (main): * MallocBench/MallocBench/reddit.cpp: (benchmark_reddit_memory_warning): * MallocBench/MallocBench/theverge.cpp: (benchmark_theverge_memory_warning): Adopt the API above. * MallocBench/run-malloc-benchmarks: I took a first pass at listing all available benchmarks here. Then I commented out the benchmarks that probably aren't reasonable to run by default. Canonical link: https://commits.webkit.org/149931@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167511 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-04-18 22:31:34 +00:00
bool m_shouldFreeAllObjects;
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
bool m_useThreadId;
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
int m_fd;
size_t m_opCount;
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
size_t m_remaining;
size_t m_opsCursor;
size_t m_opsInBuffer;
ThreadId m_currentThreadId;
std::vector<Op> m_ops;
std::mutex m_threadMutex;
std::condition_variable m_shouldRun;
std::vector<Thread*> m_threads;
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
std::vector<Record> m_objects;
};
#endif // Interpreter_h