forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize produce request handler (apache#466)
### Motivation There're some problems with produce performance. The main problem is the pending produce queue. It holds multiple pending produce requests (`PendingProduce`), which wait until `PersistentTopic` is ready and the `MemoryRecords` is encoded. First, `PendingProduce`s wait for different futures of `PersistentTopic`. Second, encoding `MemoryRecords` is fast so that putting it to another thread is not necessary and could cause some performance overhead. ### Modifications 1. Encoding `MemoryRecords` in the same thread of `handleProduceRequest`. 2. Check if the `CompletableFuture<PersistentTopic>` is done. - If it's done, just publish the messages directly without pushing the pending produce requests to the queue. - Otherwise, reuse the previous `CompletableFuture<PersistentTopic>`. This trick is performed by `PendingTopicFutures`, which uses the previous `CompletableFuture<PersistentTopic>` by `thenApply` or `exceptionally`. 3. Add tests for `PendingTopicFutures`. 4. Use a map of partition and response instead of a map of partition and response future in `handleProduceRequest`.
- Loading branch information
1 parent
3a31730
commit 808b969
Showing
6 changed files
with
372 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.