6.3.3 Simple Limit Counter Discussion

This type of counter is quite fast when aggregate values are near zero, with some overhead due to the comparison and branch in both add_count()'s and sub_count()'s fastpaths. However, the use of a per-thread countermax reserve means that add_count() can fail even when the aggregate value of the counter is nowhere near globalcountmax. Similarly, sub_count() can fail even when the aggregate value of the counter is nowhere near zero.

In many cases, this is unacceptable. Even if the globalcountmax is intended to be an approximate limit, there is usually a limit to exactly how much approximation can be tolerated. One way to limit the degree of approximation is to impose an upper limit on the value of the per-thread countermax instances. This task is undertaken in the next section.



Paul E. McKenney 2011-12-16