From bdfb3f52d9df3ee202d926d1e5473693cc9b9032 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 14 Jan 2014 07:24:40 +0100 Subject: [PATCH] src/utils_cache.c: Very minor performance improvement. cache_compare() is one of the hottest functions in collectd. Depending how many metrics collectd handles (how deep the tree is) it gets called an order of magnitude or two more often than the number of metrics handled. With 100k metrics, about 6.6% of the CPU time were spent within cache_compare(), with this commit this reduces to 6.3% (that's, uhm, 4.7% faster?). --- src/utils_cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils_cache.c b/src/utils_cache.c index fa6e6603..05386db9 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -68,7 +68,9 @@ static pthread_mutex_t cache_lock = PTHREAD_MUTEX_INITIALIZER; static int cache_compare (const cache_entry_t *a, const cache_entry_t *b) { +#if COLLECT_DEBUG assert ((a != NULL) && (b != NULL)); +#endif return (strcmp (a->name, b->name)); } /* int cache_compare */ -- 2.11.0