Open LeoMe1 opened 2 years ago
Refer https://github.com/alibaba/Sentinel/issues/1031#issuecomment-530674172
There are some legacy reasons for using concurrentlinkedhashmap. Since the min-supported JDK has been polished to 1.8, we may replace it with Caffeine. Contributions are welcomed!
这一块使用 concurrentlinkedhashmap 有历史原因,目前 Sentinel 支持的最低 JDK 版本为 1.8,因此可以考虑替换为 Caffeine. 欢迎社区一起讨论与贡献
Could I fix it?
Could I fix it?
sure!
Caffeine fixes this by lazily growing an array of ring buffers based on contention (failed CAS operations). This saves memory if under low concurrency while scaling under high load. See Java’s LongAdder which does this for counters and was heavily borrowed from.
Issue Description
ConcurrentLinkedHashMap在构造二维数组时会根据CPU核心数来计算出当前数组的一维下标长度,当核数为96时,下标为128,此时单个ParameterMetric对象大小接近1M,如下图所示:
当接口调用量较大时,此处将会占用大量内存,sentinel是否有考虑过这块的内存使用,或者切成其他Cache?毕竟googlecode.concurrentlinkedhashmap作者也建议使用Caffeine了.
Tell us your environment
springboot 2.3.10 sentinel 1.7.2 springcloudgateway 2.2.6
Anything else we need to know?
sentinel在后续版本中是否有意向对这块进行修改?