The piece uses strict ASCII validation as a small case study in SIMD optimization in Dart 3.14. A byte is valid when its high bit is clear, so the task is to check that condition across a buffer; this matters because ASCII is a fast path in UTF-8 decoding. The author distinguishes strict ASCII from browser and legacy interpretations that accept or remap high bytes. The optimization walkthrough begins with a scalar loop, then applies ideas that also work without SIMD: removing per-byte branches and using SWAR to process eight bytes inside a 64-bit word. It then moves to 128-bit Dart vectors, while explaining alignment, leftover bytes, and the cost of extracting individual vector lanes.
Benchmarks on an M3 MacBook Air show that wider processing alone does not guarantee speed. Branchless scalar code improves throughput by about 13-15%, and SWAR reaches 17 GB/s - roughly six times faster than branchless scalar. A first vector implementation manages only about 13 GB/s, because lane extraction creates extra instructions. Using a vector-wide “any lane is nonzero” test raises this to 15 GB/s, and manually hoisting a constant mask nearly doubles throughput to about 28 GB/s by avoiding repeated loads. The announced progression continues with accumulating results, unrolling loops, reducing runtime checks, and vector stores; the title gives the overall range as 2.5 to 114 GB/s. The central lesson is to inspect generated code and remove overhead around vector operations, not merely introduce SIMD types.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.