RFR: 8259699: Reduce char[] copying in URLEncoder.encode(String, Charset) [v3]
Claes Redestad
redestad at openjdk.java.net
Thu Jan 14 12:54:02 UTC 2021
On Thu, 14 Jan 2021 11:48:16 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> @cl4es SB brings pessimization both for time and memory, try `org.openjdk.bench.java.net.URLEncodeDecode`:
>> master
>> (count) (maxLength) (mySeed) Mode Cnt Score Error Units
>> testEncodeUTF8 1024 1024 3 avgt 25 8.573 ? 0.023 ms/op
>> testEncodeUTF8:?gc.alloc.rate 1024 1024 3 avgt 25 1202.896 ? 3.225 MB/sec
>> testEncodeUTF8:?gc.alloc.rate.norm 1024 1024 3 avgt 25 11355727.904 ? 196.249 B/op
>> testEncodeUTF8:?gc.churn.G1_Eden_Space 1024 1024 3 avgt 25 1203.785 ? 6.240 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Eden_Space.norm 1024 1024 3 avgt 25 11364143.637 ? 52830.222 B/op
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space 1024 1024 3 avgt 25 0.008 ? 0.001 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space.norm 1024 1024 3 avgt 25 77.088 ? 9.303 B/op
>> testEncodeUTF8:?gc.count 1024 1024 3 avgt 25 1973.000 counts
>> testEncodeUTF8:?gc.time 1024 1024 3 avgt 25 996.000 ms
>>
>> enc
>> (count) (maxLength) (mySeed) Mode Cnt Score Error Units
>> testEncodeUTF8 1024 1024 3 avgt 25 7.931 ? 0.006 ms/op
>> testEncodeUTF8:?gc.alloc.rate 1024 1024 3 avgt 25 965.347 ? 0.736 MB/sec
>> testEncodeUTF8:?gc.alloc.rate.norm 1024 1024 3 avgt 25 8430590.163 ? 7.213 B/op
>> testEncodeUTF8:?gc.churn.G1_Eden_Space 1024 1024 3 avgt 25 966.373 ? 5.248 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Eden_Space.norm 1024 1024 3 avgt 25 8439563.689 ? 47282.178 B/op
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space 1024 1024 3 avgt 25 0.007 ? 0.001 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space.norm 1024 1024 3 avgt 25 60.949 ? 8.405 B/op
>> testEncodeUTF8:?gc.count 1024 1024 3 avgt 25 1715.000 counts
>> testEncodeUTF8:?gc.time 1024 1024 3 avgt 25 888.000 ms
>>
>> stringBuilder
>> (count) (maxLength) (mySeed) Mode Cnt Score Error Units
>> testEncodeUTF8 1024 1024 3 avgt 25 8.115 ? 0.110 ms/op
>> testEncodeUTF8:?gc.alloc.rate 1024 1024 3 avgt 25 1259.267 ? 16.716 MB/sec
>> testEncodeUTF8:?gc.alloc.rate.norm 1024 1024 3 avgt 25 11249391.875 ? 6.552 B/op
>> testEncodeUTF8:?gc.churn.G1_Eden_Space 1024 1024 3 avgt 25 1259.937 ? 17.232 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Eden_Space.norm 1024 1024 3 avgt 25 11255413.875 ? 43636.143 B/op
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space 1024 1024 3 avgt 25 0.007 ? 0.001 MB/sec
>> testEncodeUTF8:?gc.churn.G1_Survivor_Space.norm 1024 1024 3 avgt 25 59.461 ? 9.087 B/op
>> testEncodeUTF8:?gc.count 1024 1024 3 avgt 25 2236.000 counts
>> testEncodeUTF8:?gc.time 1024 1024 3 avgt 25 1089.000 ms
>> The reason seems to be single char `StringBuilder.append()` that apart from range check does encoding check and stores `char` as two bytes in `byte[]` in ASB
>
> Surprising, but thanks for checking!
No need to merge in changes in master unless there are conflicts or you want to do more changes of your own, they will be merged automatically on integration. But it seems the bots need you to do /integrate again
-------------
PR: https://git.openjdk.java.net/jdk/pull/1598
More information about the net-dev
mailing list