RFR: JDK-8197594: String#repeat

Peter Levart peter.levart at gmail.com
Thu Mar 1 11:50:35 UTC 2018


On 03/01/2018 03:13 AM, Paul Sandoz wrote:
> Hi Jim,
> Looks good. I like the power of 2 copying.

Is this really the fastest way? Say you are doing this:

String s = ... 64 bytes ...


...the last arraycopy will be copying 512 KiB from one part of memory to 
the other part. It means that the source 512 KiB range will not fit into 
L1 cache. Neither fully into L2 cache.

The fastest way might be to employ power-of-two copying until the range 
reaches L1 caches size / 2 for example (16 K ?) and then use the same 
source range repeatedly as a "stamp" until the rounded end.

What do you think?

Regards, Peter

More information about the core-libs-dev mailing list