Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atomic Integer lazySet performance gains

The article "Atomic*.lazySet is a performance win for single writers," goes over how lazySet is a weak volatile write (in the sense that it acts as a store-store and not a store-load fence). But I don't understand how leveraging semi-volatile writes improves concurrent queue performance. How exactly does it offer extra low latency as claimed by Menta-queue?

I already read up on it's implementation and it's claims on the stack overflow question: "How is lazySet in Java's Atomic* classes implemented" and "Atomic Integer's lazySet vs set."

like image 243
Devarsh Desai Avatar asked Sep 15 '14 04:09

Devarsh Desai


1 Answers

The problem with a volatile write on x86 is that it issues full memory barrier which results in a stall until the store buffer is drained. Meanwhile lazySet on x86 is a simple store. It does not require all previous stores waiting in the store buffer to be flushed, thus allowing writing thread to proceed at full speed.

This is described a bit in Martin Thompson's article.

like image 182
apangin Avatar answered Oct 05 '22 12:10

apangin