From: Florian Forster Date: Tue, 14 Jan 2014 06:24:40 +0000 (+0100) Subject: src/utils_cache.c: Very minor performance improvement. X-Git-Tag: collectd-5.5.0~316^2~11 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=bdfb3f52d9df3ee202d926d1e5473693cc9b9032;ds=sidebyside 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?). --- 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 */