Optimize Utf8Validator with constant input Vector.slice API
Patch replaces existing bulky handling for pulling in last, second last and third last byte of pervious byte vector chunk in Utf8Validator with optimized constant input Vector.slice API.
Following are the results of the performance analysis of Utf8ValidatorBenchmark on AMD Ryzen 7 7840HS 8C 16T AVX512 system.
```
Baseline: jdk-24.0.2
Benchmark (fileName) Mode Cnt Score Error Units
Utf8ValidatorBenchmark.utf8Validator /twitter.json thrpt 2 62117.351 ops/s
Withopt: jdk-24.0.2
Benchmark (fileName) Mode Cnt Score Error Units
Utf8ValidatorBenchmark.utf8Validator /twitter.json thrpt 2 80763.046 ops/s
Root cause of gain: Exitance of VPERMB instruction on AVX512_VBMI targets
targets.
1.33% ││ │ 0x0000735a1422bde2: vpermb %zmm0,%zmm3,%zmm1
5.41% ││ │ 0x0000735a1422bde8: vpermb %zmm11,%zmm3,%zmm2
1.54% ││ │ 0x0000735a1422bdee: vpblendmb %zmm1,%zmm2,%zmm1{%k3}
Baseline: jdk-26
Benchmark (fileName) Mode Cnt Score Error Units
Utf8ValidatorBenchmark.utf8Validator /twitter.json thrpt 2 59075.477 ops/s
Withopt: jdk-26 (without ALIGNR)
Benchmark (fileName) Mode Cnt Score Error Units
Utf8ValidatorBenchmark.utf8Validator /twitter.json thrpt 2 81333.082 ops/s
Withopt: jdk mainline (with ALIGNR)
Benchmark (fileName) Mode Cnt Score Error Units
Utf8ValidatorBenchmark.utf8Validator /twitter.json thrpt 2 85728.800 ops/s
Utf8ValidatorBenchmark.utf8Validator:·asm /twitter.json thrpt NaN ---
```
Analysis:
Utf8Validator with slice API is performant on AVX512 targets even without ALIGNR based instruction sequence.
But, on AVX2/Intel E-core targets only ALIGNR based slice optimization part of JDK mainline PR[1] will be performant.
On AMD targets, where both client and servers support AVX512 ISA, slice based Utf8Validator will always
be performant even with stock JDK-24.0.2.
While on Intel targets we need to wait till integration of PR[1] and also gradle compatibility with jdk-25+,
JDK-8290322 improved the byte vector rearrange on AVX2/E-core targets but its performance does not
match up to direct VPERMB instruction.
PS: Patch depends on integration of eixsint simd-json PR[2]
[1] https://github.com/openjdk/jdk/pull/24104
[2] https://github.com/simdjson/simdjson-java/pull/67
合并状态:未合并 0 条评论