RFR: 8273122: ZGC: Load forwarding entries without acquire semantics

Hao Tang github.com+7947546+tanghaoth90 at openjdk.java.net
Thu Sep 2 03:48:32 UTC 2021


On Tue, 31 Aug 2021 11:25:46 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> As far as I know, Hotspot does not consistently use C++ atomics, so whether the compiler implements consume-as-acquire or any other aspect of the C++ memory model not does not really matter. Consequently, the code is full of undefined data races as far as the compiler is concerned. Compiler writers are aware of that and generally avoid optimizations that would break this memory-model-in-a-library approach (although there is of course no language specification that actually guarantees this).
>> 
>> I think that historically, the approach has been that when compiler optimizations make things go wrong, some sort of compiler barrier is added to the code. I assume the same thing could be done to implement an approximation to consume semantics.
>
>> As far as I know, Hotspot does not consistently use C++ atomics, so whether the compiler implements consume-as-acquire or any other aspect of the C++ memory model not does not really matter. Consequently, the code is full of undefined data races as far as the compiler is concerned. Compiler writers are aware of that and generally avoid optimizations that would break this memory-model-in-a-library approach (although there is of course no language specification that actually guarantees this).
>> 
>> I think that historically, the approach has been that when compiler optimizations make things go wrong, some sort of compiler barrier is added to the code. I assume the same thing could be done to implement an approximation to consume semantics.
> 
> We have not had access to C++ atomics for a long time. It's only rather recently that we upgraded past C++11. So I don't think the question of consume or acquire is irrelevant. If consume was to magically do what we want, in a way that is more standards compliant, then it would be a compelling reason to start upgrading our atomics. Given of course, that consume actually does do something other than to just bind to acquire.

@fisk @shipilev @fweimer-rh Thanks for your suggestions!

`load_consume` is better while simple `load` cannot retain the dependency. However, `load_consume` is unrealistic for now.

> #2496 also tries to optimize the Shenandoah paths that are penalized by acquires unnecessarily: heap updates after relocations are done. Maybe a similar partial relaxation would be possible for ZGC, e.g. for concurrent mark that does fixups.

Yes. ZGC also does fixups duration mutator-only phase. I am going to try using `load_acquire` during relocation phase and using `load` after relocations.

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

PR: https://git.openjdk.java.net/jdk/pull/5298



More information about the hotspot-gc-dev mailing list