[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
event counting vs. the cache
It's customary to use a 64-bit integer to count events in NetBSD because
we don't expect for the count to roll over in the lifetime of a box
I've been thinking about what these wide integers do to the cache
footprint of a system and wondering if we shouldn't make a couple of
1) Cram just as many counters into each cacheline as possible.
Extend/replace evcnt(9) to allow the caller to provide the storage
for the integer.
On a multiprocessor box, you don't want CPUs sharing counter
cachelines if you can help it, but do cram together each individual
2) Split all counters into two parts: high-order 32 bits, low-order 32
bits. It's only necessary to touch the high-order part when the
low-order part rolls over, so in effect you split the counters into
write-often (hot) and write-rarely (cold) parts. Cram together the
cold parts in cachelines. Cram together the hot parts in cachelines.
Only the hot parts change that often, so the ordinary footprint of
counters in the cache is cut almost in half.
I suppose you could split counters into four or more parts of 16 or
fewer bits each, and in that shrink the footprint even further, but it
seems that you would reach a point of diminishing returns very quickly.
Perhaps this has been tried before and found to (not) work reasonably
dyoung%pobox.com@localhost Urbana, IL (217) 721-9981
Main Index |
Thread Index |