G1 garbage collection Ext Root Scanning time increases due to Class.forName (Problem, Solution, and Patch)

Ioi Lam ioi.lam at oracle.com
Fri Jul 12 18:15:48 PDT 2013


On 07/12/2013 11:08 AM, Ioi Lam wrote:
> On 07/12/2013 12:22 AM, Thomas Schatzl wrote:
>> Hi,
>>
>> On Thu, 2013-07-11 at 14:39 -0700, Ioi Lam wrote:
>>> While looking at this, I found a small optimization opportunity:
>>>
>>>      void Dictionary::oops_do(OopClosure* f) {
>>>        for (int index = 0; index < table_size(); index++) {
>>>          for (DictionaryEntry* probe = bucket(index);
>>>                                probe != NULL && probe->pd_set() !=
>>> NULL;
>>>                                probe = probe->next()) {
>>>            probe->protection_domain_set_oops_do(f);
>>>          }
>>>        }
>>>      }
>>>
>>> We can sort each bucket so that all the classes that do NOT have a
>>> protection domain are placed at the end of the list, so we can skip
>>> them
>>> easily. However, this won't save too much time, as the GC bottleneck
>>> (at least with the original test case) seems to be here:
>>    the CR athttp://bugs.sun.com/view_bug.do?bug_id=8003420  comes to my
>> mind every time somebody is talking about system dictionary performance:
>> this might be a worthwhile change; during young gc we could then just
>> skip the rest of the bucket as soon as the PD is NULL....
>>
>> Still the scanning time would be dependent on the number of buckets, so
>> if the allowable/typical bucket load is high, this might be worth
>> trying.
>>
>> Just an idea,
>> Thomas
> |Currently all classes loaded outside of the boot loader will have a 
> protection domain -- so even if we sort the buckets, if you have lots 
> of classes loaded, most of them will be non-boot classes so this 
> optimization won't buy you much.||
> ||
> ||Anyway, many classes share the same protection domains. In many 
> cases there's just a single protection domain for the entire app (I 
> think :-)||||
> |
>
>     |ProtectionDomain  (file:/scratch/iklam/tmp/ <no signer
>     certificates>)|||
>     ||| sun.misc.Launcher$AppClassLoader at 1bc081f|||
>     ||| <no principals>|||
>     ||| java.security.Permissions at 1d742a1 (|||
>     ||| ("java.lang.RuntimePermission" "exitVM")|||
>     ||| ("java.io.FilePermission" "/scratch/iklam/tmp/-" "read")|||
>     |||)|||
>     ||
>
> |So perhaps we should keep a hashtable of protection domains, and each 
> DictionaryEntry just holds a C pointer to a entry to this table.
>
> We need to GC this table during class unloading, but that should be 
> straight forward.|

|I've created a very rough patch for this (SA is broken, etc):||
||
||http://cr.openjdk.java.net/~iklam/8003420/dict_pd_set_001/ 
<http://cr.openjdk.java.net/%7Eiklam/8003420/dict_pd_set_001/>||
||
||Eclipse runs, and class unloading seems to work. Also, by very 
unscientific test, it seems to work faster:||
||
||BEFORE||
||$java . -XX:+PrintGCDetails -XX:+UseG1GC G1Checker | grep Ext||
||      [Ext Root Scanning (ms): Min: 0.2, Avg: 0.7, Max: 2.2, Diff: 
2.0, Sum: 5.4]||
||      [Ext Root Scanning (ms): Min: 0.1, Avg: 0.7, Max: 2.5, Diff: 
2.3, Sum: 5.5]||
||      [Ext Root Scanning (ms): Min: 0.2, Avg: 1.0, Max: 4.5, Diff: 
4.4, Sum: 7.9]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 1.7, Max: 7.8, Diff: 
7.7, Sum: 13.9]||
||      [Ext Root Scanning (ms): Min: 0.1, Avg: 3.3, Max: 14.4, Diff: 
14.2, Sum: 26.1]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 5.6, Max: 26.1, Diff: 
26.1, Sum: 44.9]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 13.1, Max: 66.9, Diff: 
66.9, Sum: 105.0]||<<<<
||||||||
||AFTER:||
||$java . -XX:+PrintGCDetails -XX:+UseG1GC G1Checker | grep Ext||
||      [Ext Root Scanning (ms): Min: 0.1, Avg: 0.4, Max: 1.6, Diff: 
1.5, Sum: 3.2]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 0.5, Max: 3.1, Diff: 
3.1, Sum: 4.0]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 0.5, Max: 3.2, Diff: 
3.2, Sum: 4.0]||
||      [Ext Root Scanning (ms): Min: 0.1, Avg: 1.0, Max: 5.8, Diff: 
5.7, Sum: 7.6]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 1.4, Max: 10.1, Diff: 
10.1, Sum: 11.5]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 3.1, Max: 24.2, Diff: 
24.2, Sum: 25.0]||
||      [Ext Root Scanning (ms): Min: 0.0, Avg: 4.4, Max: 34.6, Diff: 
34.6, Sum: 35.6] <<<<||
||
||Where can I find a better benchmark?

Thanks
- Ioi
|




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130712/5a4cca0e/attachment-0001.html 


More information about the hotspot-runtime-dev mailing list