[aarch64-port-dev ] RFR(s): AArch64: 8149080: Recoginize disjoint array copy in stub code
aph at redhat.com
Sun Feb 7 10:24:39 UTC 2016
On 06/02/16 11:52, Hui Shi wrote:
> Code sequence for backward and forward array copy is almost same
> except prefetch. Performance test is based on
> run with "java StringConcatTest 5000". I tried disabling prefetch
> and compare performance between backward and forward array copy (all
> forward with my patch, force all backward by commenting out branch
> to nooverlap target and force jshort_disjoint_copy generate conjoint
> copy), forward array copy is much faster than backward. backward is
> about 85s and forward copy is about 60s.
> This test is try to reflect common cases like string builder/buffer
> append and string concatenation, these are disjoint array copy and
> forward array copy is better than backward in following two aspects:
You're confusing me. String concatenation is a disjoint array copy.
Therefore it always copies forwards, does it not?
> 1. Forward array copy can prefetch dest address needed in next string
So can backwards array copy, surely.
> 2. Backward array copy might cause much more unaligned memory access in
> string append/concatenation.
Okay, I see. That is fixable: we can make sure that there are no
more misaligned accesses in either direction.
> Perform forward array copy when possible will not make things worse and
> benefit common cases like string append/concatenation. This is the original
> logic when generate conjoint array copy, this patch complete this logic by
> recognize all disjoint array copy. Does this make sense?
Yes, but it's a kludge. I'd much rather fix backwards copies so that
they were just as fast. If that's not possible then your patch may be
acceptable, but I think we should first try to fix backwards copies.
We should be able to fix this the *right way*, by using prefetch
instructions and making sure copies are aligned where possible. When
I did my testing misaligned fetches were quite fast, and it didn't
seem worth the effort to fix it.
But I'm really mystified by why String concatenation doesn't always
use forward copies anyway.
More information about the hotspot-compiler-dev