Commit 6902012a authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

revert AccessSpreader thread-local and extern-template-struct

Summary: They are observed to trigger pathological behavior.

Differential Revision: D27659117

fbshipit-source-id: 5e4e770e61ffde02075364f2247614cf5bbcf8ce
parent eeec4600
...@@ -318,6 +318,11 @@ Getcpu::Func Getcpu::resolveVdsoFunc() { ...@@ -318,6 +318,11 @@ Getcpu::Func Getcpu::resolveVdsoFunc() {
#endif #endif
} }
#ifdef FOLLY_CL_USE_FOLLY_TLS
/////////////// SequentialThreadId
template struct SequentialThreadId<std::atomic>;
#endif
namespace detail { namespace detail {
int AccessSpreaderBase::degenerateGetcpu(unsigned* cpu, unsigned* node, void*) { int AccessSpreaderBase::degenerateGetcpu(unsigned* cpu, unsigned* node, void*) {
...@@ -365,6 +370,9 @@ bool AccessSpreaderBase::initialize( ...@@ -365,6 +370,9 @@ bool AccessSpreaderBase::initialize(
} // namespace detail } // namespace detail
/////////////// AccessSpreader
template struct AccessSpreader<std::atomic>;
SimpleAllocator::SimpleAllocator(size_t allocSize, size_t sz) SimpleAllocator::SimpleAllocator(size_t allocSize, size_t sz)
: allocSize_{allocSize}, sz_(sz) {} : allocSize_{allocSize}, sz_(sz) {}
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <folly/lang/Exception.h> #include <folly/lang/Exception.h>
#include <folly/system/ThreadId.h> #include <folly/system/ThreadId.h>
#if !FOLLY_MOBILE #if !FOLLY_MOBILE && defined(FOLLY_TLS)
#define FOLLY_CL_USE_FOLLY_TLS 1 #define FOLLY_CL_USE_FOLLY_TLS 1
#else #else
#undef FOLLY_CL_USE_FOLLY_TLS #undef FOLLY_CL_USE_FOLLY_TLS
...@@ -162,14 +162,18 @@ struct SequentialThreadId { ...@@ -162,14 +162,18 @@ struct SequentialThreadId {
private: private:
static Atom<unsigned> prevId; static Atom<unsigned> prevId;
static thread_local unsigned currentId; static FOLLY_TLS unsigned currentId;
}; };
template <template <typename> class Atom> template <template <typename> class Atom>
Atom<unsigned> SequentialThreadId<Atom>::prevId(0); Atom<unsigned> SequentialThreadId<Atom>::prevId(0);
template <template <typename> class Atom> template <template <typename> class Atom>
thread_local unsigned SequentialThreadId<Atom>::currentId(0); FOLLY_TLS unsigned SequentialThreadId<Atom>::currentId(0);
// Suppress this instantiation in other translation units. It is
// instantiated in CacheLocality.cpp
extern template struct SequentialThreadId<std::atomic>;
#endif #endif
struct HashingThreadId { struct HashingThreadId {
...@@ -341,7 +345,7 @@ struct AccessSpreader : private detail::AccessSpreaderBase { ...@@ -341,7 +345,7 @@ struct AccessSpreader : private detail::AccessSpreaderBase {
}; };
#ifdef FOLLY_CL_USE_FOLLY_TLS #ifdef FOLLY_CL_USE_FOLLY_TLS
static thread_local CpuCache cpuCache; static FOLLY_TLS CpuCache cpuCache;
#endif #endif
static bool initialized; static bool initialized;
...@@ -384,13 +388,17 @@ typename AccessSpreader<Atom>::CompactStripe ...@@ -384,13 +388,17 @@ typename AccessSpreader<Atom>::CompactStripe
#ifdef FOLLY_CL_USE_FOLLY_TLS #ifdef FOLLY_CL_USE_FOLLY_TLS
template <template <typename> class Atom> template <template <typename> class Atom>
thread_local FOLLY_TLS
typename AccessSpreader<Atom>::CpuCache AccessSpreader<Atom>::cpuCache; typename AccessSpreader<Atom>::CpuCache AccessSpreader<Atom>::cpuCache;
#endif #endif
template <template <typename> class Atom> template <template <typename> class Atom>
bool AccessSpreader<Atom>::initialized = AccessSpreader<Atom>::initialize(); bool AccessSpreader<Atom>::initialized = AccessSpreader<Atom>::initialize();
// Suppress this instantiation in other translation units. It is
// instantiated in CacheLocality.cpp
extern template struct AccessSpreader<std::atomic>;
/** /**
* A simple freelist allocator. Allocates things of size sz, from * A simple freelist allocator. Allocates things of size sz, from
* slabs of size allocSize. Takes a lock on each * slabs of size allocSize. Takes a lock on each
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment