[Java Extension] Add fast path for decoding / unescaping of ASCII-only strings#1034
[Java Extension] Add fast path for decoding / unescaping of ASCII-only strings#1034samyron wants to merge 2 commits into
Conversation
…n decoding ASCII-only strings with escape or control characters.
… being done if UTF-8 validation is disabled.
|
Note: I'm happy to remove the |
|
CC: @headius |
headius
left a comment
There was a problem hiding this comment.
Looks good to me with a quick review. I like the 8-wide scanning; exactly as I pictured it.
|
Looks good to me. I'd be interested in seeing what improvement we might see using a VarHandle to access long values from the byte array instead of wrapping with a ByteBuffer, but that would require Java 9 minimum. |
Overview
This PR is a follow up to #1004. This adds a fast path when decoding / unescaping ASCII-only strings.
Additionally, this adds a new JVM system propery
jruby.json.validateUTF8Stringswhich defaults totrue. If this property is disabled, UTF-8 validation is disabled which matches the behavior of the C parser. This provides an opt-in resolution to #138 where JRuby users can explicitly disable the UTF-8 validation. If the UTF-8 validation is disabled, there is a bit of a performance benefit on some benchmarks.Benchmarks
These benchmarks were run on a M1 Macbook Air. There is a non-trivial difference between runs but I tried to get the best
beforebenchmarks possible. THeafterare a bit more stable.SWAR + UTF-8 Validation
SWAR + No UTF-8 Validation
activitypub.jsonis the same buttwitter.jsonandcitm_catalog.jsonsee improvements.Vector API + UTF-8 Validation
Vector API + No UTF-8 Validation