Compensate for perf regressions in string-to-span parsing
authorStephen Toub <stoub@microsoft.com>
Mon, 28 Aug 2017 04:26:45 +0000 (00:26 -0400)
committerStephen Toub <stoub@microsoft.com>
Mon, 28 Aug 2017 16:45:23 +0000 (12:45 -0400)
commitb9421de69c3384592fb125eb78e931f04bab95e5
tree78f930bf6b919d7e5d809e6d32daab759d680d5b
parente2ef169c683ce226e42378815c4a2be27d533971
Compensate for perf regressions in string-to-span parsing

When changing the implementation of TimeSpan parsing from string-based to span-based, throughput of some parsing regressed upwards of 15%.  Some of this is due to more stack-based memory needing to be zero'd out, but it's not entirely clear to me at the moment where the rest went.  To compensate, I optimized various portions of the TimeSpan parsing implementation enough to fully counteract the regressions; while there's still more that can be optimized if desired, all of the inputs/formats I tested are now as fast or faster than they were before, and on top of that, the span-based implementation is allocation-free whereas the string-based implementation would allocate a non-trivial amount of memory per parsing operation.

Note that there was a fair bit of dead code, which I removed.  I think there's actually some more, but it was harder to prove, and so I left it as-is (the goal of this commit not being to clean up but to improve perf enough).
src/mscorlib/src/System/Globalization/TimeSpanParse.cs