日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs

發(fā)布時(shí)間:2024/2/28 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

問題描述:

Presto日志中出現(xiàn)大量的

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源碼

出現(xiàn)該條日志的代碼為

// 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會(huì)啟一個(gè)后臺(tái)線程,每隔一定時(shí)間(默認(rèn)20s)會(huì)檢查一次codecache的使用率,當(dāng)使用率大于一定的值時(shí),會(huì)打印該日志,并顯式調(diào)用System.gc()。

而該類的作用,注釋也說的很清楚了,即用于繞過java 8 (8u45+)中關(guān)于code cache管理的bug(一旦code cache滿了,JIT就停止編譯了)。通過強(qiáng)制觸發(fā)一次GC,來騰出空間,避免code cache填滿。

我們知道System.gc()用于建議JVM進(jìn)行Full GC。然而通過jstat觀察發(fā)現(xiàn),實(shí)際情況Minor GC的頻率很高,但是Major GC的次數(shù)為0。

2. 查閱資料

(1) https://groups.google.com/forum/#!topic/presto-users/inF0oLvOfqo
上文中作者最終修改CodeCacheSize為600M、code-cache-collection-threshold為60,情況好轉(zhuǎn)。他們的code cache一般在100M到230M, 不會(huì)超過配置的值: 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會(huì)產(chǎn)生大量的類,也就需要jvm進(jìn)行定期清理code cache。
由于code cache在方法區(qū),只有Major GC才能夠清理code cache。

3. 解決辦法

檢查當(dāng)前配置

通過以下2種方法都可以查詢當(dāng)前配置的code cache初始值與最大值。默認(rèn)情況下,初始值為2.4MB,最大值為240MB。

java -XX:+PrintFlagsFinal -version -server | grep ReservedCodeCacheSize java -XX:+PrintCodeCache -version

而當(dāng)前使用的量,就得通過jmx查詢了。好在presto自身提供了對(duì)jmx的查詢支持。
打開presto,執(zhí)行:

use jmx.current; select * from "java.lang:type=memorypool,name=code cache";

修改配置

由于使用量一般在120MB左右,所以我設(shè)置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

總結(jié)

以上是生活随笔為你收集整理的Presto日志中出现大量的Triggering GC to avoid Code Cache eviction bugs的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。