summaryrefslogtreecommitdiffstats
path: root/include/framework/reconstruction/CompactOnFull.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2025-05-25 13:35:10 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2025-05-25 13:35:10 -0400
commit7f823ef35733230d3fd1e12e52fecde89f415e8b (patch)
treedded33d97e313b5bdb417e7b611c3dc03f7c8ac0 /include/framework/reconstruction/CompactOnFull.h
parentaa15300f8302bf713d752a775f32060b59b8746f (diff)
downloaddynamic-extension-7f823ef35733230d3fd1e12e52fecde89f415e8b.tar.gz
Updates for tail latency stall testing
Diffstat (limited to 'include/framework/reconstruction/CompactOnFull.h')
-rw-r--r--include/framework/reconstruction/CompactOnFull.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/include/framework/reconstruction/CompactOnFull.h b/include/framework/reconstruction/CompactOnFull.h
new file mode 100644
index 0000000..f5e0400
--- /dev/null
+++ b/include/framework/reconstruction/CompactOnFull.h
@@ -0,0 +1,82 @@
+/*
+ * include/framework/reconstruction/LevelingPolicy.h
+ *
+ * Copyright (C) 2023-2024 Douglas B. Rumbaugh <drumbaugh@psu.edu>
+ * Dong Xie <dongx@psu.edu>
+ *
+ * Distributed under the Modified BSD License.
+ *
+ */
+#pragma once
+#include <cmath>
+
+#include "framework/reconstruction/ReconstructionPolicy.h"
+#include "framework/scheduling/Version.h"
+#include "util/types.h"
+
+namespace de {
+template <ShardInterface ShardType, QueryInterface<ShardType> QueryType>
+class CompactOnFull : public ReconstructionPolicy<ShardType, QueryType> {
+ typedef std::vector<std::shared_ptr<InternalLevel<ShardType, QueryType>>>
+ LevelVector;
+
+public:
+ CompactOnFull(size_t scale_factor, size_t buffer_size, size_t size_modifier=0)
+ : m_scale_factor(scale_factor), m_buffer_size(buffer_size), m_size_modifier(size_modifier) {}
+
+ std::vector<ReconstructionVector> get_reconstruction_tasks(
+ const Version<ShardType, QueryType> *version, LockManager &lock_mngr) const override {
+ std::vector<ReconstructionVector> reconstructions;
+
+ auto levels = version->get_structure()->get_level_vector();
+
+ if (levels[0]->get_shard_count() == 0) {
+ return {};
+ }
+
+ for (level_index i=0; i < (ssize_t) levels.size(); i++) {
+ if (levels[i]->get_shard_count() >= m_scale_factor && lock_mngr.take_lock(i, version->get_id())) {
+ ReconstructionVector recon;
+ size_t total_reccnt = levels[i]->get_record_count();
+ std::vector<ShardID> shards;
+ for (ssize_t j=0; j<(ssize_t) levels[i]->get_shard_count(); j++) {
+ shards.push_back({i,j});
+ }
+
+ recon.add_reconstruction(shards, i+1, total_reccnt, ReconstructionType::Compact);
+ reconstructions.push_back(recon);
+ }
+ }
+
+ return reconstructions;
+ }
+
+
+ ReconstructionVector
+ get_flush_tasks(const Version<ShardType, QueryType> *version) const override {
+ ReconstructionVector reconstructions;
+
+ return reconstructions;
+ }
+
+private:
+ level_index find_reconstruction_target(LevelVector &levels, size_t reccnt) const {
+ level_index target_level = invalid_level_idx;
+
+ for (level_index i = 1; i < (level_index)levels.size(); i++) {
+ if (levels[i]->get_shard_count() + 1 <= capacity(reccnt)) {
+ target_level = i;
+ break;
+ }
+ }
+
+ return target_level;
+ }
+
+ inline size_t capacity(size_t reccnt) const { return m_scale_factor * std::pow(std::log(reccnt), m_size_modifier); }
+
+ size_t m_scale_factor;
+ size_t m_buffer_size;
+ size_t m_size_modifier;
+};
+} // namespace de