TLS cache for AccessSpreader
Summary:
Under Linux the process gtod doesn't contain the current cpu, so
__vdso_getcpu uses RDTSCP, which makes it cost about 20 nanos. The gtod
_does_, however, contain a nanosecond time (for CLOCK_REALTIME_COARSE)
updated during context switches. This diff adds a TLS cache that uses
__vdso_clock_gettime_ns(CLOCK_REALTIME_COARSE) to detect context switches.
The end result is that AccessSpreader goes from ~20 nanos to ~6.
Test Plan: unit tests
Reviewed By: davejwatson@fb.com
Subscribers: yfeldblum, trunkagent, folly-diffs@
FB internal diff:
D1798922
Signature: t1:
1798922:
1423264298:
32312a5e9bddb3b8aa630c146ef708164a6a4651