coverage: Synchronize per-thread counters less aggressively
authorJoe Stringer <joestringer@nicira.com>
Fri, 15 Nov 2013 23:25:00 +0000 (15:25 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 20 Nov 2013 22:59:12 +0000 (14:59 -0800)
commitbc0d88eece4d6f0a5703d59102a7cf8f1f8c7372
tree814d7e1f17002e0fb6c380bf306f2ff398e29219
parent13465541ef305d28a665ff01550dd2dbc0985669
coverage: Synchronize per-thread counters less aggressively

When profiling CPU usage in situations involving high numbers of ports,
coverage_clear() was highlighted as a commonly called function. It
appears that it can be quite expensive to access all of the per-thread
coverage counters when threads are constantly waking up.

This patch makes each thread only do coverage_clear() logic roughly once
per second by introducing per-thread timers. Upcall handler counters may
become less accurate, as these threads may sleep without synchronising
and not wake up for some time. When the main thread is under load at
~90% CPU, this drops to ~85%. Upcall handler threads sitting at ~2.5%
drop to ~1.5%.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/coverage.c
lib/coverage.h
tests/ofproto-dpif.at