diff options
author | filmih <filmih@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:59 +0300 |
commit | 693ca74a6530df8930b0d445102e2ea77b8c4e00 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | 883c643baf3a1698f0f0a31a8973b61411cd311f (diff) | |
download | ydb-693ca74a6530df8930b0d445102e2ea77b8c4e00.tar.gz |
Restoring authorship annotation for <filmih@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | library/cpp/codecs/greedy_dict/gd_builder.cpp | 2 | ||||
-rw-r--r-- | library/cpp/containers/comptrie/comptrie_impl.cpp | 2 | ||||
-rw-r--r-- | library/cpp/protobuf/util/pb_io.cpp | 24 | ||||
-rw-r--r-- | library/cpp/protobuf/util/pb_io.h | 8 | ||||
-rw-r--r-- | library/cpp/testing/unittest/registar.cpp | 2 | ||||
-rw-r--r-- | library/cpp/unicode/normalization/normalization.h | 82 | ||||
-rw-r--r-- | library/cpp/unicode/normalization/ya.make | 2 | ||||
-rw-r--r-- | util/system/rusage.cpp | 90 | ||||
-rw-r--r-- | util/system/rusage.h | 6 | ||||
-rw-r--r-- | ydb/library/yql/minikql/computation/mkql_computation_node.cpp | 4 |
10 files changed, 111 insertions, 111 deletions
diff --git a/library/cpp/codecs/greedy_dict/gd_builder.cpp b/library/cpp/codecs/greedy_dict/gd_builder.cpp index 7788771427..561bfbca01 100644 --- a/library/cpp/codecs/greedy_dict/gd_builder.cpp +++ b/library/cpp/codecs/greedy_dict/gd_builder.cpp @@ -125,7 +125,7 @@ namespace NGreedyDict { if (Settings.Verbose) { TString mess = Sprintf("iter:%" PRIu32 " sz:%" PRIu32 " pend:%" PRIu32, maxiters, (ui32)Current->size(), (ui32)CompoundCounts->size()); - Clog << Sprintf("%-110s RSS=%" PRIu32 "M", mess.data(), (ui32)(TRusage::Get().MaxRss >> 20)) << Endl; + Clog << Sprintf("%-110s RSS=%" PRIu32 "M", mess.data(), (ui32)(TRusage::Get().MaxRss >> 20)) << Endl; } ui32 diff = BuildNextGeneration(maxentries); diff --git a/library/cpp/containers/comptrie/comptrie_impl.cpp b/library/cpp/containers/comptrie/comptrie_impl.cpp index 892fac1d48..a116ab6d1e 100644 --- a/library/cpp/containers/comptrie/comptrie_impl.cpp +++ b/library/cpp/containers/comptrie/comptrie_impl.cpp @@ -31,7 +31,7 @@ namespace NCompactTrie { void ShowProgress(size_t n) { if (n % 1000000 == 0) - Cerr << n << ", RSS=" << (TRusage::Get().MaxRss >> 20) << "mb" << Endl; + Cerr << n << ", RSS=" << (TRusage::Get().MaxRss >> 20) << "mb" << Endl; else if (n % 20000 == 0) Cerr << "."; } diff --git a/library/cpp/protobuf/util/pb_io.cpp b/library/cpp/protobuf/util/pb_io.cpp index bbedfa16fa..6270ee0624 100644 --- a/library/cpp/protobuf/util/pb_io.cpp +++ b/library/cpp/protobuf/util/pb_io.cpp @@ -118,18 +118,18 @@ void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& } } -void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out) { - google::protobuf::TextFormat::Printer printer; - printer.SetUseUtf8StringEscaping(true); - printer.SetUseShortRepeatedPrimitives(true); - - NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); - - if (!printer.Print(m, &adaptor)) { - ythrow yexception() << "SerializeToTextFormatPretty failed on Print"; - } -} - +void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out) { + google::protobuf::TextFormat::Printer printer; + printer.SetUseUtf8StringEscaping(true); + printer.SetUseShortRepeatedPrimitives(true); + + NProtoBuf::io::TCopyingOutputStreamAdaptor adaptor(&out); + + if (!printer.Print(m, &adaptor)) { + ythrow yexception() << "SerializeToTextFormatPretty failed on Print"; + } +} + static void ConfigureParser(const EParseFromTextFormatOptions options, NProtoBuf::TextFormat::Parser& p) { if (options & EParseFromTextFormatOption::AllowUnknownField) { diff --git a/library/cpp/protobuf/util/pb_io.h b/library/cpp/protobuf/util/pb_io.h index 089191c19e..493c84cb5f 100644 --- a/library/cpp/protobuf/util/pb_io.h +++ b/library/cpp/protobuf/util/pb_io.h @@ -48,10 +48,10 @@ int operator&(NProtoBuf::Message& m, IBinSaver& f); void SerializeToTextFormat(const NProtoBuf::Message& m, const TString& fileName); void SerializeToTextFormat(const NProtoBuf::Message& m, IOutputStream& out); -// Write a textual representation of the given message to the given output stream -// with flags UseShortRepeatedPrimitives and UseUtf8StringEscaping set to true. -void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out); - +// Write a textual representation of the given message to the given output stream +// with flags UseShortRepeatedPrimitives and UseUtf8StringEscaping set to true. +void SerializeToTextFormatPretty(const NProtoBuf::Message& m, IOutputStream& out); + // Write a textual representation of the given message to the given output stream // use enum id instead of enum name for all enum fields. void SerializeToTextFormatWithEnumId(const NProtoBuf::Message& m, IOutputStream& out); diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp index 471e00c639..3679b768ed 100644 --- a/library/cpp/testing/unittest/registar.cpp +++ b/library/cpp/testing/unittest/registar.cpp @@ -340,7 +340,7 @@ void NUnitTest::TTestBase::BeforeTest(const char* func) { void NUnitTest::TTestBase::Finish(const char* func, TTestContext* context) { TRusage finishRusage = TRusage::Get(); - context->Metrics["ru_rss"] = finishRusage.MaxRss - rusage.MaxRss; + context->Metrics["ru_rss"] = finishRusage.MaxRss - rusage.MaxRss; context->Metrics["ru_major_pagefaults"] = finishRusage.MajorPageFaults - rusage.MajorPageFaults; context->Metrics["ru_utime"] = (finishRusage.Utime - rusage.Utime).MicroSeconds(); context->Metrics["ru_stime"] = (finishRusage.Stime - rusage.Stime).MicroSeconds(); diff --git a/library/cpp/unicode/normalization/normalization.h b/library/cpp/unicode/normalization/normalization.h index 1537054f2a..4f5f57881c 100644 --- a/library/cpp/unicode/normalization/normalization.h +++ b/library/cpp/unicode/normalization/normalization.h @@ -187,10 +187,10 @@ namespace NUnicode { } }; - template <ENormalization N, typename TCharType> - inline bool Normalized(const TCharType* begin, const TCharType* end) { + template <ENormalization N, typename TCharType> + inline bool Normalized(const TCharType* begin, const TCharType* end) { TCombining lastCanonicalClass = 0; - for (const TCharType* i = begin; i != end;) { + for (const TCharType* i = begin; i != end;) { wchar32 ch = ReadSymbolAndAdvance(i, end); TCombining canonicalClass = DecompositionCombining(ch); @@ -244,12 +244,12 @@ namespace NUnicode { } } - static inline void Write(const TBuffer::const_iterator& begin, const TBuffer::const_iterator& end, TUtf32String& out) { // because WriteSymbol from util/charset/wide.h works wrong in this case - for (TBuffer::const_iterator i = begin; i != end; ++i) { - out += i->first; - } - } - + static inline void Write(const TBuffer::const_iterator& begin, const TBuffer::const_iterator& end, TUtf32String& out) { // because WriteSymbol from util/charset/wide.h works wrong in this case + for (TBuffer::const_iterator i = begin; i != end; ++i) { + out += i->first; + } + } + inline void SortBuffer() { if (Buffer.size() < 2) return; @@ -289,11 +289,11 @@ namespace NUnicode { } } - template <class T, typename TCharType> - inline void DoNormalize(const TCharType* begin, const TCharType* end, T& out) { + template <class T, typename TCharType> + inline void DoNormalize(const TCharType* begin, const TCharType* end, T& out) { Buffer.clear(); - for (const TCharType* i = begin; i != end;) { + for (const TCharType* i = begin; i != end;) { AddChar(ReadSymbolAndAdvance(i, end), out); } @@ -313,10 +313,10 @@ namespace NUnicode { { } - template <class T, typename TCharType> - inline void Normalize(const TCharType* begin, const TCharType* end, T& out) { + template <class T, typename TCharType> + inline void Normalize(const TCharType* begin, const TCharType* end, T& out) { if (NPrivate::Normalized<Norm>(begin, end)) { - for (const TCharType* i = begin; i != end; ++i) { + for (const TCharType* i = begin; i != end; ++i) { WriteSymbol(*i, out); } } else { @@ -324,29 +324,29 @@ namespace NUnicode { } } - template <typename TCharType> - inline void Normalize(const TCharType* begin, const TCharType* end, TUtf32String& out) { - if (NPrivate::Normalized<Norm>(begin, end)) { - for (const TCharType* i = begin; i != end;) { - out += ReadSymbolAndAdvance(i, end); - } - } else { - DoNormalize(begin, end, out); - } - } - - template <class T, typename TCharType> - inline void Normalize(const TCharType* begin, size_t len, T& out) { + template <typename TCharType> + inline void Normalize(const TCharType* begin, const TCharType* end, TUtf32String& out) { + if (NPrivate::Normalized<Norm>(begin, end)) { + for (const TCharType* i = begin; i != end;) { + out += ReadSymbolAndAdvance(i, end); + } + } else { + DoNormalize(begin, end, out); + } + } + + template <class T, typename TCharType> + inline void Normalize(const TCharType* begin, size_t len, T& out) { return Normalize(begin, begin + len, out); } - template <typename TCharType> - inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& src) { + template <typename TCharType> + inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& src) { if (NPrivate::Normalized<Norm>(src.begin(), src.end())) { // nothing to normalize return src; } else { - TBasicString<TCharType> res; + TBasicString<TCharType> res; res.reserve(src.length()); DoNormalize(src.begin(), src.end(), res); return res; @@ -355,16 +355,16 @@ namespace NUnicode { }; } -//! decompose utf16 or utf32 string to any container supporting push_back or to T* -template <NUnicode::ENormalization Norm, class T, typename TCharType> -inline void Normalize(const TCharType* begin, size_t len, T& out) { +//! decompose utf16 or utf32 string to any container supporting push_back or to T* +template <NUnicode::ENormalization Norm, class T, typename TCharType> +inline void Normalize(const TCharType* begin, size_t len, T& out) { ::NUnicode::TNormalizer<Norm> dec; dec.Normalize(begin, len, out); } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { - TBasicString<TCharType> res; +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { + TBasicString<TCharType> res; res.reserve(len); Normalize<N>(str, len, res); @@ -372,13 +372,13 @@ inline TBasicString<TCharType> Normalize(const TCharType* str, size_t len) { return res; } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TBasicString<TCharType>& str) { ::NUnicode::TNormalizer<N> dec; return dec.Normalize(str); } -template <NUnicode::ENormalization N, typename TCharType> -inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { +template <NUnicode::ENormalization N, typename TCharType> +inline TBasicString<TCharType> Normalize(const TBasicStringBuf<TCharType> str) { return Normalize<N>(str.data(), str.size()); } diff --git a/library/cpp/unicode/normalization/ya.make b/library/cpp/unicode/normalization/ya.make index f6671ff4bc..95bc93f297 100644 --- a/library/cpp/unicode/normalization/ya.make +++ b/library/cpp/unicode/normalization/ya.make @@ -18,7 +18,7 @@ IF(NOT CATBOOST_OPENSOURCE) PEERDIR( library/cpp/charset ) - GENERATE_ENUM_SERIALIZATION(normalization.h) + GENERATE_ENUM_SERIALIZATION(normalization.h) ENDIF() END() diff --git a/util/system/rusage.cpp b/util/system/rusage.cpp index 24d4a2a9c3..2befeca875 100644 --- a/util/system/rusage.cpp +++ b/util/system/rusage.cpp @@ -1,11 +1,11 @@ #include "platform.h" -#if defined(__APPLE__) && defined(__MACH__) - +#if defined(__APPLE__) && defined(__MACH__) + #include <mach/mach.h> - -#endif - + +#endif + #ifdef _win_ #include "winint.h" @@ -35,45 +35,45 @@ TDuration FiletimeToDuration(const FILETIME& ft) { } #endif -size_t TRusage::GetCurrentRSS() { -/* - * Author: David Robert Nadeau - * Site: http://NadeauSoftware.com/ - * License: Creative Commons Attribution 3.0 Unported License - * http://creativecommons.org/licenses/by/3.0/deed.en_US - */ -#if defined(_WIN32) - /* Windows -------------------------------------------------- */ - PROCESS_MEMORY_COUNTERS info; - GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); - return (size_t)info.WorkingSetSize; -#elif defined(__APPLE__) && defined(__MACH__) - /* OSX ------------------------------------------------------ */ - struct mach_task_basic_info info; - mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; - if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, - (task_info_t)&info, &infoCount) != KERN_SUCCESS) - return (size_t)0L; /* Can't access? */ - return (size_t)info.resident_size; -#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) - /* Linux ---------------------------------------------------- */ - long rss = 0L; - FILE* fp = nullptr; +size_t TRusage::GetCurrentRSS() { +/* + * Author: David Robert Nadeau + * Site: http://NadeauSoftware.com/ + * License: Creative Commons Attribution 3.0 Unported License + * http://creativecommons.org/licenses/by/3.0/deed.en_US + */ +#if defined(_WIN32) + /* Windows -------------------------------------------------- */ + PROCESS_MEMORY_COUNTERS info; + GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); + return (size_t)info.WorkingSetSize; +#elif defined(__APPLE__) && defined(__MACH__) + /* OSX ------------------------------------------------------ */ + struct mach_task_basic_info info; + mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; + if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, + (task_info_t)&info, &infoCount) != KERN_SUCCESS) + return (size_t)0L; /* Can't access? */ + return (size_t)info.resident_size; +#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) + /* Linux ---------------------------------------------------- */ + long rss = 0L; + FILE* fp = nullptr; if ((fp = fopen("/proc/self/statm", "r")) == nullptr) { - return (size_t)0L; /* Can't open? */ + return (size_t)0L; /* Can't open? */ + } + if (fscanf(fp, "%*s%ld", &rss) != 1) { + fclose(fp); + return (size_t)0L; /* Can't read? */ } - if (fscanf(fp, "%*s%ld", &rss) != 1) { - fclose(fp); - return (size_t)0L; /* Can't read? */ - } - fclose(fp); - return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE); -#else - /* AIX, BSD, Solaris, and Unknown OS ------------------------ */ - return (size_t)0L; /* Unsupported. */ -#endif -} - + fclose(fp); + return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE); +#else + /* AIX, BSD, Solaris, and Unknown OS ------------------------ */ + return (size_t)0L; /* Unsupported. */ +#endif +} + void TRusage::Fill() { *this = TRusage(); @@ -98,7 +98,7 @@ void TRusage::Fill() { ythrow TSystemError() << "GetProcessMemoryInfo failed"; } - MaxRss = pmc.PeakWorkingSetSize; + MaxRss = pmc.PeakWorkingSetSize; MajorPageFaults = pmc.PageFaultCount; #else @@ -110,9 +110,9 @@ void TRusage::Fill() { #if defined(_darwin_) // see https://lists.apple.com/archives/darwin-kernel/2009/Mar/msg00005.html - MaxRss = ru.ru_maxrss; + MaxRss = ru.ru_maxrss; #else - MaxRss = ru.ru_maxrss * 1024LL; + MaxRss = ru.ru_maxrss * 1024LL; #endif MajorPageFaults = ru.ru_majflt; Utime = ru.ru_utime; diff --git a/util/system/rusage.h b/util/system/rusage.h index efdf29325f..61aeca83f2 100644 --- a/util/system/rusage.h +++ b/util/system/rusage.h @@ -9,15 +9,15 @@ struct TRusage { // some fields may be zero if unsupported - ui64 MaxRss = 0; + ui64 MaxRss = 0; ui64 MajorPageFaults = 0; TDuration Utime; TDuration Stime; void Fill(); - static size_t GetCurrentRSS(); - + static size_t GetCurrentRSS(); + static TRusage Get() { TRusage r; r.Fill(); diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node.cpp index b379607615..aa2e27f028 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node.cpp @@ -43,7 +43,7 @@ TComputationContext::~TComputationContext() { #ifndef NDEBUG if (RssCounter) { Cerr << "UsageOnFinish: graph=" << HolderFactory.GetPagePool().GetUsed() - << ", rss=" << TRusage::Get().MaxRss + << ", rss=" << TRusage::Get().MaxRss << ", peakAlloc=" << HolderFactory.GetPagePool().GetPeakAllocated() << ", adjustor=" << UsageAdjustor << Endl; @@ -52,7 +52,7 @@ TComputationContext::~TComputationContext() { } void TComputationContext::UpdateUsageAdjustor(ui64 memLimit) { - const auto rss = TRusage::Get().MaxRss; + const auto rss = TRusage::Get().MaxRss; if (!InitRss) { LastRss = InitRss = rss; } |