diff options
author | babenko <babenko@yandex-team.com> | 2024-05-21 09:25:53 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-05-21 09:37:12 +0300 |
commit | ea58ae291cc530f91033d25b6ffa71ec25f99c37 (patch) | |
tree | fb2588d14bff055d1af13d2f3bc2bcb6d5a67a97 /library/cpp | |
parent | 7e5f63a2ba51e97fdac0d7bda613ceeb97ff2a0c (diff) | |
download | ydb-ea58ae291cc530f91033d25b6ffa71ec25f99c37.tar.gz |
Don't use per-TLS anchor counters
85eb5ffdc79771c842f049e9392902ac6868cece
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/yt/logging/logger-inl.h | 2 | ||||
-rw-r--r-- | library/cpp/yt/logging/logger.h | 15 |
2 files changed, 6 insertions, 11 deletions
diff --git a/library/cpp/yt/logging/logger-inl.h b/library/cpp/yt/logging/logger-inl.h index dcf40d9c11..b20526532d 100644 --- a/library/cpp/yt/logging/logger-inl.h +++ b/library/cpp/yt/logging/logger-inl.h @@ -277,6 +277,7 @@ inline void LogEventImpl( const TLogger& logger, ELogLevel level, ::TSourceLocation sourceLocation, + TLoggingAnchor* anchor, TSharedRef message) { auto event = CreateLogEvent(loggingContext, logger, level); @@ -285,6 +286,7 @@ inline void LogEventImpl( event.Family = ELogFamily::PlainText; event.SourceFile = sourceLocation.File; event.SourceLine = sourceLocation.Line; + event.Anchor = anchor; logger.Write(std::move(event)); if (Y_UNLIKELY(event.Level >= ELogLevel::Alert)) { OnCriticalLogEvent(logger, event); diff --git a/library/cpp/yt/logging/logger.h b/library/cpp/yt/logging/logger.h index 693ea2b9cd..4f0ed44ab7 100644 --- a/library/cpp/yt/logging/logger.h +++ b/library/cpp/yt/logging/logger.h @@ -56,7 +56,7 @@ struct TLoggingAnchor struct TCounter { - std::atomic<i64> Current = 0; + i64 Current = 0; i64 Previous = 0; }; @@ -100,6 +100,8 @@ struct TLogEvent TStringBuf SourceFile; int SourceLine = -1; + + TLoggingAnchor* Anchor = nullptr; }; //////////////////////////////////////////////////////////////////////////////// @@ -328,21 +330,12 @@ void LogStructuredEvent( break; \ } \ \ - static thread_local i64 localByteCounter__; \ - static thread_local ui8 localMessageCounter__; \ - \ - localByteCounter__ += message__.MessageRef.Size(); \ - if (Y_UNLIKELY(++localMessageCounter__ == 0)) { \ - anchor__->MessageCounter.Current += 256; \ - anchor__->ByteCounter.Current += localByteCounter__; \ - localByteCounter__ = 0; \ - } \ - \ ::NYT::NLogging::NDetail::LogEventImpl( \ loggingContext__, \ logger__, \ level__, \ location__, \ + anchor__, \ std::move(message__.MessageRef)); \ } while (false) |