Commit 3ca48bc6 authored by Philipp Götze's avatar Philipp Götze
Browse files

🔥 Removed manual profiling

parent 25ad6535
...@@ -14,7 +14,6 @@ if(NOT PROJECT_INSTALL_DIR) ...@@ -14,7 +14,6 @@ if(NOT PROJECT_INSTALL_DIR)
endif() endif()
option(ENABLE_LOG "enables log output for e.g. debugging" OFF) 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_TEST_CASES "build tests for functionality of structures" ON )
option(BUILD_GOOGLE_BENCH "build google benchmark" OFF) option(BUILD_GOOGLE_BENCH "build google benchmark" OFF)
option(BUILD_BENCHMARKS "build benchmarks for structures" ON ) option(BUILD_BENCHMARKS "build benchmarks for structures" ON )
...@@ -27,10 +26,6 @@ if(ENABLE_LOG) ...@@ -27,10 +26,6 @@ if(ENABLE_LOG)
add_definitions("-DENABLE_LOG") add_definitions("-DENABLE_LOG")
endif() endif()
if(ENABLE_PROFILING)
add_definitions("-DENABLE_PROFILING")
endif()
# Benchmark test requires benchmark library # Benchmark test requires benchmark library
if (BUILD_BENCHMARKS) if (BUILD_BENCHMARKS)
set(BUILD_GOOGLE_BENCH ON) set(BUILD_GOOGLE_BENCH ON)
......
...@@ -103,7 +103,6 @@ int main(){ ...@@ -103,7 +103,6 @@ int main(){
curr_test_size--; curr_test_size--;
keys[choosen_key] = keys[curr_test_size]; keys[choosen_key] = keys[curr_test_size];
} }
auto avg = std::accumulate(insert_measures.begin(), insert_measures.end(), 0) / insert_measures.size(); auto avg = std::accumulate(insert_measures.begin(), insert_measures.end(), 0) / insert_measures.size();
auto minmax = std::minmax_element(std::begin(insert_measures), std::end(insert_measures)); auto minmax = std::minmax_element(std::begin(insert_measures), std::end(insert_measures));
...@@ -111,9 +110,6 @@ int main(){ ...@@ -111,9 +110,6 @@ int main(){
<< "\n\tAverage: \t" << avg << "\n\tAverage: \t" << avg
<< "\n\tMin: \t" << *minmax.first << "\n\tMin: \t" << *minmax.first
<< "\n\tMax: \t" << *minmax.second << '\n'; << "\n\tMax: \t" << *minmax.second << '\n';
#ifdef IDXPROFILE
pTable->printIdxProfile();
#endif
std::cout << "\n####################################\n"; std::cout << "\n####################################\n";
//Lookup measures //Lookup measures
...@@ -126,21 +122,18 @@ int main(){ ...@@ -126,21 +122,18 @@ int main(){
std::cout << "Didn't find " << key << std::endl; std::cout << "Didn't find " << key << std::endl;
} }
end = std::chrono::high_resolution_clock::now(); end = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count(); auto diff = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
lookup_measures.push_back(diff); lookup_measures.push_back(diff);
} }
avg = std::accumulate(lookup_measures.begin(), lookup_measures.end(), 0) / lookup_measures.size(); avg = std::accumulate(lookup_measures.begin(), lookup_measures.end(), 0) / lookup_measures.size();
minmax = std::minmax_element(std::begin(lookup_measures), std::end(lookup_measures)); minmax = std::minmax_element(std::begin(lookup_measures), std::end(lookup_measures));
std::cout << "\nLookup Statistics in µs: " std::cout << "\nLookup Statistics in µs: "
<< "\n\tAverage: \t" << avg << "\n\tAverage: \t" << avg
<< "\n\tMin: \t" << *minmax.first << "\n\tMin: \t" << *minmax.first
<< "\n\tMax: \t" << *minmax.second << '\n'; << "\n\tMax: \t" << *minmax.second << '\n';
#ifdef IDXPROFILE
pTable->printIdxProfile();
#endif
std::cout << "\n####################################\n"; std::cout << "\n####################################\n";
//Delete measures //Delete measures
...@@ -161,18 +154,14 @@ int main(){ ...@@ -161,18 +154,14 @@ int main(){
if(i==3*TEST_SIZE/4){std::cout<<"Fortschritt: 75%"<<std::endl;} if(i==3*TEST_SIZE/4){std::cout<<"Fortschritt: 75%"<<std::endl;}
curr_test_size--; curr_test_size--;
keys[choosen_key] = keys[curr_test_size]; keys[choosen_key] = keys[curr_test_size];
} }
avg = std::accumulate(delete_measures.begin(), delete_measures.end(), 0) / delete_measures.size(); avg = std::accumulate(delete_measures.begin(), delete_measures.end(), 0) / delete_measures.size();
minmax = std::minmax_element(std::begin(delete_measures), std::end(delete_measures)); minmax = std::minmax_element(std::begin(delete_measures), std::end(delete_measures));
std::cout << "\nDelete Statistics in µs: " std::cout << "\nDelete Statistics in µs: "
<< "\n\tAverage: \t" << avg << "\n\tAverage: \t" << avg
<< "\n\tMin: \t" << *minmax.first << "\n\tMin: \t" << *minmax.first
<< "\n\tMax: \t" << *minmax.second << '\n'; << "\n\tMax: \t" << *minmax.second << '\n';
#ifdef IDXPROFILE
pTable->printIdxProfile();
#endif
pop.close(); pop.close();
} }
......
...@@ -8,26 +8,6 @@ ...@@ -8,26 +8,6 @@
#define LOG(msg) #define LOG(msg)
#endif #endif
#ifdef ENABLE_PROFILING
#include <memory>
#include <IdxProfile.hpp>
#define PROFILE_DECL std::unique_ptr<IdxProfile> profile;
#define PROFILE_INIT profile = std::make_unique<IdxProfile>();
#define PROFILE_READ(n) profile->read(n);
#define PROFILE_WRITE(n) profile->write(n);
#define PROFILE_SPLIT profile->split();
#define PROFILE_UNDERFLOW profile->underflow();
#define PROFILE_PRINT void printIdxProfile() { profile->print(); }
#else
#define PROFILE_DECL
#define PROFILE_INIT
#define PROFILE_READ(n)
#define PROFILE_WRITE(n)
#define PROFILE_SPLIT
#define PROFILE_UNDERFLOW
#define PROFILE_PRINT
#endif
namespace dbis { namespace dbis {
const std::string gPmemPath("@PMEM_MNT_PATH@/"); const std::string gPmemPath("@PMEM_MNT_PATH@/");
} }
......
...@@ -167,7 +167,6 @@ class FPTree { ...@@ -167,7 +167,6 @@ class FPTree {
return newNode; return newNode;
} }
void deleteLeafNode(persistent_ptr<LeafNode> node) { void deleteLeafNode(persistent_ptr<LeafNode> node) {
auto pop = pmem::obj::pool_by_vptr(this); auto pop = pmem::obj::pool_by_vptr(this);
transaction::run(pop, [&] { transaction::run(pop, [&] {
...@@ -201,8 +200,6 @@ class FPTree { ...@@ -201,8 +200,6 @@ class FPTree {
Node rootNode; //< pointer to the root node Node rootNode; //< pointer to the root node
persistent_ptr<LeafNode> leafList; //<Pointer to the leaf at the most left position. Neccessary for recovery persistent_ptr<LeafNode> leafList; //<Pointer to the leaf at the most left position. Neccessary for recovery
PROFILE_DECL
public: public:
/** /**
* Typedef for a function passed to the scan method. * Typedef for a function passed to the scan method.
...@@ -266,7 +263,6 @@ class FPTree { ...@@ -266,7 +263,6 @@ class FPTree {
rootNode = newLeafNode(); rootNode = newLeafNode();
leafList = rootNode.leaf; leafList = rootNode.leaf;
depth = 0; depth = 0;
PROFILE_INIT
LOG("created new FPTree with sizeof(BranchNode) = " << sizeof(BranchNode) LOG("created new FPTree with sizeof(BranchNode) = " << sizeof(BranchNode)
<< ", sizeof(LeafNode) = " << sizeof(LeafNode)); << ", sizeof(LeafNode) = " << sizeof(LeafNode));
} }
...@@ -357,7 +353,6 @@ class FPTree { ...@@ -357,7 +353,6 @@ class FPTree {
auto node = rootNode.branch; auto node = rootNode.branch;
assert(node != nullptr); assert(node != nullptr);
result=eraseFromBranchNode(node, depth, key); result=eraseFromBranchNode(node, depth, key);
} }
}); });
return result; return result;
...@@ -412,8 +407,6 @@ class FPTree { ...@@ -412,8 +407,6 @@ class FPTree {
} }
} }
PROFILE_PRINT
/** /**
* Perform a scan over all key-value pairs stored in the tree. * Perform a scan over all key-value pairs stored in the tree.
* For each entry the given function @func is called. * For each entry the given function @func is called.
...@@ -509,7 +502,6 @@ class FPTree { ...@@ -509,7 +502,6 @@ class FPTree {
else else
insertInLeafNodeAtPosition(sibling, sibRef.search.get_ro().getFreeZero(), key, val); insertInLeafNodeAtPosition(sibling, sibRef.search.get_ro().getFreeZero(), key, val);
/* inform the caller about the split */ /* inform the caller about the split */
splitRef.key = sibRef.keys.get_ro()[findMinKeyAtLeafNode(sibling)]; splitRef.key = sibRef.keys.get_ro()[findMinKeyAtLeafNode(sibling)];
split = true; split = true;
...@@ -569,7 +561,6 @@ class FPTree { ...@@ -569,7 +561,6 @@ class FPTree {
splitRef.key = splitKey; splitRef.key = splitKey;
} }
/** /**
* Insert a (key, value) pair at the given position @c pos into the leaf node * Insert a (key, value) pair at the given position @c pos into the leaf node
* @c node. The caller has to ensure that * @c node. The caller has to ensure that
...@@ -766,7 +757,6 @@ class FPTree { ...@@ -766,7 +757,6 @@ class FPTree {
return pos; return pos;
} }
/** /**
* Delete the element with the given key from the given leaf node. * Delete the element with the given key from the given leaf node.
* *
...@@ -945,14 +935,12 @@ class FPTree { ...@@ -945,14 +935,12 @@ class FPTree {
BranchNode *witnessNode = nullptr; BranchNode *witnessNode = nullptr;
auto ppos = pos; auto ppos = pos;
if (prevKeys > 0) { if (prevKeys > 0) {
mergeBranchNodes(lSibling, node->keys[pos - 1], child); mergeBranchNodes(lSibling, node->keys[pos - 1], child);
ppos = pos - 1; ppos = pos - 1;
witnessNode = child; witnessNode = child;
newChild = lSibling; newChild = lSibling;
// pos -= 1; // pos -= 1;
} else if (nextKeys > 0) { } else if (nextKeys > 0) {
mergeBranchNodes(child, node->keys[pos], rSibling); mergeBranchNodes(child, node->keys[pos], rSibling);
witnessNode = rSibling; witnessNode = rSibling;
} else } else
...@@ -961,19 +949,15 @@ class FPTree { ...@@ -961,19 +949,15 @@ class FPTree {
// remove node->keys.get_ro()[pos] from node // remove node->keys.get_ro()[pos] from node
for (auto i = ppos; i < node->numKeys - 1; i++) { for (auto i = ppos; i < node->numKeys - 1; i++) {
node->keys[i] = node->keys[i + 1]; node->keys[i] = node->keys[i + 1];
} }
if (pos == 0) pos++; if (pos == 0) pos++;
for (auto i = pos; i < node->numKeys; i++) { for (auto i = pos; i < node->numKeys; i++) {
if (i + 1 <= node->numKeys) { if (i + 1 <= node->numKeys) {
node->children[i] = node->children[i + 1]; node->children[i] = node->children[i + 1];
} }
} }
node->numKeys--; node->numKeys--;
deleteBranchNode(witnessNode); deleteBranchNode(witnessNode);
return newChild; return newChild;
} }
...@@ -1314,7 +1298,6 @@ class FPTree { ...@@ -1314,7 +1298,6 @@ class FPTree {
auto child = node->children[k].leaf; auto child = node->children[k].leaf;
if (child != nullptr) printLeafNode(d + 1, child); if (child != nullptr) printLeafNode(d + 1, child);
} }
} }
} }
......
...@@ -217,8 +217,6 @@ class PTree { ...@@ -217,8 +217,6 @@ class PTree {
LeafOrBranchNode rootNode; //< pointer to the root node LeafOrBranchNode rootNode; //< pointer to the root node
persistent_ptr<LeafNode> leafList; //<Pointer to the leaf at the most left position. Neccessary for recovery persistent_ptr<LeafNode> leafList; //<Pointer to the leaf at the most left position. Neccessary for recovery
PROFILE_DECL
public: public:
/** /**
* Typedef for a function passed to the scan method. * Typedef for a function passed to the scan method.
...@@ -284,7 +282,6 @@ class PTree { ...@@ -284,7 +282,6 @@ class PTree {
rootNode = newLeafNode(); rootNode = newLeafNode();
leafList = rootNode.leaf; leafList = rootNode.leaf;
depth = 0; depth = 0;
PROFILE_INIT
} }
/** /**
...@@ -340,7 +337,6 @@ class PTree { ...@@ -340,7 +337,6 @@ class PTree {
root->numKeys = root->numKeys + 1; root->numKeys = root->numKeys + 1;
rootNode.branch = root; rootNode.branch = root;
depth = depth + 1; depth = depth + 1;
} }
} }
}); });
...@@ -397,7 +393,6 @@ class PTree { ...@@ -397,7 +393,6 @@ class PTree {
auto node = rootNode.branch; auto node = rootNode.branch;
assert(node != nullptr); assert(node != nullptr);
result=eraseFromBranchNode(node, depth, key); result=eraseFromBranchNode(node, depth, key);
} }
}); });
return result; return result;
...@@ -441,7 +436,6 @@ class PTree { ...@@ -441,7 +436,6 @@ class PTree {
} }
} }
PROFILE_PRINT
/** /**
* Perform a scan over all key-value pairs stored in the tree. * Perform a scan over all key-value pairs stored in the tree.
...@@ -788,7 +782,6 @@ class PTree { ...@@ -788,7 +782,6 @@ class PTree {
const unsigned int num = node->numKeys.get_ro(); const unsigned int num = node->numKeys.get_ro();
for (; pos < num && node->keys.get_ro()[pos] < key; pos++) { for (; pos < num && node->keys.get_ro()[pos] < key; pos++) {
}; };
return pos; return pos;
} }
...@@ -812,7 +805,6 @@ class PTree { ...@@ -812,7 +805,6 @@ class PTree {
unsigned int pos = 0; unsigned int pos = 0;
const unsigned int num = node->numKeys; const unsigned int num = node->numKeys;
for (; pos < num && node->keys[pos] <= key; pos++) { for (; pos < num && node->keys[pos] <= key; pos++) {
}; };
return pos; return pos;
} }
...@@ -836,7 +828,6 @@ class PTree { ...@@ -836,7 +828,6 @@ class PTree {
unsigned int pos = 0; unsigned int pos = 0;
const unsigned int num = node->numKeys; const unsigned int num = node->numKeys;
for (; pos < num && node->keys[pos] <= key; pos++) { for (; pos < num && node->keys[pos] <= key; pos++) {
}; };
return pos; return pos;
} }
...@@ -1612,7 +1603,6 @@ class PTree { ...@@ -1612,7 +1603,6 @@ class PTree {
auto child = node->children[k].lowestbranch; auto child = node->children[k].lowestbranch;
if (child != nullptr) printLowestBranchNode(d + 1, child); if (child != nullptr) printLowestBranchNode(d + 1, child);
} }
} }
} }
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2017-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
*
* This file is part of our NVM-based Data Structures 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/>.
*/
#ifndef DBIS_IDXPROFILE_HPP
#define DBIS_IDXPROFILE_HPP
#include <iostream>
namespace dbis {
class IdxProfile {
int read_count;
int write_count;
int split_count;
int underflow_count;
public:
IdxProfile() {
read_count = 0;
write_count = 0;
split_count = 0;
underflow_count = 0;
}
void read() { read_count++; }
void read(int x) { read_count+=x; }
void write() { write_count++; }
void write(int x) { write_count+=x; }
void split() { split_count++; }
void underflow() { underflow_count++; }
void diff(IdxProfile prof) {
this->read_count -= prof.read_count;
this->write_count -= prof.write_count;
this->split_count -= prof.split_count;
this->underflow_count -= prof.underflow_count;
}
void print() {
std::cout << "\nIndex Profile" << std::endl;
std::cout << "\tReads:\t" << read_count << std::endl;
std::cout << "\tWrites:\t" << write_count << std::endl;
std::cout << "\tSplits:\t" << split_count << std::endl;
std::cout << "\tUnderflows:\t" << underflow_count << std::endl;
}
};//end class
} /* end namespace dbis */
#endif /* DBIS_IDXPROFILE_HPP */
...@@ -208,8 +208,6 @@ class wBPTree { ...@@ -208,8 +208,6 @@ class wBPTree {
p<unsigned int> depth; //< the depth of the tree, i.e. the number of levels (0 => rootNode is LeafNode) p<unsigned int> depth; //< the depth of the tree, i.e. the number of levels (0 => rootNode is LeafNode)
LeafOrBranchNode rootNode; //< pointer to the root node LeafOrBranchNode rootNode; //< pointer to the root node
PROFILE_DECL
public: public:
/** /**
* Typedef for a function passed to the scan method. * Typedef for a function passed to the scan method.
...@@ -271,7 +269,6 @@ class wBPTree { ...@@ -271,7 +269,6 @@ class wBPTree {
*/ */
wBPTree() : depth(0) { wBPTree() : depth(0) {
rootNode = newLeafNode(); rootNode = newLeafNode();
PROFILE_INIT
LOG("created new wBPTree with sizeof(BranchNode) = " << sizeof(BranchNode) LOG("created new wBPTree with sizeof(BranchNode) = " << sizeof(BranchNode)
<< ", sizeof(LeafNode) = " << sizeof(LeafNode)); << ", sizeof(LeafNode) = " << sizeof(LeafNode));
} }
...@@ -379,8 +376,6 @@ class wBPTree { ...@@ -379,8 +376,6 @@ class wBPTree {
} }
} }
PROFILE_PRINT
/** /**
* Perform a scan over all key-value pairs stored in the tree. * Perform a scan over all key-value pairs stored in the tree.
* For each entry the given function @func is called. * For each entry the given function @func is called.
...@@ -480,7 +475,6 @@ class wBPTree { ...@@ -480,7 +475,6 @@ class wBPTree {
return split; return split;
} }
void splitLeafNode(persistent_ptr<LeafNode> node, SplitInfo *splitInfo) { void splitLeafNode(persistent_ptr<LeafNode> node, SplitInfo *splitInfo) {
auto &nodeRef = *node; auto &nodeRef = *node;
const auto &slotArray = nodeRef.search.get_ro().slot; const auto &slotArray = nodeRef.search.get_ro().slot;
......
...@@ -219,8 +219,6 @@ class wHBPTree { ...@@ -219,8 +219,6 @@ class wHBPTree {
Node rootNode; //< pointer to the root node Node rootNode; //< pointer to the root node
persistent_ptr<LeafNode> leafList; //< pointer to the most left leaf node. Necessary for recovery persistent_ptr<LeafNode> leafList; //< pointer to the most left leaf node. Necessary for recovery
PROFILE_DECL
public: public:
/** /**
* Typedef for a function passed to the scan method. * Typedef for a function passed to the scan method.
...@@ -283,7 +281,6 @@ class wHBPTree { ...@@ -283,7 +281,6 @@ class wHBPTree {
wHBPTree() : depth(0) { wHBPTree() : depth(0) {
rootNode = newLeafNode(); rootNode = newLeafNode();
leafList = rootNode.leaf; leafList = rootNode.leaf;
PROFILE_INIT
LOG("created new wHBPTree with sizeof(BranchNode) = " << sizeof(BranchNode) LOG("created new wHBPTree with sizeof(BranchNode) = " << sizeof(BranchNode)
<< ", sizeof(LeafNode) = " << sizeof(LeafNode)); << ", sizeof(LeafNode) = " << sizeof(LeafNode));
} }
...@@ -428,8 +425,6 @@ class wHBPTree { ...@@ -428,8 +425,6 @@ class wHBPTree {
} }
} }
PROFILE_PRINT
/** /**
* Perform a scan over all key-value pairs stored in the tree. * Perform a scan over all key-value pairs stored in the tree.
* For each entry the given function @func is called. * For each entry the given function @func is called.
...@@ -1283,7 +1278,6 @@ class wHBPTree { ...@@ -1283,7 +1278,6 @@ class wHBPTree {
} }
/** /**
* Print the given leaf node @c node to standard output. * Print the given leaf node @c node to standard output.
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment