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

Gerard Ziemski gziemski at openjdk.org
Fri Mar 24 15:38:54 UTC 2023


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

Marked as reviewed by gziemski (Committer).

LGTM, just had a few questions...

src/hotspot/share/runtime/javaThread.cpp line 2085:

> 2083:   // from the current frame down to the start of the shadow zone.
> 2084:   const address end = _stack_overflow_state.shadow_zone_safe_limit();
> 2085:   if (is_in_full_stack(end)) {

Shouldn't we complain to the user here if false?

src/hotspot/share/runtime/javaThread.cpp line 2088:

> 2086:     char* p1 = (char*) alloca(1);
> 2087:     address here = (address) &p1;
> 2088:     if (is_in_full_stack(here) && here > end) {

Shouldn't we complain to the user here if false?

test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java line 54:

> 52: 
> 53:         int[] stackSizes = {
> 54:           1024 * 256, 1024 * 512, 1024 * 1024 * 3

I'm curious, how did you decide on these values?

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

PR Review: https://git.openjdk.org/jdk/pull/10403#pullrequestreview-1356952758
PR Comment: https://git.openjdk.org/jdk/pull/10403#issuecomment-1483006938
PR Review Comment: https://git.openjdk.org/jdk/pull/10403#discussion_r1147744801
PR Review Comment: https://git.openjdk.org/jdk/pull/10403#discussion_r1147744655
PR Review Comment: https://git.openjdk.org/jdk/pull/10403#discussion_r1147749637


More information about the hotspot-dev mailing list