How should I use -XX:PreTouchParallelChunkSize=?

Thomas Schatzl thomas.schatzl at oracle.com
Mon Feb 28 10:32:42 UTC 2022


Hi,

On 26.02.22 01:36, Peter Kessler OS wrote:
> How should I use -XX:PreTouchParallelChunkSize=?
> 
> I am using an Ampere Altra, running Oracle Linux Server release 8.5, 
> that has 64KB pages and 524288KB huge pages.  If I run a program with 
> enough logging, I see, for example,
[...]
> If I gather the times to the "Version" line for various releases of the 
> OpenJDK and various sizes of -XX:PreTouchParallelChunkSize=, I get
> 
>                                  -XX:PreTouchParallelChunkSize=
> 
>      JDK                   4k     64k   2048k   4096k   524288k  1048576k
> 
>      -----------------  -----   -----   -----   -----   -------  --------
> 
>      jdk-15.0.2         3.434   3.469   3.469   3.508     3.467     3.434
> 
>      jdk-17.0.2         0.806   0.806   0.805   0.804     0.836     0.844
> 
>      jdk-18-ea+34-2083  0.803   0.802   0.802   0.833     0.802     0.868
> 
>      jdk-19-ea+8-441    0.806   0.849   0.803   0.803     0.803     0.846
> 
> showing seconds for the median of 7 runs.  It looks like jdk-15.0.2 was 
> not good at parallelizing pretouching of the heap.  Later JDKs look like 
> they parallelize the pretouching of the heap, but it does not matter 
> much what the setting, or non-setting, of -XX:PreTouchParallelChunkSize= is.

It sets the size of memory a single thread gets to pretouch at once 
before asking for more work.

With a sufficiently large value, all is fine, the overhead of grabbing 
new chunks (and iterating over them) is negligible compared to actual 
commit work.

As demonstration, with

bin/java -Xmx40g -Xms40g -XX:+AlwaysPreTouch -XX:+UseG1GC 
-Xlog:gc+init=info,gc+heap=debug,gc=info:stdout 
-XX:PreTouchParallelChunkSize=2m -version

[0.034s][debug][gc,heap] Running G1 PreTouch with 18 workers for 10240 
work units pre-touching 42949672960B.
[2.132s][debug][gc,heap] Running G1 PreTouch with 18 workers for 160 
work units pre-touching 671088640B.

but with -XX:PreTouchParallelChunkSize=4k (which is obviously a bad 
value) I get

[0.030s][debug][gc,heap] Running G1 PreTouch with 18 workers for 
10485760 work units pre-touching 42949672960B.
[3.570s][debug][gc,heap] Running G1 PreTouch with 18 workers for 163840 
work units pre-touching 671088640B.


> 
> My question is: what difference does setting 
> -XX:PreTouchParallelChunkSize= make?  That is: is there some point to 
> setting it at all?

The default values seem to be okay, so probably not :)

Hth,
   Thomas


More information about the hotspot-gc-use mailing list