Code

src/utils_cache.c: Very minor performance improvement.
authorFlorian Forster <octo@collectd.org>
Tue, 14 Jan 2014 06:24:40 +0000 (07:24 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 14 Jan 2014 06:41:34 +0000 (07:41 +0100)
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

index fa6e6603ec3e10eedcdc6ea7d56ab64a0b04db6e..05386db9d33e9f12fa486ec90cf5cbf67868c23d 100644 (file)
@@ -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 */