RFR: JDK-8294266: Add a way to pre-touch java thread stacks [v4]

Robbin Ehn rehn at openjdk.org
Fri Nov 25 11:07:34 UTC 2022


On Mon, 14 Nov 2022 10:16:58 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> When doing performance- and footprint analysis, `AlwaysPreTouch` option is very handy for reducing noise. It would be good to have a similar option for pre-touching thread stacks. In addition to reducing noise, it can serve as worst-case test for thread costs, as well as a test for NMT regressions.
>> 
>> Patch adds a new diagnostic switch, `AlwaysPreTouchStacks`, as a companion switch to `AlwaysPreTouch`. Touching is super-simple using `alloca()`. Also, regression test.
>> 
>> Examples:
>> 
>> NMT, thread stacks, 10000 Threads, default:
>> 
>> 
>> -                    Thread (reserved=10332400KB, committed=331828KB)                                       
>>                             (thread #10021)                                                                 
>>                             (stack: reserved=10301560KB, committed=300988KB)                                
>>                             (malloc=19101KB #60755)                                                         
>>                             (arena=11739KB #20037)                                                          
>> 
>> 
>> NMT, thread stacks, 10000 Threads, +AlwaysPreTouchStacks:
>> 
>> 
>> -                    Thread (reserved=10332400KB, committed=10284360KB)                        
>>                             (thread #10021)                                                    
>>                             (stack: reserved=10301560KB, committed=10253520KB)                 
>>                             (malloc=19101KB #60755)                                            
>>                             (arena=11739KB #20037)
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
> 
>   test changes, comment change

I have seen some workload where just one or two threads are using large stacks and the majority is not.
I.e. -Xss256m and similar, having a few hundreds of threads and pre-touching both stacks and heap you may run out of physical pages and start swapping. It would be useful is such case to just pre-touch the first meg or so on the stack.

I thinking -Xss256m -XX:PreTouchStackSize=1m

Maybe it is not as useful as in my head...
Also I don't know if a user may retrieve good information about stack size usage.

I'll let you be the arbitrator.

I'll approve it as is, if this what you think is best, thanks.

-------------

Marked as reviewed by rehn (Reviewer).

PR: https://git.openjdk.org/jdk/pull/10403


More information about the hotspot-dev mailing list