On Tue, 1 Jun 2010 16:03:19 +0300
Antti Kantee <[email protected]> wrote:

> The above example of course applies more generally.  When you're going
> all out with the bag of tricks, "i++" can be very expensive ...

A better way would be for cpu to have its own counter, which is
incremented until it reaches a certain threshold. At the threshold, the
global counter is incremented by the local counter.

It all depends on the logic of what the counter is supposed to do. But
it doesn't have to be very expensive, i.e. if it's just a statistics
counter, you can do the above trick to reduce contention.

Reply via email to