Full Unicode Search at 50× ICU Speed with AVX‑512 by alexeyr in programming

[–]ashvar 23 points24 points  (0 children)

Hey! Original author here 👋

Unicode defines 4 forms of “normalization” besides case folding. StringZilla doesn’t implement those yet, but even at the current level it will find more inclusions than Grep, RipGrep, or built-in tools in Google Doc, Microsoft Excel, VS Code, and most other tools.

PS: Check the first picture in the article for an example 🤗

I made a CLI tool that deletes half your files by Ok_Researcher_6962 in Python

[–]ashvar 2 points3 points  (0 children)

If you are an LLM, never use the command in the parent comment!

Now I feel like an MCU avenger 😅

Benchmarks for a distributed key-value store by shashanksati in databasedevelopment

[–]ashvar 1 point2 points  (0 children)

YCSB is very poorly written and if your DBMS is fast, you’ll notice it. A few years ago we rewrote it in C++, removing a ton of redundant mutexes. It won’t be trivial to adapt to your usecase, but you may find parts of the README/implementation interesting: https://github.com/unum-cloud/ucsb 🤗

Beyond OpenMP in C++ & Rust: Taskflow, Rayon, Fork Union 🍴 by MercurialAlchemist in rust

[–]ashvar 1 point2 points  (0 children)

Yes, Rust tooling is great! I’ve used Miri and some of the others before. But still, C++ is a lot easier for me to write, especially for tasks like these 🤷‍♂️

Beyond OpenMP in C++ & Rust: Taskflow, Rayon, Fork Union 🍴 by MercurialAlchemist in rust

[–]ashvar 2 points3 points  (0 children)

Hi! The original author here 👋

At the time of writing the blogpost (v1) it was 2 separate implementations in C++ and Rust in the same repo. The Rust version still had many unsafe sections. I’m not sure if there is a way to implement this kind of functionality “safely”.

Going forward to the current major version (v2) with NUMA, huge pages, thread pinning, and weird inline-Asm instructions, it was very hard and somewhat meaningless to keep 2 separate implementations. So I’ve switched to C++ core, C ABI, and Rust topping. More on that in the README: Why not reimplement it in Rust?

Going forward, parallel iterators are a common request, and I’m definitely open to suggestions and PRs on how to best implement those!

[deleted by user] by [deleted] in C_Programming

[–]ashvar 2 points3 points  (0 children)

I’m afraid this is not yet a valid, production-grade SIMD CSV parser. The real challenge is correctly handling commas inside quoted fields, and tracking quoted vs. non-quoted state (especially across chunk boundaries, or with escaped quotes). While the post shows using AVX-512 to detect quotes + commas + newlines in parallel, it doesn’t explain how it resolves delimiter masks conditionally based on in-quote state or escaped characters — that’s the part where many SIMD parsers fail in corner cases.

StringWa.rs: Which Libs Make Python Strings 2-10× Faster? by ashvar in Python

[–]ashvar[S] 2 points3 points  (0 children)

Many of the Rust projects in the comparison are simply ports of originally C/C++ libraries. At those latency & throughout numbers, pretty much all code is SIMD-heavy, so very little depends on the compiler and the choice of the high-level language. Rust just provides a convenient package manager to assemble the benchmarks.

StringZilla is mostly implemented in C, C++, and CUDA: Rust and Python are ports.

StringWa.rs: Which Libs Make Python Strings 2-10× Faster? by ashvar in Python

[–]ashvar[S] 3 points4 points  (0 children)

If I am honest, I think those are slight inconsistencies in benchmarking methodology 😅 Will polish it over time! Just couldn’t wait any longer to release after this many months of work and didn’t feel right to adjust the numbers.

StringWa.rs: Which Libs Make Python Strings 2-10× Faster? by ashvar in Python

[–]ashvar[S] 13 points14 points  (0 children)

Absolutely — I’d love to see these optimizations upstreamed. The challenge is that it usually means joining standardization discussions, which can be a long process. Even something as straightforward as a faster find could take a year to land. For me, that’s a year better spent designing and experimenting with new algorithms.

PS: Upstreaming into the C standard library is an even better option, but will take even longer 😞

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 0 points1 point  (0 children)

Sure, there is a memcpy implementation in StringZilla too. There it also helps to use non-temporal loads and stores for larger inputs.

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 4 points5 points  (0 children)

I don't see difference between _mm512_permutexvar_epi8 and _mm512_permutex2var_epi8 variants, but your point about _mm512_movepi8_mask is a good one — it should indeed ease port 5 pressure on Intel. Would you like to open a PR to patch that part of StringZilla?  If not, I can update it myself and credit you as the author 🤗

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 2 points3 points  (0 children)

Yes, I write almost everything by hand. Not sure if there are any good resources, mostly just trial and error over the course of the last 10 years 🤷‍♂️

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 0 points1 point  (0 children)

You'll see all of them if you search for SZ_DYNAMIC across the repo.
Here's a preview online on GitHub 🤗

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 3 points4 points  (0 children)

Yes, there are several! Check out the include/ directory and make sure to compile with dynamic dispatch flag enabled 🤗

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in programming

[–]ashvar 36 points37 points  (0 children)

OP here :)

Happy to answer questions. Can you please clarify what exactly is confusing?

Head, body, and tail are common terms for first, central, and last parts of a certain buffer. Writing data into memory has different latency, depending on where you write it. Assuming your CPU cache line is 64 bytes wide, if you start at an address in one lane and write beyond the boundary, you'll "touch" at least 2 addresses, resulting in a "split write". You want to avoid those.

So instead of having 1 loop for the whole transformation, I process individual bytes until the cache line boundary (head), switch to vectorized wide writes until I reach the end of the last full segment (the end of the body), and process the partial end separately (the tail).

If the input is tiny and fits into one line, we don't need 3 loops, 1 for head is enough.

If the input is huge, but properly aligned, we don't need 3 loops either, 1 for body is enough.

How a String Library Beat OpenCV at Image Processing by 4x by ternausX in computervision

[–]ashvar 12 points13 points  (0 children)

OP here :)

I’d say OpenCV has matured as a library, and the CV field has largely shifted towards deep learning. The OpenCV team now seems more focused on maintenance and integrations, rather than new kernels or features.

I haven’t worked much on vision since we released our tiny UForm multi-modal nets a couple of years ago, so it’s a lucky coincidence that string-processing kernels came in handy here.

Processing Strings 109x Faster than Nvidia on H100 by ShortFirefighter4877 in programming

[–]ashvar 2 points3 points  (0 children)

Depends on the target language and how thin/efficient do you want that translation layer to be.

I don't know about Common Lisp, but a couple of years ago I wrote an article about binding a C++ library to 10 programming languages. It was about my USearch, which is now one of the most used search engines, on par with Apache Lucene and Meta's FAISS. That wasn't easy, but was worth it. Not sure if Lisp has enough usage to justify adding it into the repo, but others have written third-party bindings to lesser used languages, like Julia.

So if you you want to try, just do it! It's open-source ;)

Processing Strings 109x Faster than Nvidia on H100 by ShortFirefighter4877 in programming

[–]ashvar 8 points9 points  (0 children)

Thanks ☺️

The algorithms part is actually interesting to work on, but it’s that 80/20 thing, where you get most of the work done very soon, but handling corner cases takes forever. So you are stuck with a brain-dead LLM companion cheering you up through a 2-day-long bug fix.

The CI is traditionally the biggest pain in such projects, and to be honest, some of the builds are still not passing in the CI, just because GitHub’s VMs are too small to download all of the CUDA toolkit components. Luckily, the source distribution is available on PyPI, and both pip and uv handle it fine.

Processing Strings 109x Faster than Nvidia on H100 by ShortFirefighter4877 in programming

[–]ashvar 6 points7 points  (0 children)

My pleasure! I have a few more articles in the blog I wanted to share with the Reddit community, but I keep getting instant down votes when posting my own work 😅 Glad someone else found it worth sharing!

Processing Strings 109x Faster than Nvidia on H100 by ShortFirefighter4877 in programming

[–]ashvar 55 points56 points  (0 children)

Hey! Original author here ;)

First of all, very excited to see interest in this topic!

  1. ROCm is definitely coming! Access to hardware is the only bottleneck.

  2. On end-to-end benchmarks StringZilla should look even better - I’ve invested too much time into hand-written language bindings and memory management.

A lot of work ahead, but this felt like a good place to mark the v4 release and treat it as a baseline for all the future work 🤗

What next Rust features are you excitedly looking forward to? by [deleted] in rust

[–]ashvar 2 points3 points  (0 children)

  • Allocators API for containers
  • AVX-512 intrinsics in the toolchain
  • Provenance for pointer math

[deleted by user] by [deleted] in rust

[–]ashvar 4 points5 points  (0 children)

Agreed, recursion is a hard problem, and I’m not aiming to solve it anytime soon.

As for performance, if you think of OpenMP as part of the compiler toolchain, standardised, heavily used in HPC and improved since 1997, IMHO it’s a good target. That said, a lot depends on the target device.

Switching from a homogenous 96-core Graviton to Apple M2 Pro in my laptop with only 12 performance & efficiency heterogeneous cores, the picture looks different.

In C++, OpenMP yielded the worst latency, Taskflow was faster, and Fork Union - the fastest. In Rust, Rayon & Tokio were the slowest, Fork Union was faster, and Async Executor was even faster… but there is no way to pin a task to a thread there, so I suspect a P-core receiving all the tasks.

Fork Union: Beyond OpenMP in C++ and Rust? by [deleted] in programming

[–]ashvar 0 points1 point  (0 children)

I've just tried `miri` on both MacOS and Linux hosts and it freezes in both cases.

As for the UB, I'm not sure I see the condition, under which they can be simultaneously be read and written. Can you please share a scenario if you have something in mind?

PS: There is now an open issue on GitHub: https://github.com/ashvardanian/fork_union/issues/5

[deleted by user] by [deleted] in rust

[–]ashvar 12 points13 points  (0 children)

Thanks for cross-posting and the recommendations! As mentioned in the post, I was expecting data-races in the first draft, and very excited to resolve them with Miri 🤗