diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-10-03 12:09:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 12:09:56 +0300 |
commit | 31c9be1c073ff869b74c7551f3494669503e63e7 (patch) | |
tree | 72c366a58721c9ddf0d591bc058eb78e68f4b37c /libnetdata | |
parent | 20e3113847f8d525dc9c1b034e73ce1fb753207b (diff) |
a simple journal optimization (#16099)
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/facets/facets.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/libnetdata/facets/facets.c b/libnetdata/facets/facets.c index d8b0d56d81..7e7e829103 100644 --- a/libnetdata/facets/facets.c +++ b/libnetdata/facets/facets.c @@ -1738,10 +1738,12 @@ bool facets_row_finished(FACETS *facets, usec_t usec) { if((facets->query && facets->keys_filtered_by_query && !facets->current_row.keys_matched_by_query) || (facets->timeframe.before_ut && usec > facets->timeframe.before_ut) || - (facets->timeframe.after_ut && usec < facets->timeframe.after_ut)) { + (facets->timeframe.after_ut && usec < facets->timeframe.after_ut) || + !facets_is_entry_within_anchor(facets, usec) /* this has to be last */) { // this row is not useful // 1. not matched by full text search, or - // 2. not in our timeframe + // 2. not in our timeframe, or + // 3. is not selected by the anchor facets_reset_keys_with_value_and_row(facets); return false; } @@ -1770,42 +1772,38 @@ bool facets_row_finished(FACETS *facets, usec_t usec) { facets->histogram.key = k; } - bool within_anchor = facets_is_entry_within_anchor(facets, usec); + if(selected_keys >= total_keys - 1) { + size_t found = 0; + (void) found; - if(likely(within_anchor)) { - if(selected_keys >= total_keys - 1) { - size_t found = 0; - (void) found; + for(size_t p = 0; p < entries; p++) { + FACET_KEY *k = facets->keys_with_values.array[p]; - for(size_t p = 0; p < entries; p++) { - FACET_KEY *k = facets->keys_with_values.array[p]; + size_t counted_by = selected_keys; - size_t counted_by = selected_keys; + if(counted_by != total_keys && !k->key_values_selected_in_row) + counted_by++; - if(counted_by != total_keys && !k->key_values_selected_in_row) - counted_by++; + if(counted_by == total_keys) { + FACET_VALUE *v = FACET_VALUE_GET_CURRENT_VALUE(k); + v->final_facet_value_counter++; - if(counted_by == total_keys) { - FACET_VALUE *v = FACET_VALUE_GET_CURRENT_VALUE(k); - v->final_facet_value_counter++; - - found++; - } + found++; } - - internal_fatal(!found, "We should find at least one facet to count this row"); } - if(selected_keys == total_keys) { - // we need to keep this row - facets_histogram_update_value(facets, usec); - facets_row_keep(facets, usec); - } + internal_fatal(!found, "We should find at least one facet to count this row"); + } + + if(selected_keys == total_keys) { + // we need to keep this row + facets_histogram_update_value(facets, usec); + facets_row_keep(facets, usec); } facets_reset_keys_with_value_and_row(facets); - return selected_keys == total_keys && within_anchor; + return selected_keys == total_keys; } // ---------------------------------------------------------------------------- |