RFR: 8342975: C2: Micro-optimize PhaseIdealLoop::Dominators()

Dean Long dlong at openjdk.org
Thu Oct 24 23:24:04 UTC 2024


On Thu, 24 Oct 2024 17:10:42 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> Noticed this while looking at Leyden profiles. C2 seems to spend considerable time doing in this loop. The disassembly shows this loop is fairly hot. Replacing the initialization with memset, while touching more memory, is apparently faster. memset is also what we normally do around C2 for arena-allocated data. We seem to touch a lot of these structs later on, so pulling them to cache with memset is likely "free". 
> 
> It also looks like current initialization misses initializing the last element (at `C->unique()+1`).
> 
> I'll put performance data in separate comment.

src/hotspot/share/opto/domgraph.cpp line 413:

> 411:   // Note: Tarjan uses 1-based arrays
> 412:   NTarjan *ntarjan = NEW_RESOURCE_ARRAY(NTarjan,C->unique()+1);
> 413:   // Initialize all fields for safety.

This is also a performance optimization so the comment should probably say so, so we remember not to change it back to a loop later on.  It might be nice to have NEW_RESOURCE_ARRAY do the initialization for us, like calloc.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21690#discussion_r1815802767


More information about the hotspot-compiler-dev mailing list