Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce flush operations during journal build #17220

Merged
merged 1 commit into from Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/database/engine/cache.c
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/database/engine/cache.h
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/database/engine/rrdengineapi.c
Expand Up @@ -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);
Expand Down