Previous | Next --- Slide 19 of 48
Back to Lecture Thumbnails
chenh1

What does "might use it more sparsely" mean?

kapalani

I think it means don't do it as much. For example if you have several threads running on different cores all trying to sum one very large array and store the result in a variable sum, if they all kept acquiring a lock on the one common variable and storing the intermediate result and releasing the lock then performance of the program would be very poor because of the excessive lock contention and because the each update of the common variable by a thread running on one core will cause it to be evicted from the caches of all the other cores making the cost of synchronization very expensive. Instead if each thread would request a lock to the common variable less often (perhaps by accumulating a private sum and only requesting it after its done summing its portion of the array), then lock contention is reduced and sum doesn't have to bounce around the different caches and so this will give better performance

ask

@chenh Time and computation spent in synchronization is an overhead on the performance of the system. I think the statement simple means that the goal is to perform a lesser number of synchronization steps or increase the interval between synchronization steps in order to avoid these overheads and achieve improved performance.