snack3 icon indicating copy to clipboard operation
snack3 copied to clipboard

[Java with vector simd to impove perf]

Open PeterXiao opened this issue 2 years ago • 4 comments

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

PeterXiao avatar Mar 04 '23 15:03 PeterXiao

谢谢反馈:)

noear avatar Mar 05 '23 01:03 noear

我正在处理一些 java vector的东西,如果你可以抽象一下你的pocess,我可以处理vector部分的 :)

PeterXiao avatar Mar 05 '23 02:03 PeterXiao

如果要同时兼容 1.8 能搞吗?

noear avatar Mar 24 '23 13:03 noear

这种就得搞特殊JDKutils,学习fastjson2那种方式了。

PeterXiao avatar Apr 06 '23 05:04 PeterXiao