diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-06 19:26:39 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-03-06 19:34:29 +0300 |
commit | 77a75357df59b8b6d2c7b5fbe28536f4812f4068 (patch) | |
tree | a856bd04deeb2731aea50346cd8d02b357a446ea | |
parent | 9f62e5d8a4a5ac30109fc0f84125bf5afe00d3db (diff) | |
download | ydb-77a75357df59b8b6d2c7b5fbe28536f4812f4068.tar.gz |
Intermediate changes
-rw-r--r-- | yt/yt/client/queue_client/common.cpp | 1 | ||||
-rw-r--r-- | yt/yt/client/queue_client/common.h | 1 | ||||
-rw-r--r-- | yt/yt/core/misc/hr_timer.cpp | 95 | ||||
-rw-r--r-- | yt/yt/core/misc/hr_timer.h | 53 | ||||
-rw-r--r-- | yt/yt/core/ya.make | 1 |
5 files changed, 2 insertions, 149 deletions
diff --git a/yt/yt/client/queue_client/common.cpp b/yt/yt/client/queue_client/common.cpp index 4d28644043..22beeb98bb 100644 --- a/yt/yt/client/queue_client/common.cpp +++ b/yt/yt/client/queue_client/common.cpp @@ -94,6 +94,7 @@ size_t THash<NYT::NQueueClient::TProfilingTags>::operator()(const NYT::NQueueCli HashCombine(result, tag.Cluster); HashCombine(result, tag.LeadingStatus); HashCombine(result, tag.QueueAgentStage); + HashCombine(result, tag.ObjectType); return result; } diff --git a/yt/yt/client/queue_client/common.h b/yt/yt/client/queue_client/common.h index 0f008f39dc..93e5bc409e 100644 --- a/yt/yt/client/queue_client/common.h +++ b/yt/yt/client/queue_client/common.h @@ -36,6 +36,7 @@ struct TProfilingTags TString Cluster; TString LeadingStatus; TString QueueAgentStage; + TString ObjectType; bool operator==(const TProfilingTags& other) const = default; bool operator<(const TProfilingTags& other) const = default; diff --git a/yt/yt/core/misc/hr_timer.cpp b/yt/yt/core/misc/hr_timer.cpp deleted file mode 100644 index 18a6c1019c..0000000000 --- a/yt/yt/core/misc/hr_timer.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "hr_timer.h" - -#if defined(_linux_) -#include <time.h> -#elif defined(_darwin_) -#include <mach/mach_time.h> -#elif defined(_win_) -// Any other includes? -#endif - -#include <limits> - -namespace NYT::NHRTimer { - -//////////////////////////////////////////////////////////////////////////////// - -static const ui64 NumberOfNsInS = 1000000000UL; -static const i64 NumberOfSamples = 1000UL; - -void GetHRInstant(THRInstant* instant) -{ -#if defined(_linux_) - // See: - // http://stackoverflow.com/questions/6814792/why-is-clock-gettime-so-erratic - // http://stackoverflow.com/questions/7935518/is-clock-gettime-adequate-for-submicrosecond-timing - struct timespec* ts = reinterpret_cast<struct timespec*>(instant); - YT_VERIFY(clock_gettime(CLOCK_REALTIME, ts) == 0); -#elif defined(_darwin_) - // See http://lists.mysql.com/commits/70966 - static mach_timebase_info_data_t info = { 0, 0 }; - if (Y_UNLIKELY(info.denom == 0)) { - YT_VERIFY(mach_timebase_info(&info) == 0); - } - ui64 time; - YT_VERIFY((time = mach_absolute_time())); - time *= info.numer; - time /= info.denom; - instant->Seconds = time / NumberOfNsInS; - instant->Nanoseconds = time % NumberOfNsInS; -#elif defined(_win_) - static LARGE_INTEGER frequency = { 0 }; - if (Y_UNLIKELY(frequency.QuadPart == 0)) { - YT_VERIFY(QueryPerformanceFrequency(&frequency)); - - } - LARGE_INTEGER time; - YT_VERIFY((QueryPerformanceCounter(&time))); - instant->Seconds = time.QuadPart / frequency.QuadPart; - instant->Nanoseconds = (time.QuadPart % frequency.QuadPart) * NumberOfNsInS / frequency.QuadPart; -#else - #error "Unsupported architecture" -#endif -} - -THRDuration GetHRDuration(const THRInstant& begin, const THRInstant& end) -{ - if (end.Seconds == begin.Seconds) { - YT_ASSERT(end.Nanoseconds >= begin.Nanoseconds); - return end.Nanoseconds - begin.Nanoseconds; - } - - YT_ASSERT( - end.Seconds > begin.Seconds && - end.Seconds - begin.Seconds < - static_cast<i64>(std::numeric_limits<THRDuration>::max() / NumberOfNsInS)); - - return - ( end.Seconds - begin.Seconds ) * NumberOfNsInS - + end.Nanoseconds - begin.Nanoseconds; -} - -THRDuration GetHRResolution() -{ - static THRDuration result = 0; - if (Y_LIKELY(result)) { - return result; - } - - std::vector<THRDuration> samples(NumberOfSamples); - THRInstant begin; - THRInstant end; - for (int i = 0; i < NumberOfSamples; ++i) { - GetHRInstant(&begin); - GetHRInstant(&end); - samples[i] = GetHRDuration(begin, end); - } - - std::sort(samples.begin(), samples.end()); - result = samples[samples.size() / 2]; - return result; -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NHRTimer diff --git a/yt/yt/core/misc/hr_timer.h b/yt/yt/core/misc/hr_timer.h deleted file mode 100644 index a39223f2c4..0000000000 --- a/yt/yt/core/misc/hr_timer.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "common.h" - -#include <util/system/datetime.h> - -namespace NYT::NHRTimer { - -//////////////////////////////////////////////////////////////////////////////// - -// Returns CPU internal cycle counter. -// On modern systems, cycle counters are consistent across cores and cycle rate -// can be considered constant for practical purposes. -Y_FORCE_INLINE ui64 GetRdtsc() -{ - return GetCycleCount(); -} - -// Represents an offset from an arbitrary point in the past; -// it should be used only for relative measurements. -struct THRInstant -{ - i64 Seconds; - i64 Nanoseconds; -}; - -// Represents a duration in nano-seconds. -using THRDuration = ui64; - -#ifdef _linux_ -static_assert( - sizeof(THRInstant) == sizeof(struct timespec), - "THRInstant should be ABI-compatible with struct timespec"); -static_assert( - offsetof(THRInstant, Seconds) == offsetof(struct timespec, tv_sec), - "THRInstant should be ABI-compatible with struct timespec"); -static_assert( - offsetof(THRInstant, Nanoseconds) == offsetof(struct timespec, tv_nsec), - "THRInstant should be ABI-compatible with struct timespec"); -#endif - -// Returns instant. -void GetHRInstant(THRInstant* instant); - -// Returns time difference in nanoseconds. -THRDuration GetHRDuration(const THRInstant& begin, const THRInstant& end); - -// Returns instant resolution. -THRDuration GetHRResolution(); - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NHRTimer diff --git a/yt/yt/core/ya.make b/yt/yt/core/ya.make index 8d449fdc30..6ca8870f3c 100644 --- a/yt/yt/core/ya.make +++ b/yt/yt/core/ya.make @@ -129,7 +129,6 @@ SRCS( misc/hedging_manager.cpp misc/histogram.cpp misc/adjusted_exponential_moving_average.cpp - misc/hr_timer.cpp misc/id_generator.cpp misc/linear_probe.cpp misc/memory_reference_tracker.cpp |