Java -verbose:gc Performance Implications?
Just wondering if enabling verbose GC would have any effect on the performance of an application.
My guess is no not really.
开发者_如何学CI know that enabling verbose GC can output a fair bit data and was wondering is this realistically going to have any effect on performance?
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.
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:
- https://www.ibm.com/developerworks/community/blogs/troubleshootingjava/entry/verbose_gc_performance?lang=en
- http://www.slideshare.net/cnbailey/websphere-technical-university-introduction-to-java-diagnostic-tools (on slide 17)
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.
精彩评论