diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2025-01-21 13:11:12 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2025-02-17 09:09:43 -0500 |
| commit | 4e088dd606cc60f0e6585f1a1512a65a8a549876 (patch) | |
| tree | 7ac1dfce4db0fd40b6468addc9dd9ffe327122a6 | |
| parent | 78ecacfa46f6418fca7562cda8e79c766ddf7191 (diff) | |
| download | dynamic-extension-4e088dd606cc60f0e6585f1a1512a65a8a549876.tar.gz | |
BTree insertion latency benchmarks
| -rw-r--r-- | CMakeLists.txt | 5 | ||||
| -rw-r--r-- | benchmarks/tail-latency/btree_insert_dist.cpp | 77 |
2 files changed, 82 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f0d8a86..4723da4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,6 +301,11 @@ if (tail_bench) target_link_libraries(standard_latency_dist PUBLIC gsl pthread atomic) target_include_directories(standard_latency_dist PRIVATE include external external/m-tree/cpp external/PGM-index/include external/PLEX/include benchmarks/include external/psudb-common/cpp/include) target_link_options(standard_latency_dist PUBLIC -mcx16) + + add_executable(btree_insert_dist ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/tail-latency/btree_insert_dist.cpp) + target_link_libraries(btree_insert_dist PUBLIC gsl pthread atomic) + target_include_directories(btree_insert_dist PRIVATE include external external/m-tree/cpp external/PGM-index/include external/PLEX/include benchmarks/include external/psudb-common/cpp/include) + target_link_options(btree_insert_dist PUBLIC -mcx16) endif() if (bench) diff --git a/benchmarks/tail-latency/btree_insert_dist.cpp b/benchmarks/tail-latency/btree_insert_dist.cpp new file mode 100644 index 0000000..af60819 --- /dev/null +++ b/benchmarks/tail-latency/btree_insert_dist.cpp @@ -0,0 +1,77 @@ +/* + * + */ + +#define ENABLE_TIMER + +#include "shard/ISAMTree.h" +#include "query/rangequery.h" +#include "framework/interface/Record.h" +#include "file_util.h" +#include "benchmark_types.h" + +#include <gsl/gsl_rng.h> + +#include "psu-util/timer.h" +#include "standard_benchmarks.h" +#include "psu-ds/BTree.h" + +typedef btree_record<int64_t, int64_t> Rec; + +typedef de::ISAMTree<Rec> Shard; +typedef de::irs::Query<Shard> Q; +typedef Q::Parameters QP; + +void usage(char *progname) { + fprintf(stderr, "%s reccnt datafile queryfile\n", progname); +} + +int main(int argc, char **argv) { + + if (argc < 4) { + usage(argv[0]); + exit(EXIT_FAILURE); + } + + size_t n = atol(argv[1]); + std::string d_fname = std::string(argv[2]); + std::string q_fname = std::string(argv[3]); + + auto btree = BenchBTree(); + + auto data = read_sosd_file<Rec>(d_fname, n); + + /* read in the range queries and add sample size and rng for sampling */ + auto queries = read_range_queries<QP>(q_fname, .0001); + + /* warmup structure w/ 10% of records */ + size_t warmup = .1 * n; + for (size_t i=0; i<warmup; i++) { + btree.insert(data[i]); + } + + TIMER_INIT(); + /* insertion benchmark */ + for (size_t i=warmup; i<data.size(); i++) { + TIMER_START(); + btree.insert(data[i]); + TIMER_STOP(); + + fprintf(stdout, "I\t%ld\n", TIMER_RESULT()); + } + + /* run queries */ + size_t total = 0; + for (size_t j=0; j<10; j++) { + for (size_t i=0; i<queries.size(); i++) { + TIMER_START(); + total += btree.range_count(queries[i].lower_bound, queries[i].upper_bound); + TIMER_STOP(); + + fprintf(stdout, "Q\t%ld\n", TIMER_RESULT()); + } + } + + fprintf(stderr, "%ld\n", total); +} + |