RFR: 8282024: add EscapeAnalysis statistics under PrintOptoStatistics [v6]
aamarsh
duke at openjdk.java.net
Mon May 2 23:36:28 UTC 2022
On Sun, 10 Apr 2022 23:23:00 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> aamarsh has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>>
>> adding escape analysis and scalar replacement statistics
>
> src/hotspot/share/opto/compile.cpp line 2202:
>
>> 2200:
>> 2201: #ifndef PRODUCT
>> 2202: congraph()->update_escape_state(Atomic::load(&PhaseMacroExpand::_objs_scalar_replaced_counter) - _prev_scalar_replaced);
>
> I understand that you would like to add scalarized objects back to the snapshot, but this _objs_scalar_replaced_counter is a static counter as well. Two consecutive atomic loads are not helpful here because other C2 compiler threads can update it.
>
> I think we can a member data ConnectionGraph::_prev_scalar_replaced and increment it in mexp.eliminate_macro_nodes(); we keep _objs_scalar_replaced_counter but only atomic accumulate it at the end of ME phrase.
@navyxliu I followed the general idea of your advice and created _local_scalar_replaced, which gets added in compiler.cpp.
> src/hotspot/share/opto/escape.cpp line 116:
>
>> 114: invocation = C->congraph()->_invocation + 1;
>> 115: #ifndef PRODUCT
>> 116: // Reset counters when do_analysis is called again so objects are not double counted
>
> This does not look right either. 3 atomic words can't give you a safe transaction.
> I understand that you want to dedup across Iterative EAs. Snapshot is certainly a general solution but more complex.
>
> In our case, I feel all we need is to compensate those java objects which have been scalarized in previous iterations. One member data _prev_scalar_replaced, which remembers the number of scalarized objects, seems good enough. you can carry over this variable from the old to the new ConnectionGraph and add it back when the EA iterations end.
@navyxliu Again, to avoid this I added local counters to the compiler that reset with every do_analysis call and once EA is completed and the while loop is executed they are atomically added to the static counters.
> src/hotspot/share/opto/escape.cpp line 3795:
>
>> 3793:
>> 3794: void ConnectionGraph::print_statistics() {
>> 3795: tty->print_cr("No escape: %d", Atomic::load(&_no_escape_counter));
>
> This is just my suggestion. I would say that we keep each print_statistics() method oneliner.
> It will ease parsers. in Compile::print_statistics, most of them follow the pattern: phase: counter1, couter2, ...
> ```
> tty->print_cr("Peephole: peephole rules applied: %d", _total_peepholes);
@navyxliu Fixed! And I included a new example of how it prints above!
-------------
PR: https://git.openjdk.java.net/jdk/pull/8019
More information about the hotspot-compiler-dev
mailing list