Skip to content

Commit

Permalink
Metric release does not need to fetch retention (netdata#17033)
Browse files Browse the repository at this point in the history
metric release does not need to fetch retention
  • Loading branch information
stelfrag committed Feb 19, 2024
1 parent 2daf34c commit b8254f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/database/engine/metric.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric) {
return refcount;
}

static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, METRIC *metric) {
static inline void metric_release(MRG *mrg __maybe_unused, METRIC *metric) {
spinlock_lock(&metric->refcount_spinlock);

if (metric->refcount <= 0)
Expand All @@ -169,6 +169,10 @@ static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, ME
__atomic_sub_fetch(&mrg->index[partition].stats.entries_referenced, 1, __ATOMIC_RELAXED);

__atomic_sub_fetch(&mrg->index[partition].stats.current_references, 1, __ATOMIC_RELAXED);
}

static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, METRIC *metric) {
metric_release(mrg, metric);

time_t first, last;
mrg_metric_get_retention(mrg, metric, &first, &last, NULL);
Expand Down Expand Up @@ -376,8 +380,8 @@ inline METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric) {
return metric;
}

inline bool mrg_metric_release(MRG *mrg, METRIC *metric) {
return metric_release_and_can_be_deleted(mrg, metric);
inline void mrg_metric_release(MRG *mrg, METRIC *metric) {
metric_release(mrg, metric);
}

inline Word_t mrg_metric_id(MRG *mrg __maybe_unused, METRIC *metric) {
Expand Down
2 changes: 1 addition & 1 deletion src/database/engine/metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MRG *mrg_create(ssize_t partitions);
void mrg_destroy(MRG *mrg);

METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric);
bool mrg_metric_release(MRG *mrg, METRIC *metric);
void mrg_metric_release(MRG *mrg, METRIC *metric);

METRIC *mrg_metric_add_and_acquire(MRG *mrg, MRG_ENTRY entry, bool *ret);
METRIC *mrg_metric_get_and_acquire(MRG *mrg, uuid_t *uuid, Word_t section);
Expand Down

0 comments on commit b8254f9

Please sign in to comment.