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

fix: 修复ParameterMetric在生产环境导致的内存泄漏(请求对象继承ParamFlowArgument,包含sku等多个无限… #3391

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

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

Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: 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 8 commits behind head on 1.8.

Files Patch % Lines
...ntinel/slots/block/flow/param/ParameterMetric.java 0.00% 2 Missing and 2 partials ⚠️
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.

@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
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 to-review To review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants