From 481df63c0152e1b643ec0bd16500c4aca0716404 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Thu, 14 Mar 2024 14:47:23 -0400 Subject: Benchmarking tweaks --- benchmarks/insert_query_tput.cpp | 59 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'benchmarks/insert_query_tput.cpp') diff --git a/benchmarks/insert_query_tput.cpp b/benchmarks/insert_query_tput.cpp index ce05264..29043af 100644 --- a/benchmarks/insert_query_tput.cpp +++ b/benchmarks/insert_query_tput.cpp @@ -10,7 +10,8 @@ #include "shard/ISAMTree.h" #include "query/irs.h" #include "framework/interface/Record.h" -#include "include/data-proc.h" +#include "include/file_util.h" +#include #include @@ -25,6 +26,8 @@ typedef de::irs::Parms QP; std::atomic inserts_done = false; +struct timespec delay = {0, 500}; + void query_thread(Ext *extension, std::vector *queries) { gsl_rng *rng = gsl_rng_alloc(gsl_rng_mt19937); size_t total = 0; @@ -39,7 +42,7 @@ void query_thread(Ext *extension, std::vector *queries) { auto res = extension->query(&q); auto r = res.get(); total += r.size(); - usleep(1); + nanosleep(&delay, nullptr); } fprintf(stderr, "%ld\n", total); @@ -47,47 +50,39 @@ void query_thread(Ext *extension, std::vector *queries) { gsl_rng_free(rng); } -void insert_thread(Ext *extension, size_t start, std::vector *records) { - size_t reccnt = 0; - Rec r; - for (size_t i=start; isize(); i++) { - r.key = (*records)[i]; - r.value = i; - - while (!extension->insert(r)) { - usleep(1); +void insert_thread(Ext *extension, size_t start, size_t stop, std::vector *records) { + fprintf(stderr, "%ld\t%ld\n", start, stop); + for (size_t i=start; iinsert((*records)[i])) { + nanosleep(&delay, nullptr); } } - - inserts_done.store(true); } int main(int argc, char **argv) { - if (argc < 5) { - fprintf(stderr, "insert_query_tput reccnt query_threads datafile queryfile\n"); + if (argc < 6) { + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "%s reccnt insert_threads query_threads datafile queryfile\n", argv[0]); exit(EXIT_FAILURE); } size_t n = atol(argv[1]); - size_t qthread_cnt = atol(argv[2]); - std::string d_fname = std::string(argv[3]); - std::string q_fname = std::string(argv[4]); + size_t ithread_cnt = atol(argv[2]); + size_t qthread_cnt = atol(argv[3]); + std::string d_fname = std::string(argv[4]); + std::string q_fname = std::string(argv[5]); auto extension = new Ext(1000, 12000, 8, 0, 64); gsl_rng * rng = gsl_rng_alloc(gsl_rng_mt19937); - auto data = read_sosd_file(d_fname, n); + auto data = read_sosd_file(d_fname, n); auto queries = read_range_queries(q_fname, .001); /* warmup structure w/ 10% of records */ size_t warmup = .1 * n; - Rec r; for (size_t i=0; iinsert(r)) { + while (!extension->insert(data[i])) { usleep(1); } } @@ -96,14 +91,26 @@ int main(int argc, char **argv) { TIMER_INIT(); + std::vector ithreads(ithread_cnt); std::vector qthreads(qthread_cnt); TIMER_START(); - std::thread i_thrd(insert_thread, extension, warmup, &data); + size_t start = warmup; + size_t per_thread = (n - warmup) / ithread_cnt; + for (size_t i=0; i Date: Tue, 14 May 2024 16:18:16 -0400 Subject: Moved thread scalability bench to vldb folder --- benchmarks/insert_query_tput.cpp | 128 --------------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 benchmarks/insert_query_tput.cpp (limited to 'benchmarks/insert_query_tput.cpp') diff --git a/benchmarks/insert_query_tput.cpp b/benchmarks/insert_query_tput.cpp deleted file mode 100644 index 29043af..0000000 --- a/benchmarks/insert_query_tput.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * - */ - -#define ENABLE_TIMER - -#include - -#include "framework/DynamicExtension.h" -#include "shard/ISAMTree.h" -#include "query/irs.h" -#include "framework/interface/Record.h" -#include "include/file_util.h" -#include - -#include - -#include "psu-util/timer.h" - - -typedef de::Record Rec; -typedef de::ISAMTree ISAM; -typedef de::irs::Query Q; -typedef de::DynamicExtension Ext; -typedef de::irs::Parms QP; - -std::atomic inserts_done = false; - -struct timespec delay = {0, 500}; - -void query_thread(Ext *extension, std::vector *queries) { - gsl_rng *rng = gsl_rng_alloc(gsl_rng_mt19937); - size_t total = 0; - - while (!inserts_done.load()) { - auto q_idx = gsl_rng_uniform_int(rng, queries->size()); - - auto q = (*queries)[q_idx]; - q.rng = rng; - q.sample_size = 1000; - - auto res = extension->query(&q); - auto r = res.get(); - total += r.size(); - nanosleep(&delay, nullptr); - } - - fprintf(stderr, "%ld\n", total); - - gsl_rng_free(rng); -} - -void insert_thread(Ext *extension, size_t start, size_t stop, std::vector *records) { - fprintf(stderr, "%ld\t%ld\n", start, stop); - for (size_t i=start; iinsert((*records)[i])) { - nanosleep(&delay, nullptr); - } - } -} - -int main(int argc, char **argv) { - - if (argc < 6) { - fprintf(stderr, "Usage:\n"); - fprintf(stderr, "%s reccnt insert_threads query_threads datafile queryfile\n", argv[0]); - exit(EXIT_FAILURE); - } - - size_t n = atol(argv[1]); - size_t ithread_cnt = atol(argv[2]); - size_t qthread_cnt = atol(argv[3]); - std::string d_fname = std::string(argv[4]); - std::string q_fname = std::string(argv[5]); - - auto extension = new Ext(1000, 12000, 8, 0, 64); - gsl_rng * rng = gsl_rng_alloc(gsl_rng_mt19937); - - auto data = read_sosd_file(d_fname, n); - auto queries = read_range_queries(q_fname, .001); - - /* warmup structure w/ 10% of records */ - size_t warmup = .1 * n; - for (size_t i=0; iinsert(data[i])) { - usleep(1); - } - } - - extension->await_next_epoch(); - - TIMER_INIT(); - - std::vector ithreads(ithread_cnt); - std::vector qthreads(qthread_cnt); - - TIMER_START(); - size_t start = warmup; - size_t per_thread = (n - warmup) / ithread_cnt; - for (size_t i=0; i