RFR 8041565: JMX ObjectName could be refactored to save memory

Olivier Lagneau olivier.lagneau at oracle.com
Mon Apr 13 12:09:28 UTC 2015


Hi Jaroslav,

Looks good to me.

Nice to save 8 bytes on object name insatnces (~ 20%) !

Olivier

Le 13/04/2015 11:43, Jaroslav Bachorik a écrit :
> Please, review the following change
>
> Issue : https://bugs.openjdk.java.net/browse/JDK-8041565
> Webrev: http://cr.openjdk.java.net/~jbachorik/8041565/webrev.00
>
> In situations when there are 10s of thousands ObjectNname instances 
> around (enterprise setups etc.) the 3 separate internal boolean fields 
> can lead to a noticeable memory waste. Adding insult to the injury, 
> with the current field layout it is necessary to align the instances 
> by 4 bytes.
>
> When using JOL (http://openjdk.java.net/projects/code-tools/jol/) to 
> inspect the object layout we can see this:
>
> Before optimization (JDK8u40):
> ---
> javax.management.ObjectName object internals:
> OFFSET SIZE TYPE DESCRIPTION VALUE
>       0 12 (object header)| N/A
>      12 4 int ObjectName._domain_length N/A
>      16 1 boolean ObjectName._domain_pattern N/A
>      17 1 boolean ObjectName._property_list_pattern N/A
>      18 1 boolean ObjectName._property_value_pattern N/A
>      19 1 (alignment/padding gap) N/A
>      20 4 String ObjectName._canonicalName N/A
>      24 4 Property[] ObjectName._kp_array N/A
>      28 4 Property[] ObjectName._ca_array N/A
>      32 4 Map ObjectName._propertyList N/A
>      36 4 (loss due to the next object alignment)
> Instance size: 40 bytes (estimated, the sample instance is not available)
> Space losses: 1 bytes internal + 4 bytes external = 5 bytes total
> {noformat}
>
> After optimization (JDK9 internal build):
> ---
>
> javax.management.ObjectName object internals:
>  OFFSET SIZE TYPE DESCRIPTION VALUE
>       0 12 (object header) N/A
>      12 2 short ObjectName._domain_length N/A
>      14 1 byte ObjectName._pattern_flag N/A
>      15 1 (alignment/padding gap) N/A
>      16 4 String ObjectName._canonicalName N/A
>      20 4 Property[] ObjectName._kp_array N/A
>      24 4 Property[] ObjectName._ca_array N/A
>      28 4 Map ObjectName._propertyList N/A
> Instance size: 32 bytes (estimated, the sample instance is not available)
> Space losses: 1 bytes internal + 0 bytes external = 1 bytes total
>
>
> After optimization we can save 8 bytes per instance which can 
> translate to very interesting numbers on large installations.
>
>
> To achieve this the domain name length is set to be *short* instead of 
> *int* and the three booleans kept for the performance purposes are 
> encoded into one byte value (as proposed by the reporter, 
> Jean-Francois Denise).
>
> All the regression and JCK tests are passing after this change.
>
>
> Thanks,
>
> -JB-

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20150413/f0382c23/attachment-0001.html>


More information about the serviceability-dev mailing list