#include <folly/concurrency/CacheLocality.h>
#ifndef _MSC_VER
#define _GNU_SOURCE …
#include <dlfcn.h>
#endif
#include <fstream>
#include <mutex>
#include <numeric>
#include <optional>
#include <fmt/core.h>
#include <glog/logging.h>
#include <folly/Indestructible.h>
#include <folly/Memory.h>
#include <folly/ScopeGuard.h>
#include <folly/detail/StaticSingletonManager.h>
#include <folly/hash/Hash.h>
#include <folly/lang/Exception.h>
#include <folly/portability/Unistd.h>
#include <folly/system/ThreadId.h>
namespace folly {
static CacheLocality getSystemLocalityInfo() { … }
template <>
const CacheLocality& CacheLocality::system<std::atomic>() { … }
CacheLocality::CacheLocality(std::vector<std::vector<size_t>> equivClasses) { … }
static size_t parseLeadingNumber(const std::string& line) { … }
CacheLocality CacheLocality::readFromSysfsTree(
const std::function<std::string(std::string const&)>& mapping) { … }
CacheLocality CacheLocality::readFromSysfs() { … }
namespace {
static bool procCpuinfoLineRelevant(std::string const& line) { … }
std::vector<std::tuple<size_t, size_t, size_t>> parseProcCpuinfoLines(
std::vector<std::string> const& lines) { … }
}
CacheLocality CacheLocality::readFromProcCpuinfoLines(
std::vector<std::string> const& lines) { … }
CacheLocality CacheLocality::readFromProcCpuinfo() { … }
CacheLocality CacheLocality::uniform(size_t numCpus) { … }
Getcpu::Func Getcpu::resolveVdsoFunc() { … }
unsigned SequentialThreadId::get() { … }
unsigned HashingThreadId::get() { … }
namespace detail {
int AccessSpreaderBase::degenerateGetcpu(unsigned* cpu, unsigned* node, void*) { … }
struct AccessSpreaderStaticInit { … };
AccessSpreaderStaticInit AccessSpreaderStaticInit::instance;
bool AccessSpreaderBase::initialize(
GlobalState& state,
Getcpu::Func (&pickGetcpuFunc)(),
const CacheLocality& (&system)()) { … }
}
namespace {
class SimpleAllocator { … };
class Allocator { … };
}
void* coreMalloc(size_t size, size_t numStripes, size_t stripe) { … }
void coreFree(void* ptr) { … }
namespace {
thread_local CoreAllocatorGuard* gCoreAllocatorGuard = …;
}
CoreAllocatorGuard::CoreAllocatorGuard(size_t numStripes, size_t stripe)
: … { … }
CoreAllocatorGuard::~CoreAllocatorGuard() { … }
namespace detail {
void* coreMallocFromGuard(size_t size) { … }
}
}