Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
add_executable(main main.cpp)
add_executable(run run.cpp)
add_executable(insert_profiling insert_profiling.cpp)
179 changes: 132 additions & 47 deletions run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "ART.h"
#include "ArtNode.h"
#include "ArtNodeNewMethods.cpp"
// #include "ArtNodeNewMethods.cpp"
#include "Chain.h"
#include "Helper.h"
#include "trees/QuART_lil.h"
Expand All @@ -27,7 +27,7 @@ std::vector<key_type> read_bin(const char* filename) {

int main(int argc, char** argv) {
bool verbose = false; // optional argument
int N = 5000000; // optional argument
int N = 500000000; // optional argument
string input_file; // required argument
string tree_type = "ART"; // default tree type

Expand All @@ -53,59 +53,144 @@ int main(int argc, char** argv) {
// read data
auto keys = read_bin<uint32_t>(input_file.c_str());

// Build tree
ART::ART* tree = nullptr;
if (tree_type == "ART") {
tree = new ART::ART();
ART::ART* tree = new ART::ART();
long long insertion_time = 0;
for (uint64_t i = 0; i < N; i++) {
uint8_t key[4];
ART::loadKey(keys[i], key);
auto start = chrono::high_resolution_clock::now();
tree->insert(key, keys[i]);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
insertion_time += duration.count();
}

if (verbose) {
cout << "Tree type: " << tree_type << endl;
cout << "Insertion time: " << insertion_time << " ns" << endl;
}

// Query 1% of entries
uint64_t minval = 1;
uint64_t maxval = N;
srand(time(0));

long long query_time = 0;
for (uint64_t i = 0; i < (N / 100); i++) {
int random = rand() % (maxval - minval + 1) + minval;
uint8_t key[4];
ART::loadKey(keys[random], key);
auto start = chrono::high_resolution_clock::now();
ART::ArtNode* leaf = tree->lookup(key);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
query_time += duration.count();
assert(ART::isLeaf(leaf) &&
ART::getLeafValue(leaf) == keys[random]);
}

if (verbose) {
cout << "Query time: " << query_time << " ns" << endl;
}

// Output the times in csv format, including tree type
cout << insertion_time << "," << query_time << endl;
} else if (tree_type == "QuART_tail") {
tree = new ART::QuART_tail();
} else if (tree_type == "QuArt_lil") {
tree = new ART::QuART_lil();
} else {
cerr << "Unknown tree type: " << tree_type << endl;
return 1;
}
ART::QuART_tail* tree = new ART::QuART_tail();
long long insertion_time = 0;
for (uint64_t i = 0; i < N; i++) {
uint8_t key[4];
ART::loadKey(keys[i], key);
auto start = chrono::high_resolution_clock::now();
tree->insert(key, keys[i]);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
insertion_time += duration.count();
}

if (verbose) {
cout << "Tree type: " << tree_type << endl;
}
if (verbose) {
cout << "Tree type: " << tree_type << endl;
cout << "Insertion time: " << insertion_time << " ns" << endl;
}

long long insertion_time = 0;
for (uint64_t i = 0; i < N; i++) {
uint8_t key[4];
ART::loadKey(keys[i], key);
auto start = chrono::high_resolution_clock::now();
tree->insert(key, keys[i]);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
insertion_time += duration.count();
}
// Query 1% of entries
uint64_t minval = 1;
uint64_t maxval = N;
srand(time(0));

if (verbose) {
cout << "Insertion time: " << insertion_time << " ns" << endl;
}
long long query_time = 0;
for (uint64_t i = 0; i < (N / 100); i++) {
int random = rand() % (maxval - minval + 1) + minval;
uint8_t key[4];
ART::loadKey(keys[random], key);
auto start = chrono::high_resolution_clock::now();
ART::ArtNode* leaf = tree->lookup(key);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
query_time += duration.count();
assert(ART::isLeaf(leaf) &&
ART::getLeafValue(leaf) == keys[random]);
}

// Query tree
long long query_time = 0;
for (uint64_t i = 0; i < N; i++) {
uint8_t key[4];
ART::loadKey(keys[i], key);
auto start = chrono::high_resolution_clock::now();
ART::ArtNode* leaf = tree->lookup(key);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
query_time += duration.count();
assert(ART::isLeaf(leaf) && ART::getLeafValue(leaf) == keys[i]);
}
if (verbose) {
cout << "Query time: " << query_time << " ns" << endl;
}

if (verbose) {
cout << "Query time: " << query_time << " ns" << endl;
}
// Output the times in csv format, including tree type
cout << insertion_time << "," << query_time << endl;
} else if (tree_type == "QuART_lil") {
ART::QuART_lil* tree = new ART::QuART_lil();
long long insertion_time = 0;
for (uint64_t i = 0; i < N; i++) {
uint8_t key[4];
ART::loadKey(keys[i], key);
auto start = chrono::high_resolution_clock::now();
tree->insert(key, keys[i]);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
insertion_time += duration.count();
}

if (verbose) {
cout << "Tree type: " << tree_type << endl;
cout << "Insertion time: " << insertion_time << " ns" << endl;
}

// Output the times in csv format, including tree type
cout << insertion_time << "," << query_time << endl;
// Query 1% of entries
uint64_t minval = 1;
uint64_t maxval = N;
srand(time(0));

long long query_time = 0;
for (uint64_t i = 0; i < (N / 100); i++) {
int random = rand() % (maxval - minval + 1) + minval;
uint8_t key[4];
ART::loadKey(keys[random], key);
auto start = chrono::high_resolution_clock::now();
ART::ArtNode* leaf = tree->lookup(key);
auto stop = chrono::high_resolution_clock::now();
auto duration =
chrono::duration_cast<chrono::nanoseconds>(stop - start);
query_time += duration.count();
assert(ART::isLeaf(leaf) &&
ART::getLeafValue(leaf) == keys[random]);
}

if (verbose) {
cout << "Query time: " << query_time << " ns" << endl;
}

// Output the times in csv format, including tree type
cout << insertion_time << "," << query_time << endl;
} else {
cerr << "Unknown tree type: " << tree_type << endl;
return 1;
}
return 0;
}
22 changes: 22 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# filepath: /projectnb/manoslab/cgokmen/Qu-ART/test.sh

SUFFIX=$(date +"%Y%m%d_%H%M%S")
RESULTSDIR="results"
mkdir -p "$RESULTSDIR"
RESULTS="${RESULTSDIR}/results_run_${SUFFIX}.txt"

echo "input_file,N,result" > "$RESULTS"

for FILE in ../bods/all_workloads/workload_N*_K*_L*.bin; do
[ -f "$FILE" ] || continue

BASENAME=$(basename "$FILE")
N=$(echo "$BASENAME" | sed -n 's/.*_N\([0-9]*\)_K[0-9]*_L[0-9]*.bin/\1/p')

OUTPUT=$(./build/run -t QuART_stail -f "$FILE" -N "$N" )
# Write all output to results file, one block per workload
echo "==== $FILE ====" >> "$RESULTS"
echo "$OUTPUT" >> "$RESULTS"
echo "" >> "$RESULTS"
done
Loading