An implementation repeatedly updates data in a data structure, the data
structure having a size larger than an atomic size. The implementation
avoids locking the data structure on every update, however. One method
accesses data in a first portion of a data structure and estimates, based
on the accessed data, an impact on data in a second portion of the data
structure arising from an update to data in the first portion. The method
then determines, based on the estimated impact, whether to lock the data
structure during an update to data in the data structure. In a more
particular example, a counter is copied on a regular basis. If only the
least significant bits of the counter have changed, then an atomic
instruction is used to copy only the least significant bits. However,
when the more significant bits have changed, a lock is used to copy the
entire counter.