Skip to content

Conversation

@merlimat
Copy link
Contributor

Motivation

Instead of dequeuing all the ForceWriteRequest one by one, use drainTo() to reduce contention with the main journal thread.

@zymap zymap added this to the 4.16.0 milestone Oct 18, 2022
Copy link
Contributor

@hangc0276 hangc0276 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@merlimat merlimat merged commit b63cca8 into apache:master Oct 19, 2022
hangc0276 pushed a commit that referenced this pull request Mar 6, 2023
…rainTo() (#3830)

### Motivation

In #3545 we have switched the `ForceWriteThread` to take advantage o `BlockingQueue.drainTo()` method for reducing contention, though the core logic of the force-write was not touched at the time.

The logic of force-write is quite complicated because it tries to group multiple force-write requests in the queue by sending a new marker and grouping them when the marker is received. This also leads to a bit of lag when there are many requests coming in and the IO is stressed, as we're waiting a bit more before issuing the fsync.

Instead, with the `drainTo()` approach we can greatly simplify the logic and maintain a strict fsync grouping: 
 1. drain all the force-write-requests available in the queue into a local array list
 2. perform the fsync
 3. update the journal log mark to the position of the last fw request
 4. trigger send-responses for all the requests
 5. go back to read from the queue


This refactoring will also enable further improvements, to optimize how the send responses are prepared, since we have now a list of responses ready to send.
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…rainTo() (apache#3830)

### Motivation

In apache#3545 we have switched the `ForceWriteThread` to take advantage o `BlockingQueue.drainTo()` method for reducing contention, though the core logic of the force-write was not touched at the time.

The logic of force-write is quite complicated because it tries to group multiple force-write requests in the queue by sending a new marker and grouping them when the marker is received. This also leads to a bit of lag when there are many requests coming in and the IO is stressed, as we're waiting a bit more before issuing the fsync.

Instead, with the `drainTo()` approach we can greatly simplify the logic and maintain a strict fsync grouping: 
 1. drain all the force-write-requests available in the queue into a local array list
 2. perform the fsync
 3. update the journal log mark to the position of the last fw request
 4. trigger send-responses for all the requests
 5. go back to read from the queue


This refactoring will also enable further improvements, to optimize how the send responses are prepared, since we have now a list of responses ready to send.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants