-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOUringEventLoop nextWakeupNanos #148
Comments
Hi @pveentjer : Line 361 in 98f7b6d
inEventLoop == false
I believe this could be changed in order to just use a plain get somewhere, but I believe using on https://www.scylladb.com/2018/02/15/memory-barriers-seastar-linux/ I see that there are ways to save a(n additional) full barrier there, so happy to review any PR to improve this |
Ok. In that case we need something more powerful than a plain long. But I think we can get rid of the fences. So a get/set opaque should be sufficient since there are no memory ordering effects required. |
So the following should be sufficient for the first set:
It will provide a [StoreStore][LoadStore] which on the X86 you get for free since all stores are release stores. So it is just a compiler restriction. setOpaque would be more appropriate, but not available on Java 8. Need to think about the getAndSet. |
With Scylla the mem barrier is removed for task exchange between threads. Memory ordering matters in that case. But afaik for the nextWakeupNanos memory ordering is irrelevant. So I don't see a good reason why a price needs to be paid for memory ordering if it is irrelevant. |
@pveentjer PRs welcome |
I would be more than happy to make a PR :) But before I do, I want to make sure my understanding is correct. Assumption: the memory ordering effects of nextWakeupNanos are irrelevant. We just need to make sure that the compiler doesn't optimize out the load or store. So is this assumption correct? |
Hey thanks @pveentjer. The However I changed it to But it's possible I was wrong about this, I'm sure your understanding of the memory order modes is better than mine! |
@njhill |
@franz1981 np I think it was just for info and it was quite a long time ago now! @pveentjer you also probably noticed we guard the |
In the IOUringEventLoop the nextWakeupNanos is updated twice:
The nextWakeupNanos is an AtomicLong and the set and getAndSet are not very cheap. On the X86 the trigger a memory fence which effectively causes the CPU to stop issuing loads till the store buffer has been drained. And this will not benefit performance.
Based on the code it seems that the nextWakeupNanos is not used by any other thread. Perhaps I'm missing something since I didn't study the code in-depth, but I think the nextWakeupNanos could be converted to a simple plain long.
THe IOUringSubmissionQueue already has the appropriate fences.
The text was updated successfully, but these errors were encountered: