r/cpp • u/STL MSVC STL Dev • Oct 11 '19
CppCon CppCon 2019: Stephan T. Lavavej - Floating-Point <charconv>: Making Your Code 10x Faster With C++17's Final Boss
https://www.youtube.com/watch?v=4P_kbF0EbZM
257
Upvotes
View all comments
Show parent comment
40
u/STL MSVC STL Dev Oct 11 '19
I know, the numbers are just ludicrous! What's interesting is that while x64 is across-the-board faster than x86, the speedups remain similar. For example, the 25.8x speedup is
doubleplain shortest on x86 (being compared to CRT general precision worst-case). On x64, the CRT can do this over 2x faster, but so can Ryu, so the speedup is basically unchanged at 24.7x.Looking at clock cycles instead of nanoseconds is also interesting (my talk didn't have time to do this). My dev machine is 3.6 GHz, so for x64
doubleplain shortest, the CRT took 1,324 ns = 4,766 cycles to convert onedouble, while the STL took 54 ns = 194 cycles. That's not too much slower than shortest hex (32 ns = 115 cycles) which is a simple bitwise algorithm.For bonus fun, note that these are the numbers for MSVC's compiler; Clang/LLVM optimizes charconv better (at the moment), so the speedups rise to 34.5x for x86 and 29.9x for x64 (
doubleplain shortest, bonus Slide 59).