diff options
Diffstat (limited to 'database/engine/rrdengine.h')
-rw-r--r-- | database/engine/rrdengine.h | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/database/engine/rrdengine.h b/database/engine/rrdengine.h index fedadbe861..3a23ed4118 100644 --- a/database/engine/rrdengine.h +++ b/database/engine/rrdengine.h @@ -92,12 +92,22 @@ struct rrdeng_cmd { union { struct rrdeng_read_page read_page; struct rrdeng_read_extent read_extent; + struct rrdengine_journalfile *journalfile; struct completion *completion; }; }; #define RRDENG_CMD_Q_MAX_SIZE (2048) +struct rrdeng_work { + uv_work_t req; + struct rrdengine_worker_config *wc; + void *data; + uint32_t count; + bool rerun; + struct completion *completion; +}; + struct rrdeng_cmdqueue { unsigned head, tail; struct rrdeng_cmd cmd_array[RRDENG_CMD_Q_MAX_SIZE]; @@ -117,6 +127,7 @@ struct extent_io_descriptor { unsigned descr_count; int release_descr; struct rrdeng_page_descr *descr_array[MAX_PAGES_PER_EXTENT]; + BITMAP256 descr_array_wakeup; 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 */ }; @@ -125,6 +136,7 @@ struct generic_io_descriptor { uv_fs_t req; uv_buf_t iov; void *buf; + void *data; uint64_t pos; unsigned bytes; struct completion *completion; @@ -133,8 +145,8 @@ struct generic_io_descriptor { 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_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]; }; @@ -145,7 +157,7 @@ struct extent_cache_element { 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 */ + 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 */ @@ -155,18 +167,23 @@ struct rrdengine_worker_config { struct rrdengine_instance *ctx; uv_thread_t thread; - uv_loop_t* loop; + uv_loop_t *loop; uv_async_t async; /* file deletion thread */ uv_thread_t *now_deleting_files; + uv_thread_t *now_deleting_descriptors; unsigned long cleanup_thread_deleting_files; /* set to 0 when now_deleting_files is still running */ + unsigned long cleanup_deleting_descriptors; /* set to 0 when now_deleting_descriptors is still running */ + + unsigned long running_journal_migration; /* dirty page deletion thread */ uv_thread_t *now_invalidating_dirty_pages; /* set to 0 when now_invalidating_dirty_pages is still running */ unsigned long cleanup_thread_invalidating_dirty_pages; unsigned inflight_dirty_pages; + bool run_indexing; /* FIFO command queue */ uv_mutex_t cmd_mutex; @@ -225,9 +242,9 @@ extern rrdeng_stats_t rrdeng_reserved_file_descriptors; extern rrdeng_stats_t global_pg_cache_over_half_dirty_events; extern rrdeng_stats_t global_flushing_pressure_page_deletions; /* number of deleted pages */ -#define NO_QUIESCE (0) /* initial state when all operations function normally */ +#define NO_QUIESCE (0) /* initial state when all operations function normally */ #define SET_QUIESCE (1) /* set it before shutting down the instance, quiesce long running operations */ -#define QUIESCED (2) /* is set after all threads have finished running */ +#define QUIESCED (2) /* is set after all threads have finished running */ typedef enum { LOAD_ERRORS_PAGE_FLIPPED_TIME = 0, @@ -255,9 +272,10 @@ struct rrdengine_instance { unsigned last_fileno; /* newest index of datafile and journalfile */ unsigned long max_cache_pages; unsigned long cache_pages_low_watermark; + unsigned long cache_pages_warn_watermark; unsigned long metric_API_max_producers; - uint8_t quiesce; /* set to SET_QUIESCE before shutdown of the engine */ + uint8_t quiesce; /* set to SET_QUIESCE before shutdown of the engine */ uint8_t page_type; /* Default page type for this context */ struct rrdengine_statistics stats; @@ -273,9 +291,12 @@ void dbengine_page_free(void *page); int init_rrd_files(struct rrdengine_instance *ctx); void finalize_rrd_files(struct rrdengine_instance *ctx); -void rrdeng_test_quota(struct rrdengine_worker_config* wc); -void rrdeng_worker(void* arg); -void rrdeng_enq_cmd(struct rrdengine_worker_config* wc, struct rrdeng_cmd *cmd); -struct rrdeng_cmd rrdeng_deq_cmd(struct rrdengine_worker_config* wc); - +void rrdeng_test_quota(struct rrdengine_worker_config *wc); +void rrdeng_worker(void *arg); +void rrdeng_enq_cmd(struct rrdengine_worker_config *wc, struct rrdeng_cmd *cmd); +struct rrdeng_cmd rrdeng_deq_cmd(struct rrdengine_worker_config *wc); +void after_journal_indexing(uv_work_t *req, int status); +void start_journal_indexing(uv_work_t *req); +struct pg_cache_page_index *get_page_index(struct page_cache *pg_cache, uuid_t *uuid); +struct rrdeng_page_descr *get_descriptor(struct pg_cache_page_index *page_index, time_t start_time_s); #endif /* NETDATA_RRDENGINE_H */ |