Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs
来源:互联网 发布:女生做淘宝美工累吗 编辑:程序博客网 时间:2024/06/15 07:46
问题描述:
Presto日志中出现大量的
2017-07-31T15:31:21.505+0800 INFO Code-Cache-GC-Trigger com.facebook.presto.server.CodeCacheGcTrigger Triggering GC to avoid Code Cache eviction bugs
Presto版本为0.170。
排查过程:
1. 检查Presto源码
出现该条日志的代码为
// Hack to work around bugs in java 8 (8u45+) related to code cache management.// See http://openjdk.5641.n7.nabble.com/JIT-stops-compiling-after-a-while-java-8u45-td259603.html for more info.MemoryPoolMXBean codeCacheMbean = findCodeCacheMBean();Thread gcThread = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { long used = codeCacheMbean.getUsage().getUsed(); long max = codeCacheMbean.getUsage().getMax(); if (used > 0.95 * max) { log.error("Code Cache is more than 95% full. JIT may stop working."); } if (used > (max * collectionThreshold) / 100) { // Due to some obscure bug in hotspot (java 8), once the code cache fills up the JIT stops compiling // By forcing a GC, we let the code cache evictor make room before the cache fills up. log.info("Triggering GC to avoid Code Cache eviction bugs"); System.gc(); } try { TimeUnit.MILLISECONDS.sleep(interval.toMillis()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }});
由代码可知,Presto会启一个后台线程,每隔一定时间(默认20s)会检查一次codecache的使用率,当使用率大于一定的值时,会打印该日志,并显式调用System.gc()。
而该类的作用,注释也说的很清楚了,即用于绕过java 8 (8u45+)中关于code cache管理的bug(一旦code cache满了,JIT就停止编译了)。通过强制触发一次GC,来腾出空间,避免code cache填满。
我们知道System.gc()用于建议JVM进行Full GC。然而通过jstat观察发现,实际情况Minor GC的频率很高,但是Major GC的次数为0。
2. 查阅资料
(1) https://groups.google.com/forum/#!topic/presto-users/inF0oLvOfqo
上文中作者最终修改CodeCacheSize为600M、code-cache-collection-threshold为60,情况好转。他们的code cache一般在100M到230M, 不会超过配置的值: 600* 0.6 = 360M。
(2) https://news.ycombinator.com/item?id=12505517
上文中说到Presto is a SQL query engine that generates code for each query (a SQL query is effectively a program), so it can need a lot of codecache depending on the query rate and concurrency.
也就是presto会产生大量的类,也就需要jvm进行定期清理code cache。
由于code cache在方法区,只有Major GC才能够清理code cache。
3. 解决办法
检查当前配置
通过以下2种方法都可以查询当前配置的code cache初始值与最大值。默认情况下,初始值为2.4MB,最大值为240MB。
java -XX:+PrintFlagsFinal -version -server | grep ReservedCodeCacheSizejava -XX:+PrintCodeCache -version
而当前使用的量,就得通过jmx查询了。好在presto自身提供了对jmx的查询支持。
打开presto,执行:
use jmx.current;select * from "java.lang:type=memorypool,name=code cache";
修改配置
由于使用量一般在120MB左右,所以我设置CodeCacheSize为300M,code-cache-collection-threshold为60。300*0.6=180MB,满足要求。
(1)在config.properties文件添加code-cache-collection-threshold=60
。
(2)在jvm.config添加-XX:ReservedCodeCacheSize=300M
。
参考资料
http://openjdk.5641.n7.nabble.com/JIT-stops-compiling-after-a-while-java-8u45-td259603.html
https://groups.google.com/forum/#!topic/presto-users/inF0oLvOfqo
https://news.ycombinator.com/item?id=12505517
- Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs
- 5 reasons to avoid code comments
- C#中将大量不变的数据放入cache中
- how to avoid css and js cache in UIWebView
- windows2008 安全日志出现大量帐号登录失败的解决办法
- JAVA中JVM的GC日志解析
- JAVA中JVM的GC日志解析
- Hbase avoid full gc
- 网络安全:PR Source code Build & to avoid killing
- avoid cache in jsp
- 突然出现大量的
- 编程中遇到的Bugs
- 日志中出现大量Minact-Scn Master-Status: Grec-Scn Messages 信息
- mysql的processlist中出现大量的query end状态
- Presto中Queue的使用总结
- Java中GC日志参数
- FreeBSD服务器端代码中出现大量的defunct进程
- 为什么textarea中出现大量的空格和回车
- reids事务的伪原子性
- JavaScript数组
- 其他对象—— Date 和 Calendar 获取修改时间日期
- JavaScript中的数组
- 1946-计算奖金
- Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs
- 七.gradle的构建生命周期
- Nginx与Apache的突出的优缺点比较
- python基础学习
- 简单聊天室socket.io实现
- Trie(前缀树,字典树)
- JS 实现遍历某一磁盘文件夹下目录的功能
- JS数组
- Linux进程间通信之POSIX共享内存