From 0a9e79416df03a9e0a3d2cf171cf90028a644d6d Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Mon, 15 Jan 2024 17:21:11 -0500 Subject: Benchmarking programs --- benchmarks/reconstruction_interference.cpp | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 benchmarks/reconstruction_interference.cpp (limited to 'benchmarks/reconstruction_interference.cpp') diff --git a/benchmarks/reconstruction_interference.cpp b/benchmarks/reconstruction_interference.cpp new file mode 100644 index 0000000..a843c71 --- /dev/null +++ b/benchmarks/reconstruction_interference.cpp @@ -0,0 +1,110 @@ +/* + * + */ + +#define ENABLE_TIMER + +#include + +#include "framework/DynamicExtension.h" +#include "shard/ISAMTree.h" +#include "query/rangequery.h" +#include "framework/interface/Record.h" + +#include "psu-util/timer.h" + + +typedef de::Record Rec; +typedef de::ISAMTree ISAM; +typedef de::rq::Query Q; +typedef de::DynamicExtension Ext; + +void query_thread(Ext *extension, double selectivity, size_t k) { + TIMER_INIT(); + + size_t reccnt = extension->get_record_count(); + size_t range = reccnt * selectivity; + + auto q = new de::rq::Parms(); + + TIMER_START(); + for (int64_t i=0; ilower_bound = start; + q->upper_bound = start + range; + auto res = extension->query(q); + auto r = res.get(); + } + TIMER_STOP(); + auto query_lat = TIMER_RESULT(); + fprintf(stdout, "Q\t%ld\t%ld\t%ld\n", reccnt, query_lat, k); + delete q; +} + +Ext *build_structure(size_t n) { + auto extension = new Ext(1000, 10000, 2); + + size_t i=0; + Rec r; + do { + r.key = rand() % n; + r.value = i; + if (extension->insert(r)) { + i++; + } else { + _mm_pause(); + } + } while (i < n); + + extension->await_next_epoch(); + return extension; +} + +void query_benchmark(double selectivity, size_t k, Ext *extension) { + TIMER_INIT(); + + size_t query_thrd_cnt = 4; + std::vector thrds(query_thrd_cnt); + + TIMER_START(); + for (size_t i=0; iget_record_count(), query_lat, k, query_thrd_cnt); +} + +int main(int argc, char **argv) { + + /* the closeout routine takes _forever_ ... so we'll just leak the memory */ + size_t n = 10000000; + + size_t per_trial = 1000; + double selectivity = .001; + + /* build initial structure */ + auto extension = build_structure(n); + + /* benchmark queries w/o any interference from reconstructions */ + query_benchmark(selectivity, per_trial, extension); + + fprintf(stderr, "Running interference test...\n"); + + /* trigger a worst-case reconstruction and benchmark the queries */ + std::thread q_thrd(query_benchmark, selectivity, per_trial, extension); + auto s = extension->create_static_structure(); + fprintf(stderr, "Construction complete\n"); + q_thrd.join(); + + delete extension; + delete s; + + fflush(stderr); +} + -- cgit v1.2.3