Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java with vector simd to impove perf] #23

Open
PeterXiao opened this issue Mar 4, 2023 · 4 comments
Open

[Java with vector simd to impove perf] #23

PeterXiao opened this issue Mar 4, 2023 · 4 comments

Comments

@PeterXiao
Copy link

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

@noear
Copy link
Owner

noear commented Mar 5, 2023

谢谢反馈:)

@PeterXiao
Copy link
Author

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

@noear
Copy link
Owner

noear commented Mar 24, 2023

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

@PeterXiao
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants