dotnet/corefx — pull request #59 by stephentoub (2014-11-13 01:27:43+00:00)
Title: Reduce number of TLS accesses in AllocFreeConcurrentStack<T>

AllocFreeConcurrentStack's TryAdd and TryTake methods both access a [ThreadStatic] field multiple times in any one invocation. These repeated TLS accesses might not be optimized away, in which case the overhead is higher than necessary. This PR caches the [ThreadStatic] into a local which is then what's accessed repeatedly. In a microbenchmark of enumerating very small collections (e.g. an ImmutableList containing one item), this yielded upwards of a 10% throughput improvement on my machine.