summaryrefslogtreecommitdiffstats
path: root/database/engine/rrdengine.h
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-12-03 12:06:49 +0200
committerGitHub <noreply@github.com>2020-12-03 12:06:49 +0200
commitd1a3c48ce522b0477655491d184be981b39e567c (patch)
tree2c2411739ec72c2f0df8c2255ef474d1670d4867 /database/engine/rrdengine.h
parent551fc3237a665f47e83058aa307b672f3221f2e1 (diff)
dbengine extent cache (#10293)
* Add initial extent cache implementation * Integrate extent cache with dbengine.
Diffstat (limited to 'database/engine/rrdengine.h')
-rw-r--r--database/engine/rrdengine.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/database/engine/rrdengine.h b/database/engine/rrdengine.h
index eb13d8474e..87af04bff9 100644
--- a/database/engine/rrdengine.h
+++ b/database/engine/rrdengine.h
@@ -88,6 +88,7 @@ struct extent_io_descriptor {
int release_descr;
struct rrdeng_page_descr *descr_array[MAX_PAGES_PER_EXTENT];
Word_t descr_commit_idx_array[MAX_PAGES_PER_EXTENT];
+ struct extent_io_descriptor *next; /* multiple requests to be served by the same cached extent */
};
struct generic_io_descriptor {
@@ -99,6 +100,27 @@ struct generic_io_descriptor {
struct completion *completion;
};
+struct extent_cache_element {
+ struct extent_info *extent; /* The ABA problem is avoided with the help of fileno below */
+ unsigned fileno;
+ struct extent_cache_element *prev; /* LRU */
+ struct extent_cache_element *next; /* LRU */
+ struct extent_io_descriptor *inflight_io_descr; /* I/O descriptor for in-flight extent */
+ uint8_t pages[MAX_PAGES_PER_EXTENT * RRDENG_BLOCK_SIZE];
+};
+
+#define MAX_CACHED_EXTENTS 16 /* cannot be over 32 to fit in 32-bit architectures */
+
+/* Initialize by setting the structure to zero */
+struct extent_cache {
+ struct extent_cache_element extent_array[MAX_CACHED_EXTENTS];
+ unsigned allocation_bitmap; /* 1 if the corresponding position in the extent_array is allocated */
+ unsigned inflight_bitmap; /* 1 if the corresponding position in the extent_array is waiting for I/O */
+
+ struct extent_cache_element *replaceQ_head; /* LRU */
+ struct extent_cache_element *replaceQ_tail; /* MRU */
+};
+
struct rrdengine_worker_config {
struct rrdengine_instance *ctx;
@@ -122,6 +144,8 @@ struct rrdengine_worker_config {
volatile unsigned queue_size;
struct rrdeng_cmdqueue cmd_queue;
+ struct extent_cache xt_cache;
+
int error;
};