Commit 090a3c55 authored by Philipp Götze's avatar Philipp Götze
Browse files

Changes during DaMoN experiments

parent fc4b24c5
#!/bin/bash
### LOCATIONS ###
REPO_ROOT=$PWD
BUILD_DIR=build
DATA=/mnt/mem/test/tree_bench.data
OUTPUT_FILE=$REPO_ROOT/results/writes.csv
### CUSTOMIZABLE PARAMETERS ###
bsize=512
depth=0
keypos=('first' 'middle' 'last')
LEAF_SIZES=( 256 512 1024 2048 4096 )
TREE="wBP" #FP/PBP/wBP
TREE_BASE="wBP" # for namespace and numKeys determination
SUFFIX="" # in case of binary vs. linear
### Do not change anything following here!!! ###
### needs manual adaption ###
fillratio=1.0
lat=75
### adapting Tree usage ###
sed -i'' -e 's/\(.*BRANCH_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$bsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*DEPTH = \)\([0-9]\+\)\(.*\)/\1'"$depth"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*\"\).*\(Tree.hpp\"\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #include
sed -i'' -e 's/\(.*dbis::\).*\(tree;\)/\1'"${TREE_BASE,,}"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #namespace
sed -i'' -e 's/\(.*LEAFKEYS = getLeafKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*BRANCHKEYS = getBranchKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*TreeType = \).*\(Tree.*\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #type
echo -n "Running benchmarks for ${Tree}Tree..."
for pos in "${keypos[@]}"
do
echo -en "\nKey Position: $pos - "
KEYPOS='2'
if [ $pos == "first" ];then
KEYPOS='ELEMENTS'
elif [ $pos == "last" ]; then
KEYPOS='1'
fi
sed -i'' -e 's/\(.*KEYPOS = ELEMENTS\/\)\(.\+\)\(;.*\)/\1'"$KEYPOS"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
for lsize in "${LEAF_SIZES[@]}"
do
echo -n "$lsize "
sed -i'' -e 's/\(.*LEAF_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$lsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
pushd $BUILD_DIR > /dev/null
make tree_insert > /dev/null
rm -rf $DATA
OUTPUT="$(sh -c 'bench/tree_insert --benchmark_format=csv --benchmark_min_time=0.005' 2> /dev/null | tail -4)"
writes="$(echo "$OUTPUT" | head -1 | cut -d ':' -f2)"
elements="$(echo "$OUTPUT" | head -2 | tail -1 | cut -d ':' -f2)"
time="$(echo "$OUTPUT" | tail -1 | cut -d ',' -f4)"
echo "${TREE}Tree$SUFFIX,$elements,$lsize,$bsize,$depth,$fillratio,$pos,$time,$writes" >> $OUTPUT_FILE
popd > /dev/null
done
done
echo -e "\nFinished. Results in $OUTPUT_FILE"
#!/bin/bash
### LOCATIONS ###
REPO_ROOT=$PWD
BUILD_DIR=build
DATA=/mnt/mem/test/tree_bench.data
OUTPUT_FILE=$REPO_ROOT/results/bytesWritten.csv
### CUSTOMIZABLE PARAMETERS ###
bsize=512
depth=0
keypos=('first' 'middle' 'last')
LEAF_SIZES=( 256 512 1024 2048 4096 )
TREE="UnsortedPBP" #FP/PBP/wBP
TREE_BASE="PBP" # for namespace and numKeys determination
SUFFIX="" # in case of binary vs. linear
### Do not change anything following here!!! ###
### needs manual adaption ###
fillratio=1.0
lat=750
### adapting Tree usage ###
sed -i'' -e 's/\(.*BRANCH_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$bsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*DEPTH = \)\([0-9]\+\)\(.*\)/\1'"$depth"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*\"\).*\(Tree.hpp\"\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #include
sed -i'' -e 's/\(.*dbis::\).*\(tree;\)/\1'"${TREE_BASE,,}"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #namespace
sed -i'' -e 's/\(.*LEAFKEYS = getLeafKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*BRANCHKEYS = getBranchKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*TreeType = \).*\(Tree.*\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #type
echo -n "Running benchmarks for ${Tree}Tree..."
for pos in "${keypos[@]}"
do
echo -en "\nKey Position: $pos - "
KEYPOS='2'
if [ $pos == "first" ];then
KEYPOS='ELEMENTS'
elif [ $pos == "last" ]; then
KEYPOS='1'
fi
sed -i'' -e 's/\(.*KEYPOS = ELEMENTS\/\)\(.\+\)\(;.*\)/\1'"$KEYPOS"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
for lsize in "${LEAF_SIZES[@]}"
do
echo -n "$lsize "
sed -i'' -e 's/\(.*LEAF_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$lsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
pushd $BUILD_DIR > /dev/null
make tree_insert > /dev/null
for r in {1..5}
do
rm -rf $DATA
OUTPUT="$(sh -c 'bench/tree_insert --benchmark_format=csv --benchmark_min_time=0.005' 2> /dev/null | tail -4)"
writes="$(echo "$OUTPUT" | head -1 | cut -d ':' -f2)"
elements="$(echo "$OUTPUT" | tail -3 | head -1 | cut -d ':' -f2)"
time="$(echo "$OUTPUT" | tail -1 | cut -d ',' -f4)"
echo "${TREE}Tree$SUFFIX,$elements,$lsize,$bsize,$depth,$fillratio,$pos,$time,$writes,$lat" >> $OUTPUT_FILE
done
popd > /dev/null
done
done
echo -e "\nFinished. Results in $OUTPUT_FILE"
#!/bin/bash
### LOCATIONS ###
REPO_ROOT=$PWD
BUILD_DIR=build
DATA=/mnt/mem/test/tree_bench.data
OUTPUT_FILE=$REPO_ROOT/results/testing.csv
### CUSTOMIZABLE PARAMETERS ###
bsize=512
depth=1
#LEAF_SIZES=( 256 512 1024 2048 4096 )
LEAF_SIZES=( 1024 )
TREE="FP" #FP/PBP/Unsorted/wBP
TREE_BASE="FP" #FP/PBP/wBP
SUFFIX="" # in case of binary vs. linear
### Do not change anything following here!!! ###
### needs manual adaption ###
fillratio=1.0
keypos="last" #first/middle/last
### adapting Tree usage ###
sed -i'' -e 's/\(.*BRANCH_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$bsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*DEPTH = \)\([0-9]\+\)\(.*\)/\1'"$depth"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*\"\).*\(Tree.hpp\"\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #include
sed -i'' -e 's/\(.*dbis::\).*\(tree;\)/\1'"${TREE_BASE,,}"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #namespace
sed -i'' -e 's/\(.*LEAFKEYS = getLeafKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*BRANCHKEYS = getBranchKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*TreeType = \).*\(Tree.*\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #type
echo -n "Running benchmarks for ${Tree}Tree..."
for lsize in "${LEAF_SIZES[@]}"
do
echo -en "\nLeaf size: $lsize"
sed -i'' -e 's/\(.*LEAF_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$lsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
rm -rf $DATA
pushd $BUILD_DIR > /dev/null
make tree_get > /dev/null
for r in {1..3}
do
OUTPUT="$(sh -c 'bench/tree_get --benchmark_format=csv' 2> /dev/null | tail -3)"
elements="$(echo "$OUTPUT" | head -1 | cut -d ':' -f2)"
time="$(echo "$OUTPUT" | tail -1 | cut -d ',' -f4)"
echo "${TREE}Tree$SUFFIX,$elements,$lsize,$bsize,$depth,$fillratio,$keypos,$time" >> $OUTPUT_FILE
done
popd > /dev/null
done
echo -e "\nFinished. Results in $OUTPUT_FILE"
#!/bin/bash
### LOCATIONS ###
REPO_ROOT=$PWD
BUILD_DIR=build
DATA=/mnt/mem/test/tree_bench.data
OUTPUT_FILE=$REPO_ROOT/results/split2.csv
### CUSTOMIZABLE PARAMETERS ###
bsize=512
depth=0
LEAF_SIZES=( 256 512 1024 2048 4096 )
TREE="UnsortedPBP" #FP/PBP/wBP
TREE_BASE="PBP" # for namespace and numKeys determination
SUFFIX="" # in case of binary vs. linear
### Do not change anything following here!!! ###
### needs manual adaption ###
fillratio=1.0
lat=75
### adapting Tree usage ###
sed -i'' -e 's/\(.*BRANCH_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$bsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*DEPTH = \)\([0-9]\+\)\(.*\)/\1'"$depth"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*\"\).*\(Tree.hpp\"\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #include
sed -i'' -e 's/\(.*dbis::\).*\(tree;\)/\1'"${TREE_BASE,,}"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #namespace
sed -i'' -e 's/\(.*LEAFKEYS = getLeafKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*BRANCHKEYS = getBranchKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*TreeType = \).*\(Tree.*\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #type
echo -n "Running benchmarks for ${Tree}Tree..."
for lsize in "${LEAF_SIZES[@]}"
do
echo -n "$lsize "
sed -i'' -e 's/\(.*LEAF_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$lsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
pushd $BUILD_DIR > /dev/null
make tree_split > /dev/null
for r in {1..5}
do
rm -rf $DATA
OUTPUT="$(sh -c 'bench/tree_split --benchmark_format=csv --benchmark_min_time=0.01' 2> /dev/null | tail -4)"
writes="$(echo "$OUTPUT" | head -1 | cut -d ':' -f2)"
elements="$(echo "$OUTPUT" | tail -3 | head -1 | cut -d ':' -f2)"
time="$(echo "$OUTPUT" | tail -1 | cut -d ',' -f4)"
echo "${TREE}Tree$SUFFIX,$elements,$lsize,$bsize,$depth,$fillratio,$(($elements+1)),$time,$writes,$lat" >> $OUTPUT_FILE
done
popd > /dev/null
done
echo -e "\nFinished. Results in $OUTPUT_FILE"
......@@ -17,7 +17,7 @@ option(ENABLE_LOG "enables log output for e.g. debugging" OFF)
option(ENABLE_PROFILING "enables profiling for some of the structures" OFF)
option(BUILD_TEST_CASES "build tests for functionality of structures" ON )
option(BUILD_GOOGLE_BENCH "build google benchmark" OFF)
option(BUILD_BENCHMARKS "build benchmarks for structures" OFF)
option(BUILD_BENCHMARKS "build benchmarks for structures" ON )
################################################################################
# End of customization section #
......@@ -99,7 +99,7 @@ include_directories(${PROJECT_SOURCE_DIR}
${THIRD_PARTY_DIR}/pmdk/include)
add_library(nvmDS_deps STATIC ${THIRD_PARTY_DIR}/pmdk)
add_dependencies(nvmDS_deps fmt_target catch_target pmdk_target) #< executes custom commands
target_link_libraries(nvmDS_deps ${PMDK_LIBRARIES} ndctl daxctl)
target_link_libraries(nvmDS_deps ${PMDK_LIBRARIES} stdc++fs ndctl daxctl)
set_target_properties(nvmDS_deps PROPERTIES LINKER_LANGUAGE CXX)
#################
......
......@@ -3,6 +3,8 @@ include(../../cmake/Testing.cmake.in)
if (BUILD_BENCHMARKS)
do_bench(trees/tree_get)
do_bench(trees/tree_traverse)
do_bench(trees/tree_insert)
do_bench(trees/tree_split)
# PTABLE
do_bench(ptable/insert ptable)
do_bench(ptable/scan ptable)
......
......@@ -37,11 +37,11 @@ using pmem::obj::pool;
/* Customization section */
using MyTuple = std::tuple <int, int, double>;
using MyKey = unsigned long long;
constexpr auto TARGET_BRANCH_SIZE = 2048;
constexpr auto TARGET_LEAF_SIZE = 512; //< 512B best performance
constexpr auto TARGET_DEPTH = 4;
constexpr auto TARGET_BRANCH_SIZE = 512;
constexpr auto TARGET_LEAF_SIZE = 1024; //< 512B best performance
constexpr auto TARGET_DEPTH = 1;
const std::string path = dbis::gPmemPath + "tree_bench.data";
constexpr auto POOL_SIZE = 1024 * 1024 * 1024; //< 128MB
constexpr auto POOL_SIZE = 1024 * 1024 * 1024 * 4ull; //< 4GB
constexpr auto LAYOUT = "Tree";
/* wBPTree pre-calculations */
......@@ -105,8 +105,9 @@ constexpr uint64_t ipow(uint64_t base, int exp, uint64_t result = 1) {
/* Tree relevant calculated parameters*/
constexpr auto LEAFKEYS = getLeafKeysFPTree<5>(); //< 5 iterations should be enough
constexpr auto BRANCHKEYS = getBranchKeyswBPTree<5>();
constexpr auto BRANCHKEYS = getBranchKeysFPTree<5>();
constexpr auto ELEMENTS = LEAFKEYS*ipow(BRANCHKEYS+1, TARGET_DEPTH);
constexpr auto KEYPOS = ELEMENTS/1;
using TreeType = FPTree<MyKey, MyTuple, BRANCHKEYS, LEAFKEYS>;
......@@ -145,12 +146,17 @@ void insert(persistent_ptr<TreeType> &tree) {
};
std::function<void(int)> insertLoopOtherHalf = [&](int depth) {
//tree->printBranchNode(0, tree->rootNode.branch);
if (depth == 0) {
auto otherHalf = (LEAFKEYS + 1) / 2;
for(auto i = 0; i < ipow(BRANCHKEYS+1,TARGET_DEPTH-depth); ++i)
insertLoopLeaf(otherHalf + i * LEAFKEYS);
} else {
auto otherHalf = (LEAFKEYS * ipow(BRANCHKEYS+1, depth) + 1) / 2 + LEAFKEYS * ipow(BRANCHKEYS+1, depth-1);
auto nodeRange = LEAFKEYS * ipow(BRANCHKEYS+1, depth);
auto lowerRange = LEAFKEYS * ipow(BRANCHKEYS+1, depth-1);
auto middle = (nodeRange + 1) / 2;
auto seen = middle + lowerRange;
auto otherHalf = (BRANCHKEYS%2==0)? seen - (lowerRange+1)/2 : seen;
for(auto i = 0; i < ipow(BRANCHKEYS+1,TARGET_DEPTH-depth); ++i)
insertLoopBranch(otherHalf + i * LEAFKEYS * ipow(BRANCHKEYS+1, depth), depth, true);
insertLoopOtherHalf(depth-1);
......@@ -159,7 +165,6 @@ void insert(persistent_ptr<TreeType> &tree) {
insertLoopBranch(0, TARGET_DEPTH, false);
insertLoopOtherHalf(TARGET_DEPTH);
//tree->printBranchNode(0, tree->rootNode.branch);
auto avg = std::accumulate(measures.begin(), measures.end(), 0) / measures.size();
auto minmax = std::minmax_element(std::begin(measures), std::end(measures));
......
......@@ -39,37 +39,32 @@ static void BM_TreeGet(benchmark::State &state) {
} else {
LOG("Warning: " << path << " already exists");
pop = pool<root>::open(path, LAYOUT);
pop.root()->tree->recover(); //< FPTree only
pop.root()->tree->recover(); //< hybrids only
}
auto tree = pop.root()->tree;
//tree->printBranchNode(0, tree->rootNode.branch);
/* Getting a leaf node */
auto node = tree->rootNode;
/* FPTree version */
/* hybrid versions */
auto d = tree->depth;
while ( d > 1) {
node = node.branch->children[0];
--d;
}
if(d == 1) node = node.lowestbranch->children[0];
while ( d-- > 0) node = node.branch->children[0];
/* nvm-only trees */
//auto d = tree->depth.get_ro();
//while ( d-- > 0) node = node.branch->children.get_ro()[0];
/* other trees */
/*
auto d = tree->depth.get_ro();
while ( --d > 0) node = node.branch->children.get_ro()[0];
*/
auto leaf = node.leaf;
/* BENCHMARKING */
unsigned int p;
for (auto _ : state) {
//MyTuple tp;
//auto c = 0u;
//auto func = [&](MyKey const &key, MyTuple const &val) { c++; };
//tree->scan(ELEMENTS/2, ELEMENTS/2 + 99, func);
//tree->lookup(ELEMENTS/2, &tp);
auto p = tree->lookupPositionInLeafNode(leaf, 1);
benchmark::DoNotOptimize(
p = tree->lookupPositionInLeafNode(leaf, LEAFKEYS)
);
}
//tree->printBranchNode(0, tree->rootNode.branch);
std::cout << "Elements:" << ELEMENTS << '\n';
pop.close();
......
/*
* Copyright (C) 2017-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
*
* This file is part of our NVM-based Data Structure Repository.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <filesystem>
#include "common.hpp"
#include "utils/PersistEmulation.hpp"
void prepare(const persistent_ptr<TreeType> tree);
/* Get benchmarks on Tree */
static void BM_TreeInsert(benchmark::State &state) {
std::cout << "BRANCHKEYS: " << BRANCHKEYS
<< "\nLEAFKEYS: " << LEAFKEYS
<< "\n";
struct root {
persistent_ptr<TreeType> tree;
};
pool<root> pop;
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, POOL_SIZE);
transaction::run(pop, [&] {
pop.root()->tree = make_persistent<TreeType>();
});
} else {
LOG("Warning: " << path << " already exists");
auto n = std::filesystem::remove_all(path);
pop = pool<root>::create(path, LAYOUT);
transaction::run(pop, [&] {
delete_persistent<TreeType>(pop.root()->tree);
pop.root()->tree = make_persistent<TreeType>();
});
}
auto tree = pop.root()->tree;
/* Getting the leaf node */
auto leaf = tree->rootNode.leaf;
//tree->printLeafNode(0, leaf);
const auto reqTup = MyTuple(KEYPOS, KEYPOS * 100, KEYPOS * 1.0);
TreeType::SplitInfo splitInfo;
bool split;
/* BENCHMARKING */
for (auto _ : state) {
state.PauseTiming();
std::cout.setstate(std::ios_base::failbit);
tree->rootNode = tree->newLeafNode();
leaf = tree->rootNode.leaf;
prepare(tree);
dbis::PersistEmulation::getBytesWritten();
state.ResumeTiming();
split = tree->insertInLeafNode(leaf, KEYPOS, reqTup, &splitInfo);
state.PauseTiming();
assert(split == false);
tree->deleteLeafNode(leaf);
state.ResumeTiming();
}
//tree->printLeafNode(0, leaf);
std::cout.clear();
std::cout << "Writes:" << dbis::PersistEmulation::getBytesWritten() << '\n';
std::cout << "Elements:" << ELEMENTS << '\n';
pop.close();
}
BENCHMARK(BM_TreeInsert);
BENCHMARK_MAIN();
/* preparing inserts */
void prepare(const persistent_ptr<TreeType> tree) {
auto insertLoop = [&tree](int start, int end) {
for (auto j = start; j < end + 1; ++j) {
auto tup = MyTuple(j, j * 100, j * 1.0);
tree->insert(j, tup);
}
};
switch (KEYPOS) {
case 1 /*first*/: insertLoop(2, ELEMENTS); break;
case ELEMENTS /*last*/: insertLoop(1, ELEMENTS-1);break;
case ELEMENTS/2 /*middle*/: {insertLoop(1, KEYPOS-1); insertLoop(KEYPOS+1, ELEMENTS);}
}
}
/*
* Copyright (C) 2017-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
*
* This file is part of our NVM-based Data Structure Repository.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <filesystem>
#include "common.hpp"
#include "utils/PersistEmulation.hpp"
void prepare(const persistent_ptr<TreeType> tree);
/* Get benchmarks on Tree */
static void BM_TreeSplit(benchmark::State &state) {
std::cout << "BRANCHKEYS: " << BRANCHKEYS
<< "\nLEAFKEYS: " << LEAFKEYS
<< "\n";
struct root {
persistent_ptr<TreeType> tree;
};
pool<root> pop;
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, POOL_SIZE);
transaction::run(pop, [&] {
pop.root()->tree = make_persistent<TreeType>();
});
} else {
LOG("Warning: " << path << " already exists");
auto n = std::filesystem::remove_all(path);
pop = pool<root>::create(path, LAYOUT);
transaction::run(pop, [&] {
delete_persistent<TreeType>(pop.root()->tree);
pop.root()->tree = make_persistent<TreeType>();
});
}
auto tree = pop.root()->tree;
/* Getting the leaf node */
auto leaf = tree->rootNode.leaf;
//tree->printLeafNode(0, leaf);
const auto reqTup = MyTuple(ELEMENTS+1, (ELEMENTS+1) * 100, (ELEMENTS+1) * 1.0);
TreeType::SplitInfo splitInfo;
bool split;
/* BENCHMARKING */
for (auto _ : state) {
state.PauseTiming();
std::cout.setstate(std::ios_base::failbit);
tree->rootNode = tree->newLeafNode();
leaf = tree->rootNode.leaf;
prepare(tree);
dbis::PersistEmulation::getBytesWritten();
//tree->printLeafNode(0, leaf);
state.ResumeTiming();
tree->splitLeafNode(leaf, &splitInfo);
state.PauseTiming();
//tree->printLeafNode(0, leaf);
tree->deleteLeafNode(leaf->nextLeaf);
tree->deleteLeafNode(leaf);
state.ResumeTiming();
}
//tree->printLeafNode(0, leaf);
std::cout.clear();
std::cout << "Writes:" << dbis::PersistEmulation::getBytesWritten() << '\n';
std::cout << "Elements:" << ELEMENTS << '\n';
pop.close();
}
BENCHMARK(BM_TreeSplit);
BENCHMARK_MAIN();
/* preparing inserts */
void prepare(const persistent_ptr<TreeType> tree) {
for (auto j = 1; j < ELEMENTS+1; ++j) {
auto tup = MyTuple(j, j * 100, j * 1.0);
tree->insert(j, tup);
}
}
......@@ -39,35 +39,33 @@ static void BM_TreeTraverse(benchmark::State &state) {
} else {
LOG("Warning: " << path << " already exists");
pop = pool<root>::open(path, LAYOUT);
pop.root()->tree->recover(); //< FPTree only
//pop.root()->tree->recover(); //< Hybrids only
}
auto tree = pop.root()->tree;
persistent_ptr<TreeType::LeafNode> leaf;
/* BENCHMARKING */
for (auto _ : state) {
/* Getting a leaf node */
auto node = tree->rootNode;
/* FPTree version */
/* hybrid versions *//*
auto d = tree->depth;
while ( d > 1) {
node = node.branch->children[tree->lookupPositionInBranchNode(node.branch, 1)];
--d;
}
if(d == 1) node = node.lowestbranch->children[0];
while ( --d > 0)
node = node.branch->children[tree->lookupPositionInBranchNode(node.branch, KEYPOS)];*/
/* NVM-only versions */
auto d = tree->depth.get_ro();
while ( --d > 0)
node = node.branch->children.get_ro()[tree->lookupPositionInBranchNode(node.branch, KEYPOS)];
/* other trees */
/*
auto d = tree->depth.get_ro();
while ( --d > 0)
node = node.branch->children.get_ro()[tree->lookupPositionInBranchNode(node.branch, 1)];
*/
auto leaf = node.leaf;
benchmark::DoNotOptimize(