RFR: 8339290: Optimize ClassFile Utf8EntryImpl#writeTo [v17]
Shaojin Wen
swen at openjdk.org
Tue Sep 3 23:08:20 UTC 2024
On Tue, 3 Sep 2024 16:27:58 GMT, Shaojin Wen <swen at openjdk.org> wrote:
>> Use fast path for ascii characters 1 to 127 to improve the performance of writing Utf8Entry to BufferWriter.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> optimize for utf16
5d2e88fd9d808ec636b3dc7eb3e642ee864b1655 This version has resolved the startup performance regression in non-LATIN1 scenarios, and works well in scenarios where COMPACT_STRINGS=false or UTF16 strings with mostly ASCII characters in the prefix.
## 1. This intermediate mode
### 1.1 Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
# baseline
git checkout 5d2e88fd9d808ec636b3dc7eb3e642ee864b1655
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint"
# current
git checkout 059bece2b1b4aac644ee5e3c3c69246bd7cf50b6
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint"
### 1.2 MacBook M1 Pro Performance Numbers
-# baseline
-Benchmark (charType) Mode Cnt Score Error Units
-Utf8EntryWriteTo.writeTo ascii avgt 9 1509448.291 ? 2654.329 ns/op
-Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 1583379.661 ? 4149.880 ns/op
-Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 2197701.771 ? 13988.343 ns/op
-Utf8EntryWriteTo.writeTo emoji avgt 9 2271586.139 ? 5295.697 ns/op
+# current
+Benchmark (charType) Mode Cnt Score Error Units
+Utf8EntryWriteTo.writeTo ascii avgt 9 178505.438 ? 4274.523 ns/op
+Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 211906.736 ? 1033.539 ns/op
+Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 1303843.386 ? 3763.852 ns/op
+Utf8EntryWriteTo.writeTo emoji avgt 9 1360258.109 ? 4651.772 ns/op
| | charType | baseline | current | delta |
| --- | --- | --- | --- | --- |
| Utf8EntryWriteTo.writeTo | ascii | 1509448.291 | 178505.438 | 745.60% |
| Utf8EntryWriteTo.writeTo | utf8_2_bytes | 1583379.661 | 211906.736 | 647.21% |
| Utf8EntryWriteTo.writeTo | utf8_3_bytes | 2197701.771 | 1303843.386 | 68.56% |
| Utf8EntryWriteTo.writeTo | emoji | 2271586.139 | 1360258.109 | 67.00% |
## 2. TieredStopAtLevel=1
### 2.1 Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
# baseline
git checkout 5d2e88fd9d808ec636b3dc7eb3e642ee864b1655
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint -XX:TieredStopAtLevel=1"
# current
git checkout 059bece2b1b4aac644ee5e3c3c69246bd7cf50b6
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo" MICRO="VM_OPTIONS=-Xint -XX:TieredStopAtLevel=1"
### 2.2 MacBook M1 Pro Performance Numbers
-# baseline
-Benchmark (charType) Mode Cnt Score Error Units
-Utf8EntryWriteTo.writeTo ascii avgt 9 23496.089 ? 200.645 ns/op
-Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 24994.492 ? 221.328 ns/op
-Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 24572.165 ? 58.997 ns/op
-Utf8EntryWriteTo.writeTo emoji avgt 9 25345.417 ? 65.883 ns/op
+# current
+Benchmark (charType) Mode Cnt Score Error Units
+Utf8EntryWriteTo.writeTo ascii avgt 9 7949.429 ? 33.514 ns/op
+Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 8661.021 ? 55.333 ns/op
+Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 18511.109 ? 18.346 ns/op
+Utf8EntryWriteTo.writeTo emoji avgt 9 19239.642 ? 78.234 ns/op
| | charType | baseline | current | delta |
| --- | --- | --- | --- | --- |
| Utf8EntryWriteTo.writeTo | ascii | 23496.089 | 7949.429 | 195.57% |
| Utf8EntryWriteTo.writeTo | utf8_2_bytes | 24994.492 | 8661.021 | 188.59% |
| Utf8EntryWriteTo.writeTo | utf8_3_bytes | 24572.165 | 18511.109 | 32.74% |
| Utf8EntryWriteTo.writeTo | emoji | 25345.417 | 19239.642 | 31.74% |
## 3. Non-JVM Options
### 3.1 Script
git remote add wenshao git at github.com:wenshao/jdk.git
git fetch wenshao
# baseline
git checkout 5d2e88fd9d808ec636b3dc7eb3e642ee864b1655
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo"
# current
git checkout 059bece2b1b4aac644ee5e3c3c69246bd7cf50b6
make test TEST="micro:java.lang.classfile.Utf8EntryWriteTo"
### 3.2 MacBook M1 Pro Performance Numbers
-# baseline
-Benchmark (charType) Mode Cnt Score Error Units
-Utf8EntryWriteTo.writeTo ascii avgt 9 15178.781 ? 38.239 ns/op
-Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 16335.573 ? 288.536 ns/op
-Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 16008.245 ? 47.895 ns/op
-Utf8EntryWriteTo.writeTo emoji avgt 9 16619.964 ? 161.419 ns/op
+# current
+Benchmark (charType) Mode Cnt Score Error Units
+Utf8EntryWriteTo.writeTo ascii avgt 9 4200.584 ? 82.228 ns/op
+Utf8EntryWriteTo.writeTo utf8_2_bytes avgt 9 5019.010 ? 20.490 ns/op
+Utf8EntryWriteTo.writeTo utf8_3_bytes avgt 9 7811.282 ? 27.938 ns/op
+Utf8EntryWriteTo.writeTo emoji avgt 9 8106.677 ? 134.932 ns/op
| | charType | baseline | current | delta |
| --- | --- | --- | --- | --- |
| Utf8EntryWriteTo.writeTo | ascii | 15178.781 | 4200.584 | 261.35% |
| Utf8EntryWriteTo.writeTo | utf8_2_bytes | 16335.573 | 5019.010 | 225.47% |
| Utf8EntryWriteTo.writeTo | utf8_3_bytes | 16008.245 | 7811.282 | 104.94% |
| Utf8EntryWriteTo.writeTo | emoji | 16619.964 | 8106.677 | 105.02% |
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20772#issuecomment-2327597330
More information about the core-libs-dev
mailing list