From 7e7fd9f7339eee2f1ae974c662a447532dfb1b1a Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Tue, 26 Mar 2024 16:35:12 -0400 Subject: Updated FSTrie benchmark and some minor fixes --- benchmarks/string_insertion_tput.cpp | 73 ++++++++++++++++++++++-------------- include/query/pointlookup.h | 4 +- include/shard/FSTrie.h | 2 +- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/benchmarks/string_insertion_tput.cpp b/benchmarks/string_insertion_tput.cpp index d205175..e41e996 100644 --- a/benchmarks/string_insertion_tput.cpp +++ b/benchmarks/string_insertion_tput.cpp @@ -9,7 +9,7 @@ #include "framework/DynamicExtension.h" #include "shard/FSTrie.h" -#include "query/rangequery.h" +#include "query/pointlookup.h" #include "framework/interface/Record.h" #include "psu-util/timer.h" @@ -18,8 +18,8 @@ typedef de::Record Rec; typedef de::FSTrie Trie; -typedef de::rq::Query Q; -typedef de::DynamicExtension Ext; //, de::LayoutPolicy::TEIRING, de::DeletePolicy::TAGGING, de::SerialScheduler> Ext; +typedef de::pl::Query Q; +typedef de::DynamicExtension Ext; std::vector strings; @@ -47,45 +47,62 @@ void read_data(std::string fname, size_t n=10000000) { } } +void usage(char *name) { + fprintf(stderr, "Usage:\n%s datafile record_count\n", name); +} + int main(int argc, char **argv) { - size_t n = 100000000; - std::vector counts = {1 , 2, 4, 8}; //, 16, 32, 64}; - // - read_data("benchmarks/data/ursa-genome.txt", n); + if (argc < 3) { + usage(argv[0]); + exit(EXIT_FAILURE); + } - fprintf(stderr, "Finished reading from file.\n"); + std::string fname = std::string(argv[1]); + size_t n = atol(argv[2]); - for (auto thread_count : counts) { + read_data(fname, n); - auto extension = new Ext(1000, 12000, 8); + if (strings.size() == 0) { + fprintf(stderr, "[E]: No string data read from file. Aborting execution.\n"); + } else { + fprintf(stderr, "Finished reading from file.\n"); + } - size_t per_thread = n / thread_count; + auto extension = new Ext(1000, 12000, 8); - std::thread threads[thread_count]; + TIMER_INIT(); + TIMER_START(); + insert_thread(0, strings.size(), extension); + TIMER_STOP(); - TIMER_INIT(); - TIMER_START(); - for (size_t i=0; i parms; + parms.search_key = strings[j]; - TIMER_STOP(); + auto res = extension->query(&parms); + auto ans = res.get(); - auto total_time = TIMER_RESULT(); + assert(ans[0].value == j); + } + TIMER_STOP(); - double tput = (double) n / (double) total_time * 1e9; + auto query_time = TIMER_RESULT(); - fprintf(stdout, "%ld\t%d\t%lf\n", extension->get_record_count(), - thread_count, tput); - delete extension; - } + double i_tput = (double) n / (double) total_time * 1e9; + size_t q_lat = total_time / m; + + fprintf(stdout, "%ld\t\t%lf\t%ld\n", extension->get_record_count(), + i_tput, q_lat); + + + delete extension; fflush(stderr); } diff --git a/include/query/pointlookup.h b/include/query/pointlookup.h index caaa320..35d38e3 100644 --- a/include/query/pointlookup.h +++ b/include/query/pointlookup.h @@ -97,10 +97,12 @@ public: return output; } - output.append(r[0].rec); + output.push_back(r[0].rec); return output; } } + + return output; } static void delete_query_state(void *state) { diff --git a/include/shard/FSTrie.h b/include/shard/FSTrie.h index 50bf982..95f396f 100644 --- a/include/shard/FSTrie.h +++ b/include/shard/FSTrie.h @@ -61,7 +61,7 @@ public: std::sort(base, stop, std::less>()); for (size_t i=0; i