[英]JVM Compile Time vs Code Cache
I've been benchmarking my app and analyzing it with JMC. 我一直在对我的应用程序进行基准测试并使用JMC进行分析。 I've noticed that under load, it performs quite a bit of JIT compiling. 我注意到在负载下,它执行了相当多的JIT编译。 If I send a large amount of transactions per second, the compile time spikes. 如果我每秒发送大量事务,则编译时间会激增。 The compile time always grows proportionally with any heavy load test against the app. 编译时间总是与针对应用程序的任何重负载测试成比例增长。
I've also observed that the Code Cache slowly rises as well. 我还观察到代码缓存也慢慢上升。 So I decided to raise the Code Cache reserve to 500MB to test. 所以我决定将代码缓存保留提高到500MB进行测试。 Bad move! 不好动! Now it's spending even more time performing JIT. 现在它花费更多时间执行JIT。
Then I explicitly disabled code cache flushing via -XX:-UseCodeCacheFlushing
. 然后我通过-XX:-UseCodeCacheFlushing
显式禁用了代码缓存刷新。 However, I noticed that the peak Code Cache usage is larger than the current size. 但是,我注意到代码缓存的峰值使用率大于当前大小。 This leads me to a couple of questions: 这引出了几个问题:
In HotSpot JVM all JIT-compiled methods stays in CodeCache until they are reclaimed. 在HotSpot JVM中,所有JIT编译的方法都保留在CodeCache中,直到它们被回收为止。 UseCodeCacheFlushing
affects reclamation of cold (but still valid) compiled methods. UseCodeCacheFlushing
影响冷(但仍然有效)编译方法的回收。 However, CodeCache may also contain obsolete or invalidated methods ("zombies") which are subject to purge at the next sweep cycle even with -XX:-UseCodeCacheFlushing
. 但是,CodeCache还可能包含过时或无效的方法(“僵尸”),即使使用-XX:-UseCodeCacheFlushing
,这些方法也会在下一个扫描周期进行清除。
There is a separate JVM flag -XX:-MethodFlushing
to prevent sweeping CodeCache altogether, including zombie methods. 有一个单独的JVM标志-XX:-MethodFlushing
来防止彻底扫描CodeCache,包括僵尸方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.