Summary:
This seemingly trivial change has a surprisingly significant performance
impact. It changes the call to append() on a string-like object from using
an iterator pair to using a char* / length pair for 64-bit unsigned-to-string
conversion. This brings it in line with code for signed-to-string conversion,
which had already been using this overload of append.
=============================================================
folly/test/ConvBenchmark.cpp time/iter time/iter
=============================================================
preallocateTestNoFloat 640.47ns 590.12ns
preallocateTestFloat 569.32ns 580.25ns
preallocateTestInt8 133.65ns 116.27ns
preallocateTestInt16 147.05ns 130.03ns
preallocateTestInt32 169.98ns 156.24ns
preallocateTestInt64 228.31ns 210.66ns
preallocateTestInt128 4.53us 4.56us
preallocateTestNoFloatWithInt128 4.32us 4.27us
-------------------------------------------------------------
u64ToStringFollyMeasure(1) 17.32ns 15.49ns
i64ToStringFollyMeasurePos(1) 15.80ns 15.80ns
i64ToStringFollyMeasureNeg(1) 21.91ns 21.91ns
-------------------------------------------------------------
u64ToStringFollyMeasure(2) 18.23ns 16.10ns
i64ToStringFollyMeasurePos(2) 16.71ns 16.71ns
i64ToStringFollyMeasureNeg(2) 21.90ns 21.90ns
-------------------------------------------------------------
u64ToStringFollyMeasure(3) 19.44ns 17.32ns
i64ToStringFollyMeasurePos(3) 17.01ns 17.01ns
i64ToStringFollyMeasureNeg(3) 21.96ns 21.96ns
-------------------------------------------------------------
u64ToStringFollyMeasure(4) 20.35ns 18.53ns
i64ToStringFollyMeasurePos(4) 18.23ns 18.23ns
i64ToStringFollyMeasureNeg(4) 22.19ns 22.22ns
-------------------------------------------------------------
u64ToStringFollyMeasure(5) 20.66ns 18.84ns
i64ToStringFollyMeasurePos(5) 19.47ns 19.54ns
i64ToStringFollyMeasureNeg(5) 22.66ns 22.68ns
-------------------------------------------------------------
u64ToStringFollyMeasure(6) 21.89ns 20.19ns
i64ToStringFollyMeasurePos(6) 20.74ns 20.72ns
i64ToStringFollyMeasureNeg(6) 23.81ns 23.83ns
-------------------------------------------------------------
u64ToStringFollyMeasure(7) 23.09ns 21.42ns
i64ToStringFollyMeasurePos(7) 21.11ns 21.12ns
i64ToStringFollyMeasureNeg(7) 24.92ns 24.92ns
-------------------------------------------------------------
u64ToStringFollyMeasure(8) 24.00ns 22.48ns
i64ToStringFollyMeasurePos(8) 22.18ns 22.18ns
i64ToStringFollyMeasureNeg(8) 26.20ns 26.20ns
-------------------------------------------------------------
u64ToStringFollyMeasure(9) 24.31ns 22.94ns
i64ToStringFollyMeasurePos(9) 23.39ns 23.53ns
i64ToStringFollyMeasureNeg(9) 26.44ns 26.44ns
-------------------------------------------------------------
u64ToStringFollyMeasure(10) 25.52ns 24.12ns
i64ToStringFollyMeasurePos(10) 24.69ns 24.69ns
i64ToStringFollyMeasureNeg(10) 27.77ns 27.80ns
-------------------------------------------------------------
u64ToStringFollyMeasure(11) 26.74ns 25.53ns
i64ToStringFollyMeasurePos(11) 25.07ns 25.07ns
i64ToStringFollyMeasureNeg(11) 28.87ns 28.87ns
-------------------------------------------------------------
u64ToStringFollyMeasure(12) 28.25ns 26.59ns
i64ToStringFollyMeasurePos(12) 26.21ns 26.34ns
i64ToStringFollyMeasureNeg(12) 30.08ns 30.08ns
-------------------------------------------------------------
u64ToStringFollyMeasure(13) 29.38ns 26.89ns
i64ToStringFollyMeasurePos(13) 27.60ns 27.65ns
i64ToStringFollyMeasureNeg(13) 30.62ns 30.69ns
-------------------------------------------------------------
u64ToStringFollyMeasure(14) 30.91ns 28.26ns
i64ToStringFollyMeasurePos(14) 28.58ns 28.57ns
i64ToStringFollyMeasureNeg(14) 55.27ns 55.27ns
-------------------------------------------------------------
u64ToStringFollyMeasure(15) 54.71ns 52.06ns
i64ToStringFollyMeasurePos(15) 52.79ns 52.84ns
i64ToStringFollyMeasureNeg(15) 57.45ns 57.50ns
-------------------------------------------------------------
u64ToStringFollyMeasure(16) 57.14ns 54.44ns
i64ToStringFollyMeasurePos(16) 55.26ns 55.29ns
i64ToStringFollyMeasureNeg(16) 59.18ns 59.19ns
-------------------------------------------------------------
u64ToStringFollyMeasure(17) 58.89ns 55.96ns
i64ToStringFollyMeasurePos(17) 57.10ns 57.14ns
i64ToStringFollyMeasureNeg(17) 60.89ns 60.88ns
-------------------------------------------------------------
u64ToStringFollyMeasure(18) 60.33ns 57.69ns
i64ToStringFollyMeasurePos(18) 58.59ns 58.63ns
i64ToStringFollyMeasureNeg(18) 62.46ns 62.50ns
-------------------------------------------------------------
u64ToStringFollyMeasure(19) 62.22ns 59.45ns
i64ToStringFollyMeasurePos(19) 60.23ns 60.25ns
i64ToStringFollyMeasureNeg(19) 64.21ns 64.20ns
-------------------------------------------------------------
u64ToStringFollyMeasure(20) 63.79ns 60.91ns
=============================================================
Reviewed By: yfeldblum
Differential Revision:
D3455819
fbshipit-source-id:
bc57a0e5bd1d1dca22a37c8b7306e05493e6bd5f