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):

Takeaway: telling your parser what to expect is a cheap, significant optimization.

Original post →

More from Infra

Infra channel →