diff options
author | lukyan <lukyan@yandex-team.com> | 2023-12-05 19:07:41 +0300 |
---|---|---|
committer | lukyan <lukyan@yandex-team.com> | 2023-12-05 20:50:57 +0300 |
commit | d5b84ed65f77eab0135b9d0ee025556f4507b62b (patch) | |
tree | 5c5db90ad950923a5554c4a0f5fac239b3f44c53 /library/cpp/yt/logging | |
parent | ddadddf4718f23838ed4ffb8e6aa1f126301cf55 (diff) | |
download | ydb-d5b84ed65f77eab0135b9d0ee025556f4507b62b.tar.gz |
Use volatile TLS in library/cpp/yt
Diffstat (limited to 'library/cpp/yt/logging')
-rw-r--r-- | library/cpp/yt/logging/logger-inl.h | 6 | ||||
-rw-r--r-- | library/cpp/yt/logging/logger.cpp | 10 | ||||
-rw-r--r-- | library/cpp/yt/logging/logger.h | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/library/cpp/yt/logging/logger-inl.h b/library/cpp/yt/logging/logger-inl.h index 6f489da82d..5e2b6795dc 100644 --- a/library/cpp/yt/logging/logger-inl.h +++ b/library/cpp/yt/logging/logger-inl.h @@ -8,6 +8,8 @@ #include <library/cpp/yt/yson_string/convert.h> #include <library/cpp/yt/yson_string/string.h> +#include <library/cpp/yt/misc/tls.h> + namespace NYT::NLogging { //////////////////////////////////////////////////////////////////////////////// @@ -98,8 +100,8 @@ private: TSharedMutableRef Buffer_; - static thread_local TPerThreadCache* Cache_; - static thread_local bool CacheDestroyed_; + static YT_THREAD_LOCAL(TPerThreadCache*) Cache_; + static YT_THREAD_LOCAL(bool) CacheDestroyed_; static TPerThreadCache* GetCache(); static constexpr size_t ChunkSize = 128_KB - 64; diff --git a/library/cpp/yt/logging/logger.cpp b/library/cpp/yt/logging/logger.cpp index 4ee5c1a01b..c11457f836 100644 --- a/library/cpp/yt/logging/logger.cpp +++ b/library/cpp/yt/logging/logger.cpp @@ -93,8 +93,8 @@ TMessageStringBuilder::TPerThreadCache* TMessageStringBuilder::GetCache() if (CacheDestroyed_) { return nullptr; } - static thread_local TPerThreadCache Cache; - Cache_ = &Cache; + static YT_THREAD_LOCAL(TPerThreadCache) Cache; + Cache_ = &GetTlsRef(Cache); return Cache_; } @@ -103,8 +103,8 @@ TMessageStringBuilder::TPerThreadCache::~TPerThreadCache() TMessageStringBuilder::DisablePerThreadCache(); } -thread_local TMessageStringBuilder::TPerThreadCache* TMessageStringBuilder::Cache_; -thread_local bool TMessageStringBuilder::CacheDestroyed_; +YT_THREAD_LOCAL(TMessageStringBuilder::TPerThreadCache*) TMessageStringBuilder::Cache_; +YT_THREAD_LOCAL(bool) TMessageStringBuilder::CacheDestroyed_; } // namespace NDetail @@ -126,7 +126,7 @@ Y_WEAK ILogManager* GetDefaultLogManager() //////////////////////////////////////////////////////////////////////////////// -thread_local ELogLevel ThreadMinLogLevel = ELogLevel::Minimum; +YT_THREAD_LOCAL(ELogLevel) ThreadMinLogLevel = ELogLevel::Minimum; void SetThreadMinLogLevel(ELogLevel minLogLevel) { diff --git a/library/cpp/yt/logging/logger.h b/library/cpp/yt/logging/logger.h index 0913b9ea08..082afcddd8 100644 --- a/library/cpp/yt/logging/logger.h +++ b/library/cpp/yt/logging/logger.h @@ -324,8 +324,8 @@ void LogStructuredEvent( break; \ } \ \ - static thread_local i64 localByteCounter__; \ - static thread_local ui8 localMessageCounter__; \ + static YT_THREAD_LOCAL(i64) localByteCounter__; \ + static YT_THREAD_LOCAL(ui8) localMessageCounter__; \ \ localByteCounter__ += message__.MessageRef.Size(); \ if (Y_UNLIKELY(++localMessageCounter__ == 0)) { \ |