-
-
Notifications
You must be signed in to change notification settings - Fork 144
Description
We have a use-case for smile that involves parsing a lot of short ASCII string values and _decodeShortAsciiValue shows up prominently in profiles. This implementation copies the input bytes into a character array which is then used to create the String. On newer Java versions there is a significant improvement by just using the String constructor that takes a byte array (sample change). This is because In jdk9 and later the internal representation of String
changed (JEP 254) and creating from an ASCII byte array can basically just do Arrays.copyOfRange
. Unfortunately, this approach seems to be significantly slower on jdk8.
Results from some quick benchmarks using JMH:
Benchmark Mode Cnt Score Error Units
java 8 baseline thrpt 5 344448.375 ± 46864.690 ops/s
java 8 with change thrpt 5 194250.482 ± 7374.829 ops/s
java 17 baseline thrpt 5 301991.539 ± 52160.837 ops/s
java 17 with change thrpt 5 413394.519 ± 16857.477 ops/s
I'm assuming it would be unacceptable to take that hit on java 8 at this time. Are there any existing examples in jackson where behavior is conditional on the java version used?