> The implementation is similar to the one in simdjson except that it aligns reads to the block size of the SIMD extension, which leads to better peak performance compared to the implementation in simdjson. I didn't really understand this part. Aligned to what? to the cache line? SIMD always reads the block size. Unless I am missing something here.
I read it as "to the width of the SIMD registers" which I have seen in other quick scanners, but did not read the code here.
Show HN: High-speed UTF-8 validation in Rust
31–40 of 48 posts
Re: Show HN: High-speed UTF-8 validation in Rust
#32Earlier quoted context omitted.
I read it as "to the width of the SIMD registers" which I have seen in other quick scanners, but did not read the code here.
Aren’t all reads aligned to the width of the SIMD register? If I do an AVX512 command it will read 512 bits right?
It's less of an issue than it used to be, the penalty for unaligned access has steadily been reduced by newer CPU architectures, but it's still there.
Re: Show HN: High-speed UTF-8 validation in Rust
#33I find it interesting that with the state of rust SIMD many implementations just opted for reimplementing the code multiple times for each intrinsic (SSE, Neon, AVX, etc). One would think that one of the generic libraries (faster, simdeez, packed_simd) would start to see widespread use, but they all seem to have issues that have prevented adoption.
The various SIMD ISAs are different enough from eachother that you really want a custom implementation per ISA for perf reasons. Particularly if you're doing something off the beaten path like this rather than cranking through some vector math.
Re: Show HN: High-speed UTF-8 validation in Rust
#34Earlier quoted context omitted.
Aren’t all reads aligned to the width of the SIMD register? If I do an AVX512 command it will read 512 bits right?
It's about where you read data from, not how much data gets read. For example an AVX read is aligned if the address being read from is a multiple of 32 bytes, otherwise it's unaligned and runs slightly slower, and slower still if it happens to straddle two cachelines. The same applies to write instructions as well. It's less of an issue than it used to be, the penalty for unaligned access has steadily been reduced by…
[1] https://lemire.me/blog/2012/05/31/data-alignment-for-speed-m...
Re: Show HN: High-speed UTF-8 validation in Rust
#35I find it interesting that with the state of rust SIMD many implementations just opted for reimplementing the code multiple times for each intrinsic (SSE, Neon, AVX, etc). One would think that one of the generic libraries (faster, simdeez, packed_simd) would start to see widespread use, but they all seem to have issues that have prevented adoption.
I really think the general push right now is towards stdsimd being the future for portability.
Re: Show HN: High-speed UTF-8 validation in Rust
#36I find it interesting that with the state of rust SIMD many implementations just opted for reimplementing the code multiple times for each intrinsic (SSE, Neon, AVX, etc). One would think that one of the generic libraries (faster, simdeez, packed_simd) would start to see widespread use, but they all seem to have issues that have prevented adoption.
The various SIMD ISAs are different enough from eachother that you really want a custom implementation per ISA for perf reasons. Particularly if you're doing something off the beaten path like this rather than cranking through some vector math.
The Eigen library did recently combine most SSE and AVX code paths, however: https://eigen.tuxfamily.org/index.php?title=3.4
Re: Show HN: High-speed UTF-8 validation in Rust
#37Re: Show HN: High-speed UTF-8 validation in Rust
#38One flavour I would expect to be valuable that isn't present here is this: Process the input (as quickly as possible) and never fail, but replace each invalid sequence of bytes with U+FFFD (bytes 0xEF 0xBF 0xBD).
One major problem with this: you can’t do it in place. Invalid byte sequences could be 1–4 bytes long, but U+FFFD is exactly three bytes long.
Re: Show HN: High-speed UTF-8 validation in Rust
#39I'd be curious how this compares with the encoding_rs crate ( https://github.com/hsivonen/encoding_rs ), which also offers UTF-8 validation (among many other things).
Re: Show HN: High-speed UTF-8 validation in Rust
#40I find it interesting that with the state of rust SIMD many implementations just opted for reimplementing the code multiple times for each intrinsic (SSE, Neon, AVX, etc). One would think that one of the generic libraries (faster, simdeez, packed_simd) would start to see widespread use, but they all seem to have issues that have prevented adoption.
[0]: https://github.com/mooman219/fontdue/blob/master/src/platfor...