Rendered at 15:45:01 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
Panzerschrek 1 days ago [-]
> Instead of testing every byte, OR every byte into an accumulator and check the high bit once at the end.
It's not an optimization, in many cases it's a pessimization if a large string has non-ASCII characters right at the start (or close to it). Iterating only a small fraction of the given string with branching is faster than iterating it all without branching.
modulovalue 1 days ago [-]
That's a fair point and I agree. I've added your point to the addendum. The solution that I see is iterating in blocks and have an early exit per block.
perching_aix 1 days ago [-]
> These ten steps are as far as I could take this loop in Dart today. There is still some performance left. The good news is that I already know what it takes to get there, and I'm working on the compiler and library changes it needs. I hope they land soon, and that a future version of this post can end at full speed.
That sounds interesting. I quickly looked up the peak read of the L1D cache to be 192 GB/s, is that what's meant here? Or some other, more fundamental microarchitectural limit?
Is it possible to saturate that throughput and still have optimality to gain in some other aspect?
modulovalue 1 days ago [-]
My goal is to safely reach native speeds on 128-bit wide SIMD registers and for that we need:
- better bounds check elimination so we don't need the unsafe bounds pragma
- dedicated loads so we can extract a SIMD value type directly from bytes with no overhead (Dart doesn't support slices like Rust, for example, and it's not that easy to retrofit them from what I've seen.)
- a dedicated Uint8x16 type so the SWAR techniques over 32-bit wide integers are no longer needed
- plus a few other minor optimizations
I don't think I'll be able to reach 192 GB/s if that's the limit of the M3 Air, but even if, unfortunately, validation is slowed down by any subsequent conversion to a String.
I should write about this because all languages suffer from this. I imagine that one day we will have languages that provide more extensive static ownership guarantees where we can have zero cost wrappers over regions of memory that we can easily treat as Strings instead of having to allocate memory and copy the bytes over to a materialized String.
It's not an optimization, in many cases it's a pessimization if a large string has non-ASCII characters right at the start (or close to it). Iterating only a small fraction of the given string with branching is faster than iterating it all without branching.
That sounds interesting. I quickly looked up the peak read of the L1D cache to be 192 GB/s, is that what's meant here? Or some other, more fundamental microarchitectural limit?
Is it possible to saturate that throughput and still have optimality to gain in some other aspect?
With that we should be pretty much be as fast as Rust, see: https://www.reddit.com/r/rust/comments/1yamcov/looking_for_f...
I don't think I'll be able to reach 192 GB/s if that's the limit of the M3 Air, but even if, unfortunately, validation is slowed down by any subsequent conversion to a String.
I should write about this because all languages suffer from this. I imagine that one day we will have languages that provide more extensive static ownership guarantees where we can have zero cost wrappers over regions of memory that we can easily treat as Strings instead of having to allocate memory and copy the bytes over to a materialized String.