summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStelios Fragkakis <52996999+stelfrag@users.noreply.github.com>2024-03-21 20:20:57 +0200
committerGitHub <noreply@github.com>2024-03-21 20:20:57 +0200
commit8a4c9df1cc907f3ceb90d1a7824890e657ed8f7c (patch)
tree293de7286d108a3af538ac9b40a8ddc4d9440d69 /src
parentf2f61041202e4b1ebe017622590a0d85a4024cd2 (diff)
Reduce flush operations during journal build (#17220)
after creating journal file v2, flush open cache only once Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
Diffstat (limited to 'src')
-rw-r--r--src/database/engine/cache.c18
-rw-r--r--src/database/engine/cache.h2
-rwxr-xr-xsrc/database/engine/rrdengineapi.c2
3 files changed, 11 insertions, 11 deletions
diff --git a/src/database/engine/cache.c b/src/database/engine/cache.c
index 53346c54ec..f82d94b3ad 100644
--- a/src/database/engine/cache.c
+++ b/src/database/engine/cache.c
@@ -1882,7 +1882,7 @@ void pgc_page_release(PGC *cache, PGC_PAGE *page) {
page_release(cache, page, is_page_clean(page));
}
-void pgc_page_hot_to_dirty_and_release(PGC *cache, PGC_PAGE *page) {
+void pgc_page_hot_to_dirty_and_release(PGC *cache, PGC_PAGE *page, bool never_flush) {
__atomic_add_fetch(&cache->stats.workers_hot2dirty, 1, __ATOMIC_RELAXED);
//#ifdef NETDATA_INTERNAL_CHECKS
@@ -1901,10 +1901,8 @@ void pgc_page_hot_to_dirty_and_release(PGC *cache, PGC_PAGE *page) {
__atomic_sub_fetch(&cache->stats.workers_hot2dirty, 1, __ATOMIC_RELAXED);
// flush, if we have to
- if((cache->config.options & PGC_OPTIONS_FLUSH_PAGES_INLINE) || flushing_critical(cache)) {
- flush_pages(cache, cache->config.max_flushes_inline, PGC_SECTION_ALL,
- false, false);
- }
+ if(!never_flush && ((cache->config.options & PGC_OPTIONS_FLUSH_PAGES_INLINE) || flushing_critical(cache)))
+ flush_pages(cache, cache->config.max_flushes_inline, PGC_SECTION_ALL, false, false);
}
bool pgc_page_to_clean_evict_or_release(PGC *cache, PGC_PAGE *page) {
@@ -2224,7 +2222,7 @@ void pgc_open_cache_to_journal_v2(PGC *cache, Word_t section, unsigned datafile_
while ((PValue2 = JudyLFirstThenNext(mi->JudyL_pages_by_start_time, &start_time, &start_time_first))) {
struct jv2_page_info *pi = *PValue2;
page_transition_unlock(cache, pi->page);
- pgc_page_hot_to_dirty_and_release(cache, pi->page);
+ pgc_page_hot_to_dirty_and_release(cache, pi->page, true);
// make_acquired_page_clean_and_evict_or_page_release(cache, pi->page);
aral_freez(ar_pi, pi);
}
@@ -2251,6 +2249,8 @@ void pgc_open_cache_to_journal_v2(PGC *cache, Word_t section, unsigned datafile_
aral_by_size_release(ar_mi);
__atomic_sub_fetch(&cache->stats.workers_jv2_flush, 1, __ATOMIC_RELAXED);
+
+ flush_pages(cache, cache->config.max_flushes_inline, PGC_SECTION_ALL, false, false);
}
static bool match_page_data(PGC_PAGE *page, void *data) {
@@ -2396,7 +2396,7 @@ void *unittest_stress_test_collector(void *ptr) {
if(i % 10 == 0)
pgc_page_to_clean_evict_or_release(pgc_uts.cache, pgc_uts.metrics[i]);
else
- pgc_page_hot_to_dirty_and_release(pgc_uts.cache, pgc_uts.metrics[i]);
+ pgc_page_hot_to_dirty_and_release(pgc_uts.cache, pgc_uts.metrics[i], false);
}
}
@@ -2721,7 +2721,7 @@ int pgc_unittest(void) {
}, NULL);
pgc_page_hot_set_end_time_s(cache, page2, 2001);
- pgc_page_hot_to_dirty_and_release(cache, page2);
+ pgc_page_hot_to_dirty_and_release(cache, page2, false);
PGC_PAGE *page3 = pgc_page_add_and_acquire(cache, (PGC_ENTRY){
.section = 3,
@@ -2734,7 +2734,7 @@ int pgc_unittest(void) {
}, NULL);
pgc_page_hot_set_end_time_s(cache, page3, 2001);
- pgc_page_hot_to_dirty_and_release(cache, page3);
+ pgc_page_hot_to_dirty_and_release(cache, page3, false);
pgc_destroy(cache);
diff --git a/src/database/engine/cache.h b/src/database/engine/cache.h
index d3ac1bae69..b6f81bcc2d 100644
--- a/src/database/engine/cache.h
+++ b/src/database/engine/cache.h
@@ -192,7 +192,7 @@ PGC_PAGE *pgc_page_dup(PGC *cache, PGC_PAGE *page);
void pgc_page_release(PGC *cache, PGC_PAGE *page);
// mark a hot page dirty, and release it
-void pgc_page_hot_to_dirty_and_release(PGC *cache, PGC_PAGE *page);
+void pgc_page_hot_to_dirty_and_release(PGC *cache, PGC_PAGE *page, bool never_flush);
// find a page from the cache
typedef enum {
diff --git a/src/database/engine/rrdengineapi.c b/src/database/engine/rrdengineapi.c
index b9c2b59801..d1a96d07a0 100755
--- a/src/database/engine/rrdengineapi.c
+++ b/src/database/engine/rrdengineapi.c
@@ -320,7 +320,7 @@ void rrdeng_store_metric_flush_current_page(STORAGE_COLLECT_HANDLE *sch) {
__atomic_add_fetch(&ctx->atomic.samples, add_samples, __ATOMIC_RELAXED);
}
- pgc_page_hot_to_dirty_and_release(main_cache, handle->pgc_page);
+ pgc_page_hot_to_dirty_and_release(main_cache, handle->pgc_page, false);
}
mrg_metric_set_hot_latest_time_s(main_mrg, handle->metric, 0);