Java -verbose:gc 性能影响?
只是想知道启用详细 GC 是否会对应用程序的性能产生任何影响。
我的猜测是不是。
我知道启用详细 GC 可以输出相当多的数据,并且想知道这实际上会对性能产生任何影响吗?
Just wondering if enabling verbose GC would have any effect on the performance of an application.
My guess is no not really.
I know that enabling verbose GC can output a fair bit data and was wondering is this realistically going to have any effect on performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
任何输出到文件/控制台的内容都会产生一些 I/O 开销。在每个垃圾收集事件上增加几毫秒的延迟肯定会对性能产生一些影响。
但实际上,您的应用程序必须经历很多这些过程,并且在您注意到之前承受相当大的负载。不经过测试很难判断。
Anything that outputs to file/console will incur some I/O overhead. Tacking an extra couple ms latency onto every garbage collection event certainly could have some effect on performance.
Realistically speaking though, your application would have to be going through a lot of them and be under quite some load before you'd notice. It's very hard to tell without testing.
以下是 IBM 对此的一些性能基准。两者都表明,在其基准场景中,详细 GC 的开销非常小:
当然,这是在 IBM JVM 上进行的,因此 Hotspot 的结果可能会有所不同。然而,与 IBM JVM 一样,写入日志的大多数指标可能已经出于优化原因在内部计算,因此唯一的额外开销是将已计算的数据写入日志的行为。因此,正如 WDS 所说,在开销开始对整体性能产生重大影响之前,您必须以令人难以置信的频率进行收集。
Here are some performance benchmarks on this from IBM. Both indicate that, in their benchmark scenarios, that the overhead of verbose GC was pretty minuscule:
This is, of course, on the IBM JVM, so results may differ for Hotspot. However, as with the IBM JVM, most of the metrics that get written to the log are likely internally computed for optimization reasons already, so the only additional overhead would be the act of writing the already-computed data to the log. So as WDS said, you'd have to be collecting with incredible frequency before that overhead started to make a significant dent in your overall performance.