-
Notifications
You must be signed in to change notification settings - Fork 909
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
Pin order executor in LedgerHandle #3738
Pin order executor in LedgerHandle #3738
Conversation
rerun failure checks |
PTAL @StevenLuMT @eolivelli |
@AnonHxy Would you please provide more context about the reason to pin the executor? thanks. |
Sure. It was inspired by this PR apache/pulsar#18078. and I have provided more detail reasons in the descriptions of this PR @hangc0276 |
PTAL @hangc0276 @eolivelli , thanks |
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.
when the execution mode changes, the performance change significantly ? ledgerID will block reading. Is it expected?
I think this patch will not change the executeion mode. It just make the execute thread as a final field, which is a obvious improvement. But I am not sure how much can be improved. @StevenLuMT |
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.
Overall LGTM. This change saves the cost of choosing threads in executeOrdered, and I wonder if choosing threads costs a lot of CPU resources and whether this change can improve the performance or not.
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeper.java
Show resolved
Hide resolved
I tested it using one bookie client to add entry async like following. It looks that it was not a significant improvement from the result.
|
@AnonHxy If there is no significant performance improvement, I think we can hold on this change. |
@AnonHxy Do you have any updates? |
OK. But I think this change is a positive optimization anyway, while the proform result is not obvious ... @hangc0276 |
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
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.
Good catch,LGTM
@eolivelli @dlg99 @merlimat PTAL, thanks:) |
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
Descriptions of the changes in this PR:
Motivation
Pin the order executor in
LedgerHandle
to save the choose thread overhead. For details reason:We could call
executeOrdered()
frequently, e.g., when inasyncReadEntries
. And we would compute the thread index from ledgerId every time when callexecuteOrdered()
. So pin the order executor will save the thread index compution time.Changes
LedgerHandle
constructor method and save it as a final fieldgetMainWorkerPool()
inMockBookKeeper
to fix UT NPE exception when callthis.executor = clientCtx.getMainWorkerPool().chooseThread(ledgerId);