Skip to content

[ISSUE #9581] Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios#9579

Merged
RongtongJin merged 2 commits intoapache:developfrom
RongtongJin:dev-0726
Sep 8, 2025
Merged

[ISSUE #9581] Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios#9579
RongtongJin merged 2 commits intoapache:developfrom
RongtongJin:dev-0726

Conversation

@RongtongJin
Copy link
Copy Markdown
Contributor

@RongtongJin RongtongJin commented Jul 29, 2025

Which Issue(s) This PR Fixes

Fixes #9581

In the LMQ scenario, the system cannot determine whether a topic or subscription actually exists (LMQ assumes all of them exist by default). As a result, the cleanUnusedResource becomes ineffective, and after prolonged operation the sizes of topicCidMap and pollingMap grow close to their maximumSize, wasting memory and CPU.

Introduce a Caffeine cache so that entries automatically expire after they have been absent for a prolonged period.

Brief Description

Introduce a Caffeine cache so that entries automatically expire after they have been absent for a prolonged period.

How Did You Test This Change?

@RongtongJin RongtongJin marked this pull request as draft July 29, 2025 08:01
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 48.27586% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.04%. Comparing base (e20d56b) to head (bd8074e).
⚠️ Report is 82 commits behind head on develop.

Files with missing lines Patch % Lines
...etmq/broker/longpolling/PopLongPollingService.java 54.16% 8 Missing and 3 partials ⚠️
.../java/org/apache/rocketmq/common/BrokerConfig.java 25.00% 3 Missing ⚠️
...ocketmq/broker/processor/PollingInfoProcessor.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #9579      +/-   ##
=============================================
- Coverage      48.13%   48.04%   -0.10%     
+ Complexity     12074    12044      -30     
=============================================
  Files           1313     1313              
  Lines          92791    92789       -2     
  Branches       11866    11862       -4     
=============================================
- Hits           44667    44576      -91     
- Misses         42628    42700      +72     
- Partials        5496     5513      +17     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RongtongJin RongtongJin changed the title Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios [ISSUE #9581] Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios Jul 30, 2025
Copy link
Copy Markdown
Contributor

@fuyou001 fuyou001 left a comment

Choose a reason for hiding this comment

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

LGTM

@RongtongJin RongtongJin marked this pull request as ready for review August 7, 2025 01:36
private final ConcurrentLinkedHashMap<String, ConcurrentHashMap<String, Byte>> topicCidMap;
private final ConcurrentLinkedHashMap<String, ConcurrentSkipListSet<PopRequest>> pollingMap;
private final Cache<String, ConcurrentHashMap<String, Byte>> topicCidMap;
private final Cache<String, ConcurrentSkipListSet<PopRequest>> pollingMap;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@RongtongJin RongtongJin merged commit 32d68e7 into apache:develop Sep 8, 2025
10 of 13 checks passed
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.

[Enhancement] Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios

4 participants