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

[ISSUE #3585] [Part J] Use MappedByteBuffer instead of FileChannel to … #3657

Merged
merged 1 commit into from
Dec 27, 2021

Conversation

areyouok
Copy link
Contributor

Make sure set the target branch to develop

What is the purpose of the change

speed up reput performance (relative to consumer tps) .

Brief changelog

Use MappedByteBuffer instead of FileChannel to write consume queue and slave commitlog.

Verifying this change

This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps.

72 queue consume qps: from about 70,000 to 200,000

600 queue consume qps: from about 70,000 to 110,000

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

…write consume queue and slave commitlog.

This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps.
72 queue consume qps: from about 70,000 to 200,000
600 queue consume qps: from about 70,000 to 110,000
@areyouok areyouok linked an issue Dec 16, 2021 that may be closed by this pull request
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 56.186% when pulling 122a69b on areyouok:492_PartJ into ecb061a on apache:develop.

@codecov-commenter
Copy link

Codecov Report

Merging #3657 (122a69b) into develop (ecb061a) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3657      +/-   ##
=============================================
- Coverage      49.69%   49.67%   -0.02%     
+ Complexity      4725     4723       -2     
=============================================
  Files            555      555              
  Lines          36798    36800       +2     
  Branches        4853     4853              
=============================================
- Hits           18286    18281       -5     
- Misses         16214    16220       +6     
- Partials        2298     2299       +1     
Impacted Files Coverage Δ
...ain/java/org/apache/rocketmq/store/MappedFile.java 50.18% <100.00%> (-0.01%) ⬇️
...in/java/org/apache/rocketmq/test/util/MQAdmin.java 38.88% <0.00%> (-5.56%) ⬇️
...apache/rocketmq/remoting/netty/ResponseFuture.java 85.00% <0.00%> (-5.00%) ⬇️
...sumer/rebalance/AllocateMessageQueueAveragely.java 56.52% <0.00%> (-4.35%) ⬇️
...rocketmq/remoting/netty/NettyRemotingAbstract.java 46.88% <0.00%> (-4.03%) ⬇️
...he/rocketmq/client/trace/AsyncTraceDispatcher.java 77.22% <0.00%> (-1.00%) ⬇️
.../rocketmq/broker/filter/ConsumerFilterManager.java 72.19% <0.00%> (-0.90%) ⬇️
...a/org/apache/rocketmq/store/StoreStatsService.java 29.50% <0.00%> (-0.66%) ⬇️
...org/apache/rocketmq/store/DefaultMessageStore.java 56.04% <0.00%> (-0.20%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecb061a...122a69b. Read the comment docs.

@areyouok
Copy link
Contributor Author

before:

before

after:

after

@RongtongJin RongtongJin merged commit 6d247cb into apache:develop Dec 27, 2021
@RongtongJin RongtongJin added this to the 4.9.3 milestone Dec 27, 2021
@francisoliverlee francisoliverlee changed the title [ISSUE 3585] [Part J] Use MappedByteBuffer instead of FileChannel to … [ISSUE #3585] [Part J] Use MappedByteBuffer instead of FileChannel to … Feb 21, 2022
devfat pushed a commit to devfat/rocketmq that referenced this pull request Mar 3, 2022
…write consume queue and slave commitlog. (apache#3657)

This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps.
72 queue consume qps: from about 70,000 to 200,000
600 queue consume qps: from about 70,000 to 110,000
GenerousMan pushed a commit to GenerousMan/rocketmq that referenced this pull request Aug 12, 2022
…write consume queue and slave commitlog. (apache#3657)

This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps.
72 queue consume qps: from about 70,000 to 200,000
600 queue consume qps: from about 70,000 to 110,000
@kimmking
Copy link
Member

kimmking commented Mar 5, 2023

Actually, mmap is better than fileChannel in small size message case. In large scale size message, fileChannel is more better.
There could be an option to switch mmap/fileChannel.
See https://www.jianshu.com/p/d0b4ac90dbcb

@kimmking
Copy link
Member

kimmking commented Mar 5, 2023

As another effect, we found after upgrade to 4.9.4, mmap avoid many swap usage rather than older version with fileChannel.
See https://stackoverflow.com/questions/49996217/filechannel-vs-mappedbytebuffer-in-random-access

carlvine500 pushed a commit to carlvine500/rocketmq-apache that referenced this pull request Sep 10, 2024
…write consume queue and slave commitlog. (apache#3657)

This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps.
72 queue consume qps: from about 70,000 to 200,000
600 queue consume qps: from about 70,000 to 110,000
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.

Improve performance for 4.9.2
10 participants