From 1e0ee9095ce87a3cee0b44a120f6297ac672f5d0 Mon Sep 17 00:00:00 2001 From: Martin Ankerl Date: Fri, 29 Dec 2017 11:36:11 +0100 Subject: Use best-fit strategy in Arena, now O(log(n)) instead O(n) This replaces the first-fit algorithm used in the Arena with a best-fit. According to "Dynamic Storage Allocation: A Survey and Critical Review", Wilson et. al. 1995, http://www.scs.stanford.edu/14wi-cs140/sched/readings/wilson.pdf, both startegies work well in practice. The advantage of using best-fit is that we can switch the slow O(n) algorithm to O(log(n)) operations. Additionally, some previously O(log(n)) operations are now replaced with O(1) operations by using a hash map. The end effect is that the benchmark runs about 2.5 times faster on my machine: old: BenchLockedPool, 5, 530, 5.25749, 0.00196938, 0.00199755, 0.00198172 new: BenchLockedPool, 5, 1300, 5.11313, 0.000781493, 0.000793314, 0.00078606 I've run all unit tests and benchmarks. --- src/bench/lockedpool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/bench') diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp index 914e37a2ed..8b7fe5f609 100644 --- a/src/bench/lockedpool.cpp +++ b/src/bench/lockedpool.cpp @@ -43,4 +43,4 @@ static void BenchLockedPool(benchmark::State& state) addr.clear(); } -BENCHMARK(BenchLockedPool, 530); +BENCHMARK(BenchLockedPool, 1300); -- cgit v1.2.3