diff options
author | Dan McGee <dan@archlinux.org> | 2010-11-02 18:38:04 -0500 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2010-11-02 19:20:19 -0700 |
commit | 92d6e1240c455a3cb4a0bb7f9ada41061d4c6147 (patch) | |
tree | 1ab761ba4244b0dc7c4cdfe2fc7cfc59bf07af92 | |
parent | 3d8d80dff183f7fec69df55950e01f0b06e4f5ea (diff) | |
download | memcached-92d6e1240c455a3cb4a0bb7f9ada41061d4c6147.tar.gz |
Simplify stats aggregation code
We can use memset, unlike what the previous comment said, because this is a
one-time allocated thread_stats struct that doesn't actually use the mutex
for anything. This simplifies the setup code a decent amount and makes one
fewer place where things need to be added if a new stat is introduced.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | thread.c | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -503,22 +503,10 @@ void threadlocal_stats_reset(void) { void threadlocal_stats_aggregate(struct thread_stats *stats) { int ii, sid; - /* The struct contains a mutex, so I should probably not memset it.. */ - stats->get_cmds = 0; - stats->get_misses = 0; - stats->delete_misses = 0; - stats->incr_misses = 0; - stats->decr_misses = 0; - stats->cas_misses = 0; - stats->bytes_written = 0; - stats->bytes_read = 0; - stats->flush_cmds = 0; - stats->conn_yields = 0; - stats->auth_cmds = 0; - stats->auth_errors = 0; - - memset(stats->slab_stats, 0, - sizeof(struct slab_stats) * MAX_NUMBER_OF_SLAB_CLASSES); + + /* The struct has a mutex, but we can safely set the whole thing + * to zero since it is unused when aggregating. */ + memset(stats, 0, sizeof(*stats)); for (ii = 0; ii < settings.num_threads; ++ii) { pthread_mutex_lock(&threads[ii].stats.mutex); |