diff options
author | ddoarn <ddoarn@yandex-team.ru> | 2022-02-10 16:49:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:52 +0300 |
commit | 0783fe3f48d91a3b741ce2ea32b11fbfc1637e7e (patch) | |
tree | 6d6a79d83e5003eaf4d45cac346113c1137cb886 /library/cpp/actors/memory_log | |
parent | 9541fc30d6f0877db9ff199a16f7fc2505d46a5c (diff) | |
download | ydb-0783fe3f48d91a3b741ce2ea32b11fbfc1637e7e.tar.gz |
Restoring authorship annotation for <ddoarn@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/actors/memory_log')
-rw-r--r-- | library/cpp/actors/memory_log/memlog.cpp | 50 | ||||
-rw-r--r-- | library/cpp/actors/memory_log/memlog.h | 24 | ||||
-rw-r--r-- | library/cpp/actors/memory_log/mmap.cpp | 12 |
3 files changed, 43 insertions, 43 deletions
diff --git a/library/cpp/actors/memory_log/memlog.cpp b/library/cpp/actors/memory_log/memlog.cpp index 8e6b46727d..9cd7dee0fe 100644 --- a/library/cpp/actors/memory_log/memlog.cpp +++ b/library/cpp/actors/memory_log/memlog.cpp @@ -15,11 +15,11 @@ static int (*FastGetCpu)(unsigned* cpu, unsigned* node, void* unused); #endif #if defined(_unix_) -#include <sched.h> +#include <sched.h> #elif defined(_win_) -#include <WinBase.h> +#include <WinBase.h> #else -#error NO IMPLEMENTATION FOR THE PLATFORM +#error NO IMPLEMENTATION FOR THE PLATFORM #endif const char TMemoryLog::DEFAULT_LAST_MARK[16] = { @@ -62,34 +62,34 @@ const char TMemoryLog::CLEAR_MARK[16] = { unsigned TMemoryLog::GetSelfCpu() noexcept { #if defined(_unix_) -#if HAVE_VDSO_GETCPU +#if HAVE_VDSO_GETCPU unsigned cpu; if (Y_LIKELY(FastGetCpu != nullptr)) { auto result = FastGetCpu(&cpu, nullptr, nullptr); Y_VERIFY(result == 0); - return cpu; + return cpu; } else { return 0; } -#elif defined(_x86_64_) || defined(_i386_) +#elif defined(_x86_64_) || defined(_i386_) -#define CPUID(func, eax, ebx, ecx, edx) \ - __asm__ __volatile__( \ - "cpuid" \ - : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) \ - : "a"(func)); +#define CPUID(func, eax, ebx, ecx, edx) \ + __asm__ __volatile__( \ + "cpuid" \ + : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) \ + : "a"(func)); int a = 0, b = 0, c = 0, d = 0; CPUID(0x1, a, b, c, d); int acpiID = (b >> 24); return acpiID; -#elif defined(__CNUC__) +#elif defined(__CNUC__) return sched_getcpu(); -#else +#else return 0; -#endif +#endif #elif defined(_win_) return GetCurrentProcessorNumber(); @@ -99,16 +99,16 @@ unsigned TMemoryLog::GetSelfCpu() noexcept { } TMemoryLog* TMemoryLog::MemLogBuffer = nullptr; -Y_POD_THREAD(TThread::TId) -TMemoryLog::LogThreadId; +Y_POD_THREAD(TThread::TId) +TMemoryLog::LogThreadId; char* TMemoryLog::LastMarkIsHere = nullptr; std::atomic<bool> TMemoryLog::PrintLastMark(true); TMemoryLog::TMemoryLog(size_t totalSize, size_t grainSize) - : GrainSize(grainSize) - , FreeGrains(DEFAULT_TOTAL_SIZE / DEFAULT_GRAIN_SIZE * 2) - , Buf(totalSize) + : GrainSize(grainSize) + , FreeGrains(DEFAULT_TOTAL_SIZE / DEFAULT_GRAIN_SIZE * 2) + , Buf(totalSize) { Y_VERIFY(DEFAULT_TOTAL_SIZE % DEFAULT_GRAIN_SIZE == 0); NumberOfGrains = DEFAULT_TOTAL_SIZE / DEFAULT_GRAIN_SIZE; @@ -266,7 +266,7 @@ bool MemLogWrite(const char* begin, size_t msgSize, bool addLF) noexcept { // alignment required by NoCacheMemcpy // check for format for snprintf constexpr size_t prologSize = 48; - alignas(TMemoryLog::MemcpyAlignment) char prolog[prologSize + 1]; + alignas(TMemoryLog::MemcpyAlignment) char prolog[prologSize + 1]; Y_VERIFY(AlignDown(&prolog, TMemoryLog::MemcpyAlignment) == &prolog); int snprintfResult = snprintf(prolog, prologSize + 1, @@ -291,7 +291,7 @@ bool MemLogWrite(const char* begin, size_t msgSize, bool addLF) noexcept { // warning: copy prolog first to avoid corruption of the message // by prolog tail NoCacheMemcpy(buffer, prolog, prologSize); - if (AlignDown(begin + prologSize, TMemoryLog::MemcpyAlignment) == begin + prologSize) { + if (AlignDown(begin + prologSize, TMemoryLog::MemcpyAlignment) == begin + prologSize) { NoCacheMemcpy(buffer + prologSize, begin, msgSize); } else { NoWCacheMemcpy(buffer + prologSize, begin, msgSize); @@ -335,14 +335,14 @@ bool MemLogVPrintF(const char* format, va_list params) noexcept { auto threadId = TMemoryLog::GetTheadId(); // alignment required by NoCacheMemcpy - alignas(TMemoryLog::MemcpyAlignment) char buf[TMemoryLog::MAX_MESSAGE_SIZE]; + alignas(TMemoryLog::MemcpyAlignment) char buf[TMemoryLog::MAX_MESSAGE_SIZE]; Y_VERIFY(AlignDown(&buf, TMemoryLog::MemcpyAlignment) == &buf); int prologSize = snprintf(buf, - TMemoryLog::MAX_MESSAGE_SIZE - 2, - "TS %020" PRIu64 " TI %020" PRIu64 " ", + TMemoryLog::MAX_MESSAGE_SIZE - 2, + "TS %020" PRIu64 " TI %020" PRIu64 " ", GetCycleCountFast(), - threadId); + threadId); if (Y_UNLIKELY(prologSize < 0)) { return false; diff --git a/library/cpp/actors/memory_log/memlog.h b/library/cpp/actors/memory_log/memlog.h index 2aa27272a6..ffeb1c308d 100644 --- a/library/cpp/actors/memory_log/memlog.h +++ b/library/cpp/actors/memory_log/memlog.h @@ -18,14 +18,14 @@ #endif #ifndef NO_SANITIZE_THREAD -#define NO_SANITIZE_THREAD -#if defined(__has_feature) -#if __has_feature(thread_sanitizer) -#undef NO_SANITIZE_THREAD -#define NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) -#endif -#endif +#define NO_SANITIZE_THREAD +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) +#undef NO_SANITIZE_THREAD +#define NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) #endif +#endif +#endif class TMemoryLog { public: @@ -60,8 +60,8 @@ public: } inline static void CreateMemoryLogBuffer( - size_t totalSize = DEFAULT_TOTAL_SIZE, - size_t grainSize = DEFAULT_GRAIN_SIZE) + size_t totalSize = DEFAULT_TOTAL_SIZE, + size_t grainSize = DEFAULT_GRAIN_SIZE) Y_COLD { if (AtomicGet(MemLogBuffer) != nullptr) { return; @@ -193,11 +193,11 @@ bool MemLogWriteStruct(const TObj* obj) noexcept { return MemLogWrite(begin, begin + sizeof(TObj)); } -Y_PRINTF_FORMAT(1, 0) +Y_PRINTF_FORMAT(1, 0) bool MemLogVPrintF(const char* format, va_list params) noexcept; -Y_PRINTF_FORMAT(1, 2) -Y_WRAPPER +Y_PRINTF_FORMAT(1, 2) +Y_WRAPPER inline bool MemLogPrintF(const char* format, ...) noexcept { va_list params; va_start(params, format); diff --git a/library/cpp/actors/memory_log/mmap.cpp b/library/cpp/actors/memory_log/mmap.cpp index 201998d343..67dfd9a16f 100644 --- a/library/cpp/actors/memory_log/mmap.cpp +++ b/library/cpp/actors/memory_log/mmap.cpp @@ -1,11 +1,11 @@ #include "memlog.h" -#if defined(_unix_) -#include <sys/mman.h> -#elif defined(_win_) -#include <util/system/winint.h> +#if defined(_unix_) +#include <sys/mman.h> +#elif defined(_win_) +#include <util/system/winint.h> #else -#error NO IMPLEMENTATION FOR THE PLATFORM +#error NO IMPLEMENTATION FOR THE PLATFORM #endif void TMemoryLog::TMMapArea::MMap(size_t amount) { @@ -44,7 +44,7 @@ void TMemoryLog::TMMapArea::MUnmap() { return; } -#if defined(_unix_) +#if defined(_unix_) int result = ::munmap(BufPtr, Size); Y_VERIFY(result == 0); |