diff options
author | msherbakov <msherbakov@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:16 +0300 |
commit | c224a621661ddd69699f9476922eb316607ef57e (patch) | |
tree | 33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/monlib/encode/spack | |
parent | 29d0b2eeae154d04156e0698067c0c21a97ea61d (diff) | |
download | ydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz |
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/spack')
-rw-r--r-- | library/cpp/monlib/encode/spack/compression.cpp | 46 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/fuzz/main.cpp | 36 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/fuzz/ya.make | 22 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/spack_v1_decoder.cpp | 26 | ||||
-rw-r--r-- | library/cpp/monlib/encode/spack/spack_v1_encoder.cpp | 20 |
5 files changed, 75 insertions, 75 deletions
diff --git a/library/cpp/monlib/encode/spack/compression.cpp b/library/cpp/monlib/encode/spack/compression.cpp index 0d2152fc85..922e11d6ad 100644 --- a/library/cpp/monlib/encode/spack/compression.cpp +++ b/library/cpp/monlib/encode/spack/compression.cpp @@ -1,12 +1,12 @@ #include "compression.h" -#include <util/generic/buffer.h> +#include <util/generic/buffer.h> #include <util/generic/cast.h> #include <util/generic/ptr.h> #include <util/generic/scope.h> -#include <util/generic/size_literals.h> -#include <util/stream/format.h> -#include <util/stream/output.h> +#include <util/generic/size_literals.h> +#include <util/stream/format.h> +#include <util/stream/output.h> #include <util/stream/walk.h> #include <contrib/libs/lz4/lz4.h> @@ -24,10 +24,10 @@ namespace NMonitoring { using TUncompressedSize = ui32; using TCheckSum = ui32; - constexpr size_t COMPRESSED_FRAME_SIZE_LIMIT = 512_KB; - constexpr size_t UNCOMPRESSED_FRAME_SIZE_LIMIT = COMPRESSED_FRAME_SIZE_LIMIT; - constexpr size_t FRAME_SIZE_LIMIT = 2_MB; - constexpr size_t DEFAULT_FRAME_LEN = 64_KB; + constexpr size_t COMPRESSED_FRAME_SIZE_LIMIT = 512_KB; + constexpr size_t UNCOMPRESSED_FRAME_SIZE_LIMIT = COMPRESSED_FRAME_SIZE_LIMIT; + constexpr size_t FRAME_SIZE_LIMIT = 2_MB; + constexpr size_t DEFAULT_FRAME_LEN = 64_KB; struct Y_PACKED TFrameHeader { TCompressedSize CompressedSize; @@ -46,7 +46,7 @@ namespace NMonitoring { TBlock(T&& t) : TStringBuf(t.data(), t.size()) { - Y_ENSURE(t.data() != nullptr); + Y_ENSURE(t.data() != nullptr); } char* data() noexcept { @@ -208,14 +208,14 @@ namespace NMonitoring { return 0; } - Y_ENSURE(header.CompressedSize <= COMPRESSED_FRAME_SIZE_LIMIT, "Compressed frame size is limited to " - << HumanReadableSize(COMPRESSED_FRAME_SIZE_LIMIT, SF_BYTES) - << " but is " << HumanReadableSize(header.CompressedSize, SF_BYTES)); - - Y_ENSURE(header.UncompressedSize <= UNCOMPRESSED_FRAME_SIZE_LIMIT, "Uncompressed frame size is limited to " - << HumanReadableSize(UNCOMPRESSED_FRAME_SIZE_LIMIT, SF_BYTES) - << " but is " << HumanReadableSize(header.UncompressedSize, SF_BYTES)); - + Y_ENSURE(header.CompressedSize <= COMPRESSED_FRAME_SIZE_LIMIT, "Compressed frame size is limited to " + << HumanReadableSize(COMPRESSED_FRAME_SIZE_LIMIT, SF_BYTES) + << " but is " << HumanReadableSize(header.CompressedSize, SF_BYTES)); + + Y_ENSURE(header.UncompressedSize <= UNCOMPRESSED_FRAME_SIZE_LIMIT, "Uncompressed frame size is limited to " + << HumanReadableSize(UNCOMPRESSED_FRAME_SIZE_LIMIT, SF_BYTES) + << " but is " << HumanReadableSize(header.UncompressedSize, SF_BYTES)); + Compressed_.Resize(header.CompressedSize); In_->LoadOrFail(Compressed_.Data(), header.CompressedSize); @@ -307,13 +307,13 @@ namespace NMonitoring { void WriteCompressedFrame() { static const auto framePayload = sizeof(TFrameHeader) + sizeof(TFrameFooter); - const auto maxFrameSize = ui64(TCodecAlg::MaxCompressedLength(Uncompressed_.Size())) + framePayload; - Y_ENSURE(maxFrameSize <= FRAME_SIZE_LIMIT, "Frame size in encoder is limited to " - << HumanReadableSize(FRAME_SIZE_LIMIT, SF_BYTES) - << " but is " << HumanReadableSize(maxFrameSize, SF_BYTES)); - - Frame_.Resize(maxFrameSize); + const auto maxFrameSize = ui64(TCodecAlg::MaxCompressedLength(Uncompressed_.Size())) + framePayload; + Y_ENSURE(maxFrameSize <= FRAME_SIZE_LIMIT, "Frame size in encoder is limited to " + << HumanReadableSize(FRAME_SIZE_LIMIT, SF_BYTES) + << " but is " << HumanReadableSize(maxFrameSize, SF_BYTES)); + Frame_.Resize(maxFrameSize); + // compress TBlock compressedBlock = Frame_; compressedBlock.Skip(sizeof(TFrameHeader)); diff --git a/library/cpp/monlib/encode/spack/fuzz/main.cpp b/library/cpp/monlib/encode/spack/fuzz/main.cpp index 6a14afe71c..c546e392cb 100644 --- a/library/cpp/monlib/encode/spack/fuzz/main.cpp +++ b/library/cpp/monlib/encode/spack/fuzz/main.cpp @@ -1,20 +1,20 @@ #include <library/cpp/monlib/encode/spack/spack_v1.h> #include <library/cpp/monlib/encode/fake/fake.h> - -#include <util/stream/mem.h> - - -extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { - using namespace NMonitoring; - - TMemoryInput min{data, size}; - - auto encoder = EncoderFake(); - - try { - DecodeSpackV1(&min, encoder.Get()); - } catch (...) { - } - - return 0; -} + +#include <util/stream/mem.h> + + +extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { + using namespace NMonitoring; + + TMemoryInput min{data, size}; + + auto encoder = EncoderFake(); + + try { + DecodeSpackV1(&min, encoder.Get()); + } catch (...) { + } + + return 0; +} diff --git a/library/cpp/monlib/encode/spack/fuzz/ya.make b/library/cpp/monlib/encode/spack/fuzz/ya.make index 99b63eadd5..fc41465df3 100644 --- a/library/cpp/monlib/encode/spack/fuzz/ya.make +++ b/library/cpp/monlib/encode/spack/fuzz/ya.make @@ -1,21 +1,21 @@ -FUZZ() - +FUZZ() + OWNER( g:solomon msherbakov -) - +) + FUZZ_OPTS(-rss_limit_mb=1024) -SIZE(MEDIUM) - -PEERDIR( +SIZE(MEDIUM) + +PEERDIR( library/cpp/monlib/encode/spack library/cpp/monlib/encode/fake -) - +) + SRCS( main.cpp ) - -END() + +END() diff --git a/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp b/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp index 1f445fc80d..b3be13f77c 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_decoder.cpp @@ -9,8 +9,8 @@ #include <util/generic/yexception.h> #include <util/generic/buffer.h> -#include <util/generic/size_literals.h> -#include <util/stream/format.h> +#include <util/generic/size_literals.h> +#include <util/stream/format.h> #ifndef _little_endian_ #error Unsupported platform @@ -20,8 +20,8 @@ namespace NMonitoring { namespace { #define DECODE_ENSURE(COND, ...) MONLIB_ENSURE_EX(COND, TSpackDecodeError() << __VA_ARGS__) - constexpr ui64 LABEL_SIZE_LIMIT = 128_MB; - + constexpr ui64 LABEL_SIZE_LIMIT = 128_MB; + /////////////////////////////////////////////////////////////////////// // TDecoderSpackV1 /////////////////////////////////////////////////////////////////////// @@ -63,20 +63,20 @@ namespace NMonitoring { TimePrecision_ = DecodeTimePrecision(Header_.TimePrecision); const ui64 labelSizeTotal = ui64(Header_.LabelNamesSize) + Header_.LabelValuesSize; - + DECODE_ENSURE(labelSizeTotal <= LABEL_SIZE_LIMIT, "Label names & values size of " << HumanReadableSize(labelSizeTotal, SF_BYTES) - << " exceeds the limit which is " << HumanReadableSize(LABEL_SIZE_LIMIT, SF_BYTES)); - + << " exceeds the limit which is " << HumanReadableSize(LABEL_SIZE_LIMIT, SF_BYTES)); + // (2) read string pools - TVector<char> namesBuf(Header_.LabelNamesSize); - readBytes = In_->Load(namesBuf.data(), namesBuf.size()); + TVector<char> namesBuf(Header_.LabelNamesSize); + readBytes = In_->Load(namesBuf.data(), namesBuf.size()); DECODE_ENSURE(readBytes == Header_.LabelNamesSize, "not enough data to read label names pool"); - TStringPool labelNames(namesBuf.data(), namesBuf.size()); + TStringPool labelNames(namesBuf.data(), namesBuf.size()); - TVector<char> valuesBuf(Header_.LabelValuesSize); - readBytes = In_->Load(valuesBuf.data(), valuesBuf.size()); + TVector<char> valuesBuf(Header_.LabelValuesSize); + readBytes = In_->Load(valuesBuf.data(), valuesBuf.size()); DECODE_ENSURE(readBytes == Header_.LabelValuesSize, "not enough data to read label values pool"); - TStringPool labelValues(valuesBuf.data(), valuesBuf.size()); + TStringPool labelValues(valuesBuf.data(), valuesBuf.size()); // (3) read common time c->OnCommonTime(ReadTime()); diff --git a/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp b/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp index a2b0bb5f50..d7c6e1d123 100644 --- a/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp +++ b/library/cpp/monlib/encode/spack/spack_v1_encoder.cpp @@ -17,7 +17,7 @@ namespace NMonitoring { /////////////////////////////////////////////////////////////////////// // TEncoderSpackV1 /////////////////////////////////////////////////////////////////////// - class TEncoderSpackV1 final: public TBufferedEncoderBase { + class TEncoderSpackV1 final: public TBufferedEncoderBase { public: TEncoderSpackV1( IOutputStream* out, @@ -35,8 +35,8 @@ namespace NMonitoring { { MetricsMergingMode_ = mergingMode; - LabelNamesPool_.SetSorted(true); - LabelValuesPool_.SetSorted(true); + LabelNamesPool_.SetSorted(true); + LabelValuesPool_.SetSorted(true); } ~TEncoderSpackV1() override { @@ -45,7 +45,7 @@ namespace NMonitoring { private: void OnDouble(TInstant time, double value) override { - TBufferedEncoderBase::OnDouble(time, value); + TBufferedEncoderBase::OnDouble(time, value); } void OnInt64(TInstant time, i64 value) override { @@ -53,7 +53,7 @@ namespace NMonitoring { } void OnUint64(TInstant time, ui64 value) override { - TBufferedEncoderBase::OnUint64(time, value); + TBufferedEncoderBase::OnUint64(time, value); } void OnHistogram(TInstant time, IHistogramSnapshotPtr snapshot) override { @@ -74,8 +74,8 @@ namespace NMonitoring { } Closed_ = true; - LabelNamesPool_.Build(); - LabelValuesPool_.Build(); + LabelNamesPool_.Build(); + LabelValuesPool_.Build(); // Sort all points uniquely by ts -- the size can decrease ui64 pointsCount = 0; @@ -192,12 +192,12 @@ namespace NMonitoring { void WriteLabels(const TPooledLabels& labels, const TPooledStr* skipKey) { WriteVarUInt32(Out_, static_cast<ui32>(skipKey ? labels.size() - 1 : labels.size())); - for (auto&& label : labels) { + for (auto&& label : labels) { if (label.Key == skipKey) { continue; } - WriteVarUInt32(Out_, label.Key->Index); - WriteVarUInt32(Out_, label.Value->Index); + WriteVarUInt32(Out_, label.Key->Index); + WriteVarUInt32(Out_, label.Value->Index); } } |