-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Is there a performance problem with the next(n) method? #482
Comments
A few thoughts:
|
OK!@ocoanet Thank you for your thoughts! I brought this up because I wanted everyone to discuss it. All can understand this framework design details more deeply in the discussion.A small request, by the way.@Palmr By the way a small request, can you mark my issues as questions? |
@swarren12 or @isolgpus will have to assist with changing issue types. Earlier this year I left LMAX and therefore handed back my owner rights for this repo. |
In the next(n) method we used
long wrapPoint = nextSequence - bufferSize;wrapPoint > cachedGatingSequence
in determining whether a wrap occurred or not.For example, in the following figure:Let's say we've posted a round, at which point cursor=15 and cachedGatingSequence=1. The producer calls next(4) again; the pseudo-code logic looks like this:
but it is clear that there are already two positions that can be filled, but we have to wait for “C” and “D” to be consumed before we can post an event to fill. General machine 100 times the value of the simple assignment of about 1500-5000 nanoseconds, assuming that we next (200) read and write events are simple assignment operations, 100 events are consumed, there are still 100 events have not been consumed, at this time the wrap occurs, then it is not 1500-5000 times parkNanos (1L), this system switching is not 1500-5000 times parkNanos (1L), this system switching is not a good idea? ), is this system switching too consuming?On the contrary, if you use next(), then each time you judge for the next cursor position, you will wait for one consumption at most. So is it recommended to use the default next()? And next(n) hanging mechanism instead of simple parkNanos(1L), such as and n some kind of correlation, or to put the winding judgment to event fill to determine the sequence of each slot? (Of course, this change for the whole architecture is a big disruption)
The text was updated successfully, but these errors were encountered: