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 #9064]Optimize the way to determine whether RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SSYS_TRANS-OP_ALF_TOPIC in transaction messages #9062

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

LilMosey
Copy link

@LilMosey LilMosey commented Dec 18, 2024

Which Issue(s) This PR Fixes

fixes #9064

Brief Description

事务消息, 回查判断RMQ_SYS_TRANS_HALF_TOPIC消息是否在RMQ_SYS_TRANS_OP_HALF_TOPIC 中,优化判断方式。之前代码是先判断Map.containsKey,然后进行removeKey,新的方式是直接removeKey != null。之前如果Map.containsKey为真,还需要进行额外的一步removeKey操作,新的方式removeKey!= null,即判断了Map是否存在key,又移出了对应的key,提升了一点点性能。

Transactional messages: The process involves checking whether messages in RMQ_SYS_TRANS_HALF_TOPIC exist in RMQ_SYS_TRANS_OP_HALF_TOPIC, with an optimized approach for verification. Previously, the code first used Map.containsKey to check existence and then performed removeKey. The new approach directly uses removeKey != null.

In the previous method, if Map.containsKey returned true, an additional removeKey operation was required. In contrast, the new approach both checks if the key exists in the Map and removes the corresponding key in one step, offering a slight performance improvement.

How Did You Test This Change?

经过多轮测试,在Map.containsKey 为true为false概率各为50%的情况,第二种方案明显优于第一种方案。而实际生产环境中,事务回查状态为Unknown的场景应该小于50%,在高并发大数据量场景下,个人认为这个小改动对性能还是有一些提升。

After multiple rounds of testing, when the probabilities of Map.containsKey being true or false are both 50%, the second approach consistently outperforms the first. In actual production environments, the probability of transactional checks being in an “Unknown” state should be less than 50%. Therefore, I believe this small adjustment provides a minor but meaningful performance improvement.
image

Transaction message, check back to determine if the OP-HALF-QUEUE message is in HALF-QUEUE, optimize the judgment method
@LilMosey LilMosey changed the title 优化事务消息回查判断RMQ_SYS_TRANS_HALF_TOPIC是否在RMQ_SYS_TRANS_OP_HALF_TOPIC中。 Optimize transaction message backtracking to determine if RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SYS_TRANS-OP_ALF_TOPIC. Dec 18, 2024
@LilMosey LilMosey changed the title Optimize transaction message backtracking to determine if RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SYS_TRANS-OP_ALF_TOPIC. Optimize the way to determine whether RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SSYS_TRANS-OP_ALF_TOPIC in transaction messages Dec 18, 2024
TangJie added 4 commits December 18, 2024 18:41
Transaction message, check back to determine if the OP-HALF-QUEUE message is in HALF-QUEUE, optimize the judgment method
Transaction message, check back to determine if the OP-HALF-QUEUE message is in HALF-QUEUE, optimize the judgment method
Transaction message, check back to determine if the OP-HALF-QUEUE message is in HALF-QUEUE, optimize the judgment method
Transaction message, check back to determine if the OP-HALF-QUEUE message is in HALF-QUEUE, optimize the judgment method
@LilMosey LilMosey changed the title Optimize the way to determine whether RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SSYS_TRANS-OP_ALF_TOPIC in transaction messages [ISSUE #9064]Optimize the way to determine whether RMQ_SYS_TRANS-HALFTOPIC is in RMQ_SSYS_TRANS-OP_ALF_TOPIC in transaction messages Dec 18, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 47.85%. Comparing base (93e2689) to head (f13c93e).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
...saction/queue/TransactionalMessageServiceImpl.java 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #9062      +/-   ##
=============================================
- Coverage      47.97%   47.85%   -0.13%     
+ Complexity     11904    11869      -35     
=============================================
  Files           1312     1312              
  Lines          91735    91733       -2     
  Branches       11751    11751              
=============================================
- Hits           44014    43898     -116     
- Misses         42312    42414     +102     
- Partials        5409     5421      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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