-
Notifications
You must be signed in to change notification settings - Fork 974
Group and flush add-responses after journal sync #3837
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| import org.apache.bookkeeper.common.util.MemoryLimitController; | ||
| import org.apache.bookkeeper.common.util.affinity.CpuAffinity; | ||
| import org.apache.bookkeeper.conf.ServerConfiguration; | ||
| import org.apache.bookkeeper.processor.RequestProcessor; | ||
| import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback; | ||
| import org.apache.bookkeeper.stats.Counter; | ||
| import org.apache.bookkeeper.stats.NullStatsLogger; | ||
|
|
@@ -444,6 +445,8 @@ private class ForceWriteThread extends BookieCriticalThread { | |
| // This holds the queue entries that should be notified after a | ||
| // successful force write | ||
| Thread threadToNotifyOnEx; | ||
|
|
||
| RequestProcessor requestProcessor; | ||
| // should we group force writes | ||
| private final boolean enableGroupForceWrites; | ||
| private final Counter forceWriteThreadTime; | ||
|
|
@@ -499,6 +502,10 @@ public void run() { | |
| journalStats.getForceWriteGroupingCountStats() | ||
| .registerSuccessfulValue(numReqInLastForceWrite); | ||
|
|
||
| if (requestProcessor != null) { | ||
| requestProcessor.flushPendingResponses(); | ||
| } | ||
|
|
||
| } catch (IOException ioe) { | ||
| LOG.error("I/O exception in ForceWrite thread", ioe); | ||
| running = false; | ||
|
|
@@ -1093,6 +1100,10 @@ journalFormatVersionToWrite, getBufferedChannelBuilder(), | |
| numEntriesToFlush--; | ||
| entry.run(); | ||
| } | ||
|
|
||
| if (forceWriteThread.requestProcessor != null) { | ||
| forceWriteThread.requestProcessor.flushPendingResponses(); | ||
| } | ||
|
Comment on lines
+1103
to
+1106
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to record
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flush would be very fast though. It's only posting an event on the channel group, not writing the actuals responses on the channels. |
||
| } | ||
|
|
||
| lastFlushPosition = bc.position(); | ||
|
|
@@ -1211,6 +1222,10 @@ public BufferedChannelBuilder getBufferedChannelBuilder() { | |
| return (FileChannel fc, int capacity) -> new BufferedChannel(allocator, fc, capacity); | ||
| } | ||
|
|
||
| public void setRequestProcessor(RequestProcessor requestProcessor) { | ||
| forceWriteThread.requestProcessor = requestProcessor; | ||
| } | ||
|
|
||
| /** | ||
| * Shuts down the journal. | ||
| */ | ||
|
|
||
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.
Here we trigger all channels to flush
pendingSendResponses, shall we only pick the requestHandler which is written to the logFile to flushpendingSendResponses, it may reduce the unnecessary iteration in the loop.If there are 1000 channels, maybe only 2 channels need to flush
pendingSendResponses