A Very Fast IPv4 Parser, in Swift

17 points by juri


masklinn

The shapes columns refer to running the benchmarks against 4 million random valid IP addresses.

The ipv4 space being only 32 bit, at under 10ns per you can very reasonably run an exhaustive test / bench, that’s under a minute runtime.

Also while it’s true that simd is unevenly distributed, neon is required on ARM64, and so is SSE2 on x86-64. And up to 4.2 and a few extensions (x86-64 v2) is pretty reasonable to expect, above that us where it gets dodgy: Intel kept shipping cheap and low power cores without AVX or avx2 for a very very long time, and there have been a lot of implementation issues. But both baselines have 128b registers which means every ipv4 fits without tricks.