Skip to content

Conversation

@love4coding
Copy link

…枚举值字段)

Describe what this PR does / why we need it

生产环境dubbo接口配置了热点参数限流规则,请求对象包含sku\店铺id等多个无限枚举值字段,继承ParamFlowArgument指定某个字段配置不同的限流阈值,每隔几天订单服务出现堆内存溢出,服务不可用; 通过分析堆内存,发现ParameterMetric下的HashMap对象在服务启动后逐渐增长达到4g大小,无法gc回收

Does this pull request fix one issue?

NONE

Describe how you did it

ParamFlowArgument.threadCount.CacheMap会为每次dubbo接口的请求的复合请求对象put一组新的健值对, 当dubbo复合请求对象存在无限多个枚举值时, 内存溢出; 优化为只采集ParamFlowArgument指定字段枚举值的线程指标

Describe how to verify it

通过jmter压测或者单测debug ParameterMetric类,每次请求构造不同的arg对象(not equals), ParamFlowArgument.threadCount.CacheMap每次请求都会put一组新的健值对, 超过默认大小4000后无法及时回收
threadCount.putIfAbsent(arg, new AtomicInteger());

Special notes for reviews

@codecov
Copy link

codecov bot commented May 27, 2024

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.89%. Comparing base (dbd3c06) to head (9c93754).
⚠️ Report is 14 commits behind head on 1.8.

Files with missing lines Patch % Lines
...ntinel/slots/block/flow/param/ParameterMetric.java 0.00% 2 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.8    #3391      +/-   ##
============================================
- Coverage     45.90%   45.89%   -0.02%     
+ Complexity     2148     2145       -3     
============================================
  Files           431      431              
  Lines         12906    12910       +4     
  Branches       1728     1730       +2     
============================================
  Hits           5925     5925              
+ Misses         6281     6280       -1     
- Partials        700      705       +5     
Components Coverage Δ
sentinel-adapter 43.22% <ø> (ø)
sentinel-cluster 23.68% <ø> (-0.11%) ⬇️
sentinel-core 59.58% <ø> (-0.04%) ⬇️
sentinel-extension 46.28% <0.00%> (+0.14%) ⬆️
sentinel-logging 54.54% <ø> (ø)

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LearningGp LearningGp added to-review To review area/hotspot-param-flow Issues or PRs related to "hot-spot" param flow control labels May 29, 2024
@LearningGp
Copy link
Collaborator

The fix looks good. Please add a unit test to cover this code path.

@LearningGp LearningGp added wait-for-response PRs that require further response and removed to-review To review labels Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hotspot-param-flow Issues or PRs related to "hot-spot" param flow control wait-for-response PRs that require further response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants