[Java with vector simd to impove perf]
JDK 18之后,JDK的默认编码由 uft16 => utf8,且默认都带了vector
下面是一个验证
https://github.com/AugustNagro/utf8.java 该使用了 验证utf8字符性能 在 i7-4930mx上可以跑出2.4GB/secs
Performance
Throughput for twitter.json:
simdjson 就是使用了simd才达到了java的json库15倍以上的性能
new String(buf, UTF_8) |
Utf8.validate(buf, new LookupTables256()) |
simdjson::validate_utf8(str, len) |
|---|---|---|
| .8 GB/sec | 3.52 GB/sec | 24 GB/sec |
-
The JDK algorithm is very optimized, and uses intrinsics to check negatives (for the ASCII shortcut) and to elide array bound checks.
-
In the vectorized algorithm, 256 bit vectors currently perform best. We cannot go smaller than 128 bit, since nibbles (4 bits) are used to select from the lookup tables.
且 fastjson已经有一个使用jdk vector impove performance的特性,下次跑benchmark的时候,使用fastjson2 请使用 JDK>=17 (并启用该特性)
https://github.com/alibaba/fastjson2/tree/a7134cc6416f4a91662c6b37c6591c624d0e3d4d/incubator-vector
谢谢反馈:)
我正在处理一些 java vector的东西,如果你可以抽象一下你的pocess,我可以处理vector部分的 :)
如果要同时兼容 1.8 能搞吗?
这种就得搞特殊JDKutils,学习fastjson2那种方式了。