TLS cache for AccessSpreader
authorNathan Bronson <ngbronson@fb.com>
Fri, 6 Feb 2015 23:16:53 +0000 (15:16 -0800)
committerSara Golemon <sgolemon@fb.com>
Wed, 11 Feb 2015 02:02:00 +0000 (18:02 -0800)
commit5569e6fa6061fdeb6c3c95ac4fe6d2fc9e4df7b6
treec08b09315f3f12b4bb74219f5f1d8ff565875666
parentb2f445a27494e122632e7987d7171b7b33fed9fb
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
folly/detail/CacheLocality.cpp
folly/detail/CacheLocality.h
folly/test/CacheLocalityTest.cpp