Comment

Comment by juliusgeo

This is super cool! If I'm understanding your implementation correctly, you do perform bit by bit state machine logic to check whether quotes should be escaped etc. You can do that in a single pass by using carry-less polynomial multiplication instructions (_mm_clmulepi64_si128 on AVX-512 I believe), or by just computing the carryless xor directly on the quote mask and then &ing the inverse with the bitmask for quotes. Simdjson uses this trick, and I use it as well in my Rust simd csv parser:

https://github.com/juliusgeo/csimdv-rs/blob/681df3b036f30c5a...

This is a good write-up on how the approach works: https://nullprogram.com/blog/2021/12/04/

parent juliusgeo 9 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton