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

👌 Small adaptions to PTable (benchmark)

parent f7290b4c
......@@ -20,6 +20,7 @@
#include <chrono>
#include <unistd.h>
#include <experimental/filesystem>
#include "PTable.hpp"
using pmem::obj::make_persistent;
......@@ -44,7 +45,7 @@ struct root {
};
const std::string path = dbis::gPmemPath + "benchdb.db";
const auto NUM_TUPLES = 1000 * 100;
const auto NUM_TUPLES = 1000 * 10;
const auto POOL_SIZE = 1024 * 1024 * 256; // * 4ull; // 1GB
const auto ALIGNMENT = hibit_pos(NUM_TUPLES) + 1;
......
......@@ -15,8 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include "fmt/format.h"
#include <experimental/filesystem>
#include "common.hpp"
using namespace dbis::ptable;
......@@ -24,7 +23,7 @@ using namespace dbis::ptable;
int main() {
pool<root> pop;
std::remove(path.c_str());
std::experimental::filesystem::remove_all(path);
if (access(path.c_str(), F_OK) != 0) {
insert(pop, path, NUM_TUPLES);
} else {
......
......@@ -38,15 +38,17 @@ static void BM_PointQuery(benchmark::State& state) {
pop = pool<root>::open(path, LAYOUT);
}
auto pTable = pop.root()->pTable;
auto &pTable = *pop.root()->pTable;
for (auto _ : state) {
auto ptp = pTable->getByKey(state.range(1));
auto ptp = pTable.getByKey(state.range(1));
if (ptp.getNode() != nullptr) ptp;// ptp.createTuple();
else std::cerr << "key not found" << '\n';
}
transaction::run(pop, [&] { delete_persistent<PTableType>(pop.root()->pTable); });
pop.close();
std::remove(path.c_str());
std::experimental::filesystem::remove_all(path);
}
static void VectorArguments(benchmark::internal::Benchmark* b) {
for (const auto &arg : POINT_ACCESS) b->Args(arg);
......
......@@ -96,7 +96,6 @@ static void BM_PBPTreeKeyScan(benchmark::State &state) {
}
pop.close();
//std::remove(path.c_str());
}
BENCHMARK(BM_PBPTreeKeyScan)->Apply(KeyRangeArguments);
......@@ -111,12 +110,12 @@ static void BM_PBPTreeScan(benchmark::State &state) {
pop = pool<root>::open(path, LAYOUT);
}
auto pTable = pop.root()->pTable;
auto &pTable = *pop.root()->pTable;
for (auto _ : state) {
/* Scan via PTuple iterator */
auto eIter = pTable->end();
auto iter = pTable->select(
auto eIter = pTable.end();
auto iter = pTable.select(
[&](const PTuple<int, MyTuple> &tp) {
return (tp.get<0>() >= state.range(0)) && (tp.get<0>() <= state.range(1)) &&
(tp.get<3>() >= state.range(2)) && (tp.get<3>() <= state.range(3));
......@@ -127,8 +126,9 @@ static void BM_PBPTreeScan(benchmark::State &state) {
}
}
transaction::run(pop, [&] { delete_persistent<PTableType>(pop.root()->pTable); });
pop.close();
//std::remove(path.c_str());
std::experimental::filesystem::remove_all(path);
}
BENCHMARK(BM_PBPTreeScan)->Apply(NonKeyRangeArguments);
......
......@@ -33,9 +33,9 @@
namespace dbis::ptable {
const std::string LAYOUT = "PTable";
constexpr auto LAYOUT = "PTable";
auto const TARGET_INDEX_NODE_SIZE = 1 * 1024; // 1KB
constexpr auto TARGET_INDEX_NODE_SIZE = 1 * 1024; // 1KB
/** Abort reason codes: */
const auto NOT_ENOUGH_SPACE = 1;
......@@ -57,9 +57,9 @@ class PTable;
template<typename KeyType, class... Types>
class PTable<KeyType, std::tuple<Types...>> {
using Tuple = std::tuple<Types...>;
static const auto BRANCHKEYS = ((TARGET_INDEX_NODE_SIZE - 28) / (sizeof(KeyType) + 24)) & ~1;
static const auto LEAFKEYS = ((TARGET_INDEX_NODE_SIZE - 36) /
(sizeof(KeyType) + sizeof(PTuple<KeyType, Tuple>))) & ~1;
static constexpr auto BRANCHKEYS = ((TARGET_INDEX_NODE_SIZE - 28) / (sizeof(KeyType) + 24)) & ~1;
static constexpr auto LEAFKEYS = ((TARGET_INDEX_NODE_SIZE - 36) /
(sizeof(KeyType) + sizeof(PTuple<KeyType, Tuple>)));
using VTableInfoType = VTableInfo<KeyType, Tuple>;
using PTableInfoType = PTableInfo<KeyType, Tuple>;
......
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