When UseCompactObjectHeaders is enabled, all Klasses in the AOT cache must be 1024-byte aligned. This leads to many unused gaps in the "rw" region of the AOT cache, resulting in larger footprint:
$ java -Xlog:aot -cp HelloWorld.jar -XX:AOTCacheOutput=hw.aot -XX:-UseCompactObjectHeaders HelloWorld
[...]
[0.148s][info][aot] Shared file region (rw) 0: 3326712 bytes, addr 0x0000000800001000 file offset 0x00001000 crc 0x7995b610
[0.149s][info][aot] Shared file region (ro) 1: 5650040 bytes, addr 0x000000080032e000 file offset 0x0032e000 crc 0x0166880c
[0.150s][info][aot] Shared file region (ac) 4: 377000 bytes, addr 0x0000000800892000 file offset 0x00892000 crc 0x1ec195f7
[0.152s][info][aot] Shared file region (bm) 2: 143064 bytes, addr 0x0000000000000000 file offset 0x008ef000 crc 0x344026eb
[0.153s][info][aot] Shared file region (hp) 3: 766864 bytes, addr 0x00000007ff800000 file offset 0x00912000 crc 0x3e5c19e7
$ java -Xlog:aot -cp HelloWorld.jar -XX:AOTCacheOutput=hw.aot -XX:+UseCompactObjectHeaders HelloWorld
[...]
[0.151s][info][aot] Shared file region (rw) 0: 3787304 bytes, addr 0x0000000800001000 file offset 0x00001000 crc 0x3df97e6e
[0.153s][info][aot] Shared file region (ro) 1: 5650280 bytes, addr 0x000000080039e000 file offset 0x0039e000 crc 0xeb082792
[0.154s][info][aot] Shared file region (ac) 4: 377800 bytes, addr 0x0000000800902000 file offset 0x00902000 crc 0x3ddb3c7f
[0.156s][info][aot] Shared file region (bm) 2: 148536 bytes, addr 0x0000000000000000 file offset 0x0095f000 crc 0xab33a5ca
[0.156s][info][aot] Shared file region (hp) 3: 716440 bytes, addr 0x00000007ff800000 file offset 0x00984000 crc 0x61380d0e
Proposed fix:
Sort the objects in the "rw" region so that the gaps can be filled with smaller objects.
$ java -Xlog:aot -cp HelloWorld.jar -XX:AOTCacheOutput=hw.aot -XX:-UseCompactObjectHeaders HelloWorld
[...]
[0.148s][info][aot] Shared file region (rw) 0: 3326712 bytes, addr 0x0000000800001000 file offset 0x00001000 crc 0x7995b610
[0.149s][info][aot] Shared file region (ro) 1: 5650040 bytes, addr 0x000000080032e000 file offset 0x0032e000 crc 0x0166880c
[0.150s][info][aot] Shared file region (ac) 4: 377000 bytes, addr 0x0000000800892000 file offset 0x00892000 crc 0x1ec195f7
[0.152s][info][aot] Shared file region (bm) 2: 143064 bytes, addr 0x0000000000000000 file offset 0x008ef000 crc 0x344026eb
[0.153s][info][aot] Shared file region (hp) 3: 766864 bytes, addr 0x00000007ff800000 file offset 0x00912000 crc 0x3e5c19e7
$ java -Xlog:aot -cp HelloWorld.jar -XX:AOTCacheOutput=hw.aot -XX:+UseCompactObjectHeaders HelloWorld
[...]
[0.151s][info][aot] Shared file region (rw) 0: 3787304 bytes, addr 0x0000000800001000 file offset 0x00001000 crc 0x3df97e6e
[0.153s][info][aot] Shared file region (ro) 1: 5650280 bytes, addr 0x000000080039e000 file offset 0x0039e000 crc 0xeb082792
[0.154s][info][aot] Shared file region (ac) 4: 377800 bytes, addr 0x0000000800902000 file offset 0x00902000 crc 0x3ddb3c7f
[0.156s][info][aot] Shared file region (bm) 2: 148536 bytes, addr 0x0000000000000000 file offset 0x0095f000 crc 0xab33a5ca
[0.156s][info][aot] Shared file region (hp) 3: 716440 bytes, addr 0x00000007ff800000 file offset 0x00984000 crc 0x61380d0e
Proposed fix:
Sort the objects in the "rw" region so that the gaps can be filled with smaller objects.
- blocks
-
JDK-8360700 Implement Compact Object Headers enabled by default
-
- Open
-