Comprehensive benchmarks of C++ maps
ninja
and cmake
git clone --recurse-submodules https://github.com/martinus/map_benchmark.git
./map_benchmark/tools/build.sh
git submodule update --force --remote
The implementation if the benchmark is open source, get it here: martinus/map_benchmark. It is split in several parts:
external
: all map implementations available through github are added as git submodules here.src/hashes
: One directory for each hashing algorithm, each directory contains a Hash.h
which basically contains a using
instruction for the hash, e.g. like this:
template <class Key>
using Hash = robin_hood::hash<Key>;
src/maps
: One directory for each unordered map implementation, each directory contains a Map.h
which basically contains a using
instruction for the map. It includes Hash.h
. E.g. like this:
#include "Hash.h"
template <class Key, class Val>
using Map = robin_hood::unordered_flat_map<Key, Val, Hash<Key>>;
external
, add a submodule:
cd external
git submodule add -b master https://github.com/rigtorp/HashMap.git rigtorp__HashMap
src/map/
with a file Hash.h
. See the others for example.iterator->first
and iterator->second
do not exist.lscpu --extended
to find out if you have hyperthreadding. E.g. for me it shows
$ lscpu --extended
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ
0 0 0 0 0:0:0:0 yes 4600,0000 800,0000
1 0 0 1 1:1:1:0 yes 4600,0000 800,0000
2 0 0 2 2:2:2:0 yes 4600,0000 800,0000
3 0 0 3 3:3:3:0 yes 4600,0000 800,0000
4 0 0 4 4:4:4:0 yes 4600,0000 800,0000
5 0 0 5 5:5:5:0 yes 4600,0000 800,0000
6 0 0 0 0:0:0:0 yes 4600,0000 800,0000
7 0 0 1 1:1:1:0 yes 4600,0000 800,0000
8 0 0 2 2:2:2:0 yes 4600,0000 800,0000
9 0 0 3 3:3:3:0 yes 4600,0000 800,0000
10 0 0 4 4:4:4:0 yes 4600,0000 800,0000
11 0 0 5 5:5:5:0 yes 4600,0000 800,0000
/etc/default/grub
and change GRUB_CMDLINE_LINUX_DEFAULT so it looks like this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash isolcpus=5,11 rcu_nocbs=5,11"
sudo update-grub
bench.rb
so the taskset -c ...
prefix is correct.perf
, see https://perf.readthedocs.io/en/latest/sudo python3 -m perf system tune
../tools/bench.rb |tee ../data/all_new.txt
Sources: