3 ms·
Show HN: StringZilla v3 with C++, Rust, and Swift bindings, and AVX-512 and NEON
Hi HN!
I've spent the last few weeks optimizing the string operations in StringZilla. You'd be surprised how much performance GLibc and the Standard Templates Library of C++ are leaving on the table, especially on Arm and, likely, on RISC-V. I've significantly increased the number of implemented algorithms for different workloads. Searching across English texts on Arm, for example:
- is 4.4x faster than STL,
- and 16.8x faster in reverse order.
The new version of the library now includes a C++ binding largely compatible with the C++ Standard, featuring all 17 overloads of the `replace` function. It also gained bindings for Rust and Swift. On the functionality side, it can now compute Levenshtein distances and Needleman-Wunsch alignment scores using AVX-512. It can generate random strings with a fair, uniform distribution without integer divisions. It can sort strings and compute rolling hashes. It has lazily evaluated ranges to avoid memory allocations on bulk search and split operations over large datasets, which is very common in modern AI pre-training experiments.
I wrote over 60KB of English text in the README about all the new bells and whistles, so repeating the whole text here probably doesn't make sense. I've also listed several "good first issues" on GitHub in case someone wants to contribute - it may be a good learning opportunity. Lastly, I'll organize more hackathons for systems engineers in the SF Bay Area. LLM wrappers are fun, but the world needs infra. So, if you are around, join and let's build the future together :)
- skeptrune 3y agocool to see the community coming together and adding bindings to other languages i definitely agree that the world needs more infra like this; it's great to see a community growing around it
- sgerenser 3y agoThis looks interesting. If I can scrounge up some time in the next few weeks maybe I’ll try to contribute.
- ashvardanian 3y agoThank you! There are still a lot of good first issues: https://github.com/ashvardanian/StringZilla/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 https://github.com/ashvardanian/StringZilla/issues?q=is%3Ais...
- snvzz 3y ago>libc Which libc?
- ashvardanian 3y agoBenchmarks were repeated on multiple systems. The numbers I reference here come from glibc v2.35 and are explained in more details in the README :)
- snvzz 3y agoCool. It would likely be best to edit to show "glibc-2.35" directly in place of libc.
- ashvardanian 3y agoSadly I can’t edit the post now. Too many upvotes, I guess. Will keep in mind for the next one ;)
- chaisan 3y agonice. where is the the main part of the 4.4x boost on ARM coming from?
- ashvardanian 3y agoIt’s mostly coming from using the Arm NEON intrinsics, not much magic. While working on the library, I was shocked to see how under-vectorized LibC is on Arm. A lot of improvement potential beyond strings. Amazon, Microsoft, Nvidia, Ampere, Apple, Qualcomm, and all the other Arm-based CPU vendors should really consider investing more into the ecosystem. The hardware is very capable, they shouldn’t be losing against x86 in so many benchmarks…
- menaerus 3y agoI'd say that SIMD and even moreso CPU internals knowledge is not quite common and upmost performance is I think not among the highest priority goals in libc/libc++/libstdc++. The ones who need it will implement it themselves. The ones that don't need them won't even notice. Implementation effort and maintanence is by several factors larger than usual "good enough" scalar implementation.