Skip to content
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

perf: schedule in eventloop for batchWrite of endpoint #2947

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

okg-cxf
Copy link

@okg-cxf okg-cxf commented Aug 8, 2024

Make sure that:

  • [Y] You have read the contribution guidelines.
  • [Y] You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • [Y] You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • [Y] You submit test cases (unit or integration tests) that back your changes.

channelWrite() will result in SingleThreadEventLoop#taskQueue.offer() which is a volatile write, it could be quite expensive if the batch size is super large.

Bench result (batchSize: 500)

with perf:
RedisClientBenchmark.asyncSetBatchFlush     avgt   10   1176.188 ±    2.945  ns/op  (18% performance gain)
RedisClientBenchmark.reactiveSetBatchFlush  avgt   10   7701.130 ±  580.995  ns/op (performance slightly down, maybe need to add a switch to control the behavior?)

without perf:
Benchmark                                   Mode  Cnt      Score      Error  Units
RedisClientBenchmark.asyncSetBatchFlush     avgt   10   1387.984 ±   46.847  ns/op
RedisClientBenchmark.reactiveSetBatchFlush  avgt   10   7308.346 ±  129.363  ns/op

@tishun
Copy link
Collaborator

tishun commented Aug 8, 2024

The failing tests are failing in other PRs too, seems to be a regression, investigating currently ...

@tishun
Copy link
Collaborator

tishun commented Aug 8, 2024

The failing tests are failing in other PRs too, seems to be a regression, investigating currently ...

You need to fetch the fix from #2949

if (eventLoop.inEventLoop()) {
runnable.run();
} else {
eventLoop.execute(runnable);
Copy link
Contributor

@Roiocam Roiocam Aug 19, 2024

Choose a reason for hiding this comment

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

Looks like it will limit the throughput because it will has only few thread write, in the legacy way, both IOGroup and ExecutorGroup can execute.

can you verify the performance improvement not just JMH case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants