0% found this document useful (0 votes)
518 views1 page

Cache Line Ping Pong

Cache line ping-ponging can occur in non-blocking algorithms as threads repeatedly try and fail to perform operations on the same cache line, bouncing it between CPU caches. Memory reclamation is difficult for non-blocking algorithms that remove nodes from linked data structures using compare-and-swap operations, as a thread cannot know if another thread is still using a node after it is removed. Experts should create new non-blocking linked data structure algorithms and non-experts should use proven algorithms, understanding memory management issues.

Uploaded by

bsgindia82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
518 views1 page

Cache Line Ping Pong

Cache line ping-ponging can occur in non-blocking algorithms as threads repeatedly try and fail to perform operations on the same cache line, bouncing it between CPU caches. Memory reclamation is difficult for non-blocking algorithms that remove nodes from linked data structures using compare-and-swap operations, as a thread cannot know if another thread is still using a node after it is removed. Experts should create new non-blocking linked data structure algorithms and non-experts should use proven algorithms, understanding memory management issues.

Uploaded by

bsgindia82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

CACHE LINE PING-PONGING: Non-blocking algorithms can cause a lot of traffic on the memory bus as various hardware threads

s keep trying and retrying to perform operations on the same cache line. To service these operations, the cache linebounces back and forth ( ping-pongs) between the contending threads. locked algorithm may outperform the non-blocking e!uivalent if lock contention is sufficiently distributed."#perimentation is necessary to find out whether the non-blocking or locked algorithm is better. rough guide is that a fast spin lock protecting a critical section with no atomic operations may outperform an alternative non-blocking design that re!uires three or more highly contended atomic operations. MEMORY RECLAMATION PROBLEM: $emory reclamation is the dirty laundry of many non-blocking algorithms. %or languages such as &'&(( that re!uire the programmer to e#plicitly free memory, it turns out to be surprisingly difficult to call free on a node used in a non-blocking algorithm. The problem occurs for algorithms that remove nodes from linked structures, and do so by performing compare-e#change operations on fields in the nodes. %or e#ample, non-blocking algorithms for !ueues do this. The reason is that when a thread removes a node from a data structure, without using a lock to e#clude other threads, it never knows if another thread still looking at the node. The solution is to use a garbage collector or mini-collector like ha)ard pointers. lternatively you may associate a free list of nodes with the data structure and not free any nodes until the data structure itself is freed.

RECOMMENDATIONS: Non-blocking algorithms big advantage is avoiding lock pathologies. Their primary disadvantage is that they are much more complicated than their locked counterparts. Non-blocking algorithms are difficult to verify. None#perts should consider the following advice: tomic increment, decrement, and fetch-and-add are generally safe to use in an intuitive fashion. The fetch-and-op idiom is generally safe to use with operations that are commutative and associative. The creation of non-blocking algorithms for linked data structures should be left to e#perts. *se algorithms from the peer-reviewed literature. +e sure to understand any memory reclamation issues. void having more runnable software threads than hardware threads, and design programs to avoid lock contention.

You might also like