RFR: 8273122: ZGC: Load forwarding entries without acquire semantics
Erik Österlund
eosterlund at openjdk.java.net
Tue Aug 31 08:36:23 UTC 2021
On Tue, 31 Aug 2021 07:50:27 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> > We usually do not relax things to rely on data dependency in C++ code, as the C++ standard gives us no guarantees that the data dependency will be retained in the generated machine code. It only gives threats that it might not work. In practice probably not, but still. So I don't know how I feel about this. Have you tried to use load consume instead? If that yields the same improvement, we can incorporate load_consume into HotSpot. I think that is an interesting experiment worth running first.
>
> FWIW, Shenandoah faces a similar thing (see #2496), but in a different direction: it started with "relaxed" for fwdptr accesses. Bumping that up to "acquire" for GC code costs quite a bit. I think I convinced myself (to be fair, with a significant amount of handwaving) that while dangerous, it still works. Yes, "consume" would be nice as the additional safety measure, but I don't think any current C++ compiler properly implements it, and instead it bumps "consume" to "acquire", leaving you at the same performance place. That is to say that "consume" experiments might be futile at this moment.
I also recall reading that due to the complexity of implementing consume correctly, compilers chose to implement it as acquire instead. But that was years ago and I was kind of hoping something would have changed there. But maybe that is still the state of the art a decade after its introduction. It's a pity because all we want is for the compiler to not do anything outrageously weird such as breaking trivial data dependencies with some hypothetical bizarre address guessing optimization, that I'm sure nobody does anyway. Sigh...
-------------
PR: https://git.openjdk.java.net/jdk/pull/5298
More information about the hotspot-gc-dev
mailing list