Skip to content

Possible performance improvement on jdk9+ for Smile decoding #342

@brharrington

Description

@brharrington

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions