fast_float benchmarks: parser hints double throughput to 355M numbers/sec
lemire · x · 2026-11-10
Daniel Lemire, author of fastfloat (part of GCC's C++ standard library), explains how hints speed up number parsing.
Why it matters: Parsing a number involves branches — sign, digit count, decimal point, rounding mode. Modern CPUs speculate past branches; correct guesses are nearly free, mispredictions cost 15–20 cycles. Random-looking data (e.g., mixed gains/losses) defeats the predictor.
The technique: fastfloat now accepts caller-supplied hints: unpredictablesign, shortnumbers, and assumeroundtonearest.
Benchmarks (millions of numbers/sec, two CPU generations):
- Price-change data (-731.51): 153 → 347 M/s with shortnumbers + assumeroundtonearest — more than 2x.
- Regular prices: up to 355 M/s; sensor readings: 123 → 250 M/s.
- Gains are smaller on older hardware, and a mismatched hint (shortnumbers on long account balances) can slightly hurt.
Takeaway: telling your parser what to expect is a cheap, significant optimization.
More from Infra
- New Export Control Push After Spy Scandal Adds to Nvidia's Headaches — pstAsiatech · 2026-11-10
- You can download a model but not a substation: investor case for AI compute bottlenecks — McDonaghMatthew · 2026-11-10
- Lokey: Open-Source Android Keyboard Runs On-Device AI Prediction and Translation — Nicolodeva · 2026-11-10
- Report: Moonshot AI obtained Nvidia's advanced chips this summer; skeptic says not a serious training cluster — pstAsiatech · 2026-11-10
- The Softmax Wall: in FP8/FP4 attention is no longer bottlenecked by matmuls — burny_tech · 2026-11-10
- Data center investment up 21% in a year, one of only two US investment booms — soumitrashukla9 · 2026-11-10