G1 garbage collection Ext Root Scanning time increases due to Class.forName (Problem, Solution, and Patch)
Ashley Taylor
ashley.taylor at sli-systems.com
Tue Jul 9 15:17:48 PDT 2013
Hello
We have an application that makes heavy use of an apache API that uses Class.forName.
Using this method call we have noticed is that over time the "Ext Root Scanning" aspect of the G1 garbage collector time increased linearly.
Working with John Cuthbertson from the hotspot-gc mailing list we tracked this down to the Dictionary thread within the garbage collector.
https://www.dropbox.com/s/7s7gishn8mxtote/G1Checker.java reproduces this issue, to see the issue run it with the following jvm options
-XX:+PrintGCDetails -XX:+UseG1GC
Watch the Ext Root Scanning time and a single thread will start to climb.
We propose that when loading a class in a new classloader using Class.forName it will create a reference in the Dictionary table even when the class is present in the Dictionary table due to a parent classloader.
We have created a patch https://www.dropbox.com/s/t7gepqsvksz77kv/Class.diff to the Class.forName method that fixes this bug by using the same approach as UrlClassLoader.loadClass
which recursively tries to load the given class in its parent classloader first.
The only potential change in behaviour that we could imagine is to how static objects within the class get referenced,
have creating some unit tests have confirmed that the behaviour is identical after the patch.
https://www.dropbox.com/s/wf8rfa53jl7o5zg/ClassLoaderTests.java
https://www.dropbox.com/s/y5ir6x927niu2ax/Loaded.java
We have been using this patch in production now for the last couple of month with no issues and would like to see it adopted so we can stop using a custom build.
Cheers,
Ashley Taylor
Software Engineer
Email: ashley.taylor at sli-systems.com<mailto:ashley.taylor at sli-systems.com>
Website: www.sli-systems.com<http://www.sli-systems.com/>
Blog: blog.sli-systems.com<http://blog.sli-systems.com/>
Podcast: EcommercePodcast.com<http://ecommercepodcast.com/>
Twitter: www.twitter.com/slisystems<http://www.twitter.com/slisystems>
[sli_logo_2011]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130709/0a81a063/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 8602 bytes
Desc: image001.png
Url : http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130709/0a81a063/image001-0001.png
More information about the hotspot-runtime-dev
mailing list