-
Notifications
You must be signed in to change notification settings - Fork 893
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
Added BlockingQueue implementation based on JCtools #1682
Conversation
bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessorV3.java
Outdated
Show resolved
Hide resolved
@merlimat any perf/measurements that you can share? |
I am curious why you decided to implement blocking queue on top of JCtools' MPSC vs using disruptor that implements it. I do not have experience or stake in using either of those, but conversant claims to be faster and it already has blocking queue API. |
Same curiosity from me. Even Netty has its own MCSP queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me +1
@merlimat can you answer the questions why we are choosing JCtools queues? |
f542515
to
ade756a
Compare
@jvrao This really brings 2 benefits:
Some test results were shared here: netty/netty#8267 (comment) . Though this was including Pulsar in the mix, on top of BK, with same kind of optimizations applied.
@dlg99 @eolivelli I was not aware of conversant library. I was looking at Lmax disruptor but it forces to change all your code to fit into its model of dedicating a thread to it. I wanted to have a regular blocking queue so that this can also be directly plugged into the OrderedSafeExecutor (or any JDK executor), so that existing code doesn't have to be modified. JCTool seems to be well maintained, the concurrency code is very scrupulously reviewed and is being used in several high profile projects, from Netty, Cassandra, Log4j, etc.
Netty is actually importing JCTools queue :) |
run integration tests |
Yes I noticed that Netty has its own copy of jctools queue. I am fine with this idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left two comments, please take a look.
Overall it looks good to me
handle = MethodHandles.lookup().findStatic(Thread.class, "onSpinWait", MethodType.methodType(void.class)); | ||
} catch (Throwable t) { | ||
// Ignore | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should log this error, so that it is clear that we are not able to leverage this feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not strictly critical for performance, it's just a way to consume less CPU power.
Since it's not available in Java8, I'd rather keep this at debug level to avoid printing the warning every time (eg: even if busywait is not used).
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerDescriptorImpl.java
Outdated
Show resolved
Hide resolved
run pr validation |
1 similar comment
run pr validation |
@eolivelli PTAL again |
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
Outdated
Show resolved
Hide resolved
cfef277
to
72d325e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good
+1
@jvrao @dlg99 @sijie @ivankelly Are we good to merge this one? |
run pr validation |
@dlg99 can you please review this? I wish we have some way to validate these perf changes. At lest to make sure it is not introducing perf regression. These changes are tricky - on paper they look like obvious win but in practice it is totally different picture. My comments are not specific to this change, but general category. @sijie |
@jvrao all these changes are by default turned off |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm if it is not turned on by default.
8bff8ec
to
e4306e1
Compare
run integration tests |
1 similar comment
run integration tests |
IGNORE IT CI |
// Flaky TestCompatUpgrade integration test. Seen failing in other PRs as well |
Motivation
Add a
BlockingQueue
implementation that is suitable for low latency and low contention.Key points:
(This will be used in subsequent PRs to optionally enable it)