-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Back port] 8310929: Optimization for integer/long toString #682
base: master
Are you sure you want to change the base?
[Back port] 8310929: Optimization for integer/long toString #682
Conversation
能提供一个性能测试案例吗? |
已经补上,dragoonwell11下怎么跑性能测试?
|
The performance test results of the latest version (PR Update 20 c0f42a7c ) are as follows: 1. aliyun_ecs_c8i.xlarge
-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Integers.toStringBig 500 avgt 15 6.800 ? 0.022 us/op
-Integers.toStringSmall 500 avgt 15 4.792 ? 0.021 us/op
-Integers.toStringTiny 500 avgt 15 3.757 ? 0.081 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Integers.toStringBig 500 avgt 15 5.894 ? 0.046 us/op (+15.37%)
+Integers.toStringSmall 500 avgt 15 4.027 ? 0.012 us/op (+18.99%)
+Integers.toStringTiny 500 avgt 15 3.491 ? 0.090 us/op (+7.61%)
-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Longs.toStringBig 500 avgt 15 9.213 ? 0.019 us/op
-Longs.toStringSmall 500 avgt 15 4.550 ? 0.016 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Longs.toStringBig 500 avgt 15 7.507 ? 0.011 us/op (+22.72%)
+Longs.toStringSmall 500 avgt 15 3.967 ? 0.021 us/op (+14.69%)
-Benchmark Mode Cnt Score Error Units (baseline)
-StringBuilders.toStringCharWithInt8 avgt 15 89.187 ? 0.236 ns/op
+Benchmark Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+StringBuilders.toStringCharWithInt8 avgt 15 36.125 ? 0.309 ns/op (+146.88%) 2. aliyun_ecs_c8y.xlarge
-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Integers.toStringBig 500 avgt 15 11.649 ? 0.011 us/op
-Integers.toStringSmall 500 avgt 15 6.985 ? 0.018 us/op
-Integers.toStringTiny 500 avgt 15 5.972 ? 0.013 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Integers.toStringBig 500 avgt 15 8.957 ? 0.026 us/op (+30.05%)
+Integers.toStringSmall 500 avgt 15 6.136 ? 0.018 us/op (+13.83%)
+Integers.toStringTiny 500 avgt 15 5.753 ? 0.026 us/op (+3.80%)
-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Longs.toStringBig 500 avgt 15 14.568 ? 0.021 us/op
-Longs.toStringSmall 500 avgt 15 7.250 ? 0.023 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Longs.toStringBig 500 avgt 15 13.401 ? 0.012 us/op (+8.70%)
+Longs.toStringSmall 500 avgt 15 6.031 ? 0.018 us/op (+20.21%)
-Benchmark Mode Cnt Score Error Units (baseline)
-StringBuilders.toStringCharWithInt8 avgt 15 52.484 ? 0.534 ns/op
+Benchmark Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+StringBuilders.toStringCharWithInt8 avgt 15 40.410 ? 0.348 ns/op (+29.87%) 3. MacBookPro M1 Pro-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Integers.toStringBig 500 avgt 15 18.483 ± 2.771 us/op
-Integers.toStringSmall 500 avgt 15 4.435 ± 0.067 us/op
-Integers.toStringTiny 500 avgt 15 2.382 ± 0.063 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Integers.toStringBig 500 avgt 15 5.392 ? 0.016 us/op (+242.78%)
+Integers.toStringSmall 500 avgt 15 3.201 ? 0.024 us/op (+38.55%)
+Integers.toStringTiny 500 avgt 15 2.141 ? 0.021 us/op (+11.25%)
-Benchmark (size) Mode Cnt Score Error Units (baseline)
-Longs.toStringBig 500 avgt 15 8.336 ± 0.025 us/op
-Longs.toStringSmall 500 avgt 15 4.389 ± 0.018 us/op
+Benchmark (size) Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+Longs.toStringBig 500 avgt 15 7.706 ? 0.015 us/op (+8.17%)
+Longs.toStringSmall 500 avgt 15 3.094 ? 0.021 us/op (+41.85%)
-Benchmark Mode Cnt Score Error Units (baseline)
-StringBuilders.toStringCharWithInt8 avgt 15 124.316 ± 61.017 ns/op
+Benchmark Mode Cnt Score Error Units (PR Update 20 c0f42a7c)
+StringBuilders.toStringCharWithInt8 avgt 15 44.497 ? 29.741 ns/op (+179.38%) |
Hi wenshao,
|
This BackPort PR merges three PRs (8317329, 8310929, 8317329) |
这个PR合并了原来三个PR:
当前的提交合并了前2个,但和第3个PR 15836的修复方法不同,使用Unsafe代替ByteArrayLittleEndian。性能没有回退,并且不会导致JVM启动变慢。 |
1f32a54
to
b7c133a
Compare
JDK 11没有ByteArrayLittleEndian,只能合成一个commit来提交了 |
原来的实现需要两次查表Integer.DigitTens/DigitOnes,新的实现只需要查表一次DecimalDigits#DIGITS,组合Unsafe.putShortUnaligned一次put两个数字,可以提升性能。