fix: 修复ParameterMetric在生产环境导致的内存泄漏(请求对象继承ParamFlowArgument,包含sku等多个无限… #3391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…枚举值字段)
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