RFR: 8339290: Optimize ClassFile Utf8EntryImpl#writeTo [v3]
Shaojin Wen
swen at openjdk.org
Mon Sep 2 15:45:20 UTC 2024
On Fri, 30 Aug 2024 18:46:08 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Suggestions from @cl4es, rename hasNegativeOrZeros to isLatin1GreaterThanZero
>
> If a non-ascii is in the middle or the end of a string, this patch may add an overhead. Offline benchmark results show that this actually brings a regression in the startup of a jetty server.
Thanks to @liach for providing new ideas for benchmarking. Here are the new performance data
## 1. TieredStopAtLevel=1
### 1.1 Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
# baseline
git checkout 12550c3ea58a6405de21cc185fa972378b534120
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint -XX:TieredStopAtLevel=1"
# current
git checkout 99143fdb3a11140d5c9f067c144629def344666d
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint -XX:TieredStopAtLevel=1"
### 1.2 MacBook M1 Pro Performance Numbers
-# baseline
-Benchmark (charType) Mode Cnt Score Error Units
-Utf8EntryWriteTo.writeTo ascii avgt 9 26818.441 ? 476.844 ns/op
-Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 33001.261 ? 78.130 ns/op
-Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 40134.337 ? 103.220 ns/op
-Utf8EntryWriteTo.writeTo emoji avgt 9 58745.488 ? 205.561 ns/op
+# current
+Benchmark (charType) Mode Cnt Score Error Units
+Utf8EntryWriteTo.writeTo ascii avgt 9 10795.072 ? 254.952 ns/op
+Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 14661.640 ? 64.254 ns/op
+Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 17129.657 ? 194.146 ns/op
+Utf8EntryWriteTo.writeTo emoji avgt 9 24167.056 ? 319.348 ns/op
| | charType | baseline | current | delta |
| --- | --- | --- | --- | --- |
| Utf8EntryWriteTo.writeTo | ascii | 26818.441 | 10795.072 | 148.43% |
| Utf8EntryWriteTo.writeTo | utf8_2_bytes | 33001.261 | 14661.640 | 125.09% |
| Utf8EntryWriteTo.writeTo | utf8_3_bytes | 40134.337 | 17129.657 | 134.30% |
| Utf8EntryWriteTo.writeTo | emoji | 58745.488 | 24167.056 | 143.08% |
## 2. Non-JVM Options
### 2.1 Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
# baseline
git checkout 12550c3ea58a6405de21cc185fa972378b534120
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo"
# current
git checkout 99143fdb3a11140d5c9f067c144629def344666d
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo"
### 2.2 MacBook M1 Pro Performance Numbers
-# baseline
-Benchmark (charType) Mode Cnt Score Error Units
-Utf8EntryWriteTo.writeTo ascii avgt 9 268.824 ? 2.834 ns/op
-Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 308.376 ? 1.581 ns/op
-Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 343.579 ? 1.331 ns/op
-Utf8EntryWriteTo.writeTo emoji avgt 9 463.350 ? 2.090 ns/op
+# current
+Benchmark (charType) Mode Cnt Score Error Units
+Utf8EntryWriteTo.writeTo ascii avgt 9 139.114 ? 0.873 ns/op
+Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 158.509 ? 0.772 ns/op
+Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 170.437 ? 2.442 ns/op
+Utf8EntryWriteTo.writeTo emoji avgt 9 268.832 ? 112.823 ns/op
| | charType | baseline | current | delta |
| --- | --- | --- | --- | --- |
| Utf8EntryWriteTo.writeTo | ascii | 268.824 | 139.114 | 93.24% |
| Utf8EntryWriteTo.writeTo | utf8_2_bytes | 308.376 | 158.509 | 94.55% |
| Utf8EntryWriteTo.writeTo | utf8_3_bytes | 343.579 | 170.437 | 101.59% |
| Utf8EntryWriteTo.writeTo | emoji | 463.350 | 268.832 | 72.36% |
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20772#issuecomment-2325008818
More information about the core-libs-dev
mailing list