aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/cpp/blockcodecs/codecs.h2
-rw-r--r--library/cpp/json/json_value.h2
-rw-r--r--library/cpp/monlib/metrics/fake.h10
-rw-r--r--library/cpp/monlib/metrics/metric.h16
-rw-r--r--library/cpp/monlib/metrics/metric_registry.cpp58
-rw-r--r--library/cpp/monlib/metrics/metric_registry.h38
-rw-r--r--library/cpp/neh/http2.cpp9
-rw-r--r--library/cpp/neh/https.cpp14
-rw-r--r--library/cpp/svnversion/svnversion.h2
-rw-r--r--library/cpp/testing/common/env.cpp10
-rw-r--r--library/cpp/testing/common/env.h1
-rw-r--r--library/cpp/testing/gtest/gtest.h2
-rw-r--r--library/cpp/testing/gtest_extensions/gtest_extensions.h2
-rw-r--r--library/cpp/threading/future/future.h2
-rw-r--r--library/cpp/threading/local_executor/local_executor.h7
-rw-r--r--library/cpp/threading/local_executor/tbb_local_executor.cpp18
-rw-r--r--library/cpp/threading/local_executor/tbb_local_executor.h10
-rw-r--r--library/cpp/tld/tlds-alpha-by-domain.txt2
18 files changed, 104 insertions, 101 deletions
diff --git a/library/cpp/blockcodecs/codecs.h b/library/cpp/blockcodecs/codecs.h
index fd499b54b0..43a9244465 100644
--- a/library/cpp/blockcodecs/codecs.h
+++ b/library/cpp/blockcodecs/codecs.h
@@ -1,3 +1,3 @@
#pragma once
-#include <library/cpp/blockcodecs/core/codecs.h>
+#include <library/cpp/blockcodecs/core/codecs.h> // IWYU pragma: export
diff --git a/library/cpp/json/json_value.h b/library/cpp/json/json_value.h
index f70f4d2ee8..47273f6b13 100644
--- a/library/cpp/json/json_value.h
+++ b/library/cpp/json/json_value.h
@@ -1,3 +1,3 @@
#pragma once
-#include <library/cpp/json/writer/json_value.h>
+#include <library/cpp/json/writer/json_value.h> // IWYU pragma: export
diff --git a/library/cpp/monlib/metrics/fake.h b/library/cpp/monlib/metrics/fake.h
index b01ff2505a..a058e1d99a 100644
--- a/library/cpp/monlib/metrics/fake.h
+++ b/library/cpp/monlib/metrics/fake.h
@@ -82,6 +82,8 @@ namespace NMonitoring {
i64 Get() const noexcept override {
return 0;
}
+
+ void Reset() noexcept override {}
};
struct TFakeRate final: public TFakeAcceptor<IRate> {
@@ -102,6 +104,8 @@ namespace NMonitoring {
ui64 Get() const noexcept override {
return 0;
}
+
+ void Reset() noexcept override {}
};
struct TFakeGauge final: public TFakeAcceptor<IGauge> {
@@ -117,12 +121,16 @@ namespace NMonitoring {
double Get() const noexcept override {
return 0;
}
+
+ void Reset() noexcept override {}
};
struct TFakeLazyGauge final: public TFakeAcceptor<ILazyGauge> {
double Get() const noexcept override {
return 0;
}
+
+ void Reset() noexcept override {}
};
struct TFakeHistogram final: public IHistogram {
@@ -169,5 +177,7 @@ namespace NMonitoring {
ui64 Get() const noexcept override {
return 0;
}
+
+ void Reset() noexcept override {}
};
} // namespace NMonitoring
diff --git a/library/cpp/monlib/metrics/metric.h b/library/cpp/monlib/metrics/metric.h
index 2f7d9de687..bb5fda322e 100644
--- a/library/cpp/monlib/metrics/metric.h
+++ b/library/cpp/monlib/metrics/metric.h
@@ -15,6 +15,7 @@ namespace NMonitoring {
virtual EMetricType Type() const noexcept = 0;
virtual void Accept(TInstant time, IMetricConsumer* consumer) const = 0;
+ virtual void Reset() noexcept = 0;
};
using IMetricPtr = TIntrusivePtr<IMetric>;
@@ -28,7 +29,7 @@ namespace NMonitoring {
virtual double Add(double n) noexcept = 0;
virtual void Set(double n) noexcept = 0;
virtual double Get() const noexcept = 0;
- virtual void Reset() noexcept {
+ void Reset() noexcept override {
Set(0);
}
};
@@ -58,7 +59,7 @@ namespace NMonitoring {
virtual void Set(i64 value) noexcept = 0;
virtual i64 Get() const noexcept = 0;
- virtual void Reset() noexcept {
+ void Reset() noexcept override {
Set(0);
}
};
@@ -84,7 +85,6 @@ namespace NMonitoring {
virtual ui64 Add(ui64 n) noexcept = 0;
virtual ui64 Get() const noexcept = 0;
- virtual void Reset() noexcept = 0;
};
class ILazyCounter: public IMetric {
@@ -108,7 +108,6 @@ namespace NMonitoring {
virtual ui64 Add(ui64 n) noexcept = 0;
virtual ui64 Get() const noexcept = 0;
- virtual void Reset() noexcept = 0;
};
class ILazyRate: public IMetric {
@@ -134,7 +133,6 @@ namespace NMonitoring {
virtual void Record(double value) noexcept = 0;
virtual void Record(double value, ui32 count) noexcept = 0;
virtual IHistogramSnapshotPtr TakeSnapshot() const = 0;
- virtual void Reset() noexcept = 0;
protected:
const bool IsRate_;
@@ -194,6 +192,8 @@ namespace NMonitoring {
consumer->OnDouble(time, Get());
}
+ void Reset() noexcept override {}
+
private:
std::function<double()> Supplier_;
};
@@ -245,6 +245,8 @@ namespace NMonitoring {
consumer->OnInt64(time, Get());
}
+ void Reset() noexcept override {}
+
private:
std::function<i64()> Supplier_;
};
@@ -296,6 +298,8 @@ namespace NMonitoring {
consumer->OnUint64(time, Get());
}
+ void Reset() noexcept override {}
+
private:
std::function<ui64()> Supplier_;
};
@@ -347,6 +351,8 @@ namespace NMonitoring {
consumer->OnUint64(time, Get());
}
+ void Reset() noexcept override {}
+
private:
std::function<ui64()> Supplier_;
};
diff --git a/library/cpp/monlib/metrics/metric_registry.cpp b/library/cpp/monlib/metrics/metric_registry.cpp
index 245f65702d..dbbea603c1 100644
--- a/library/cpp/monlib/metrics/metric_registry.cpp
+++ b/library/cpp/monlib/metrics/metric_registry.cpp
@@ -226,29 +226,7 @@ namespace NMonitoring {
void TMetricRegistry::Reset() {
TWriteGuard g{*Lock_};
for (auto& [label, metricValue] : Metrics_) {
- auto metric = metricValue.Metric;
- switch (metric->Type()) {
- case EMetricType::GAUGE:
- static_cast<TGauge*>(metric.Get())->Set(.0);
- break;
- case EMetricType::IGAUGE:
- static_cast<TIntGauge*>(metric.Get())->Set(0);
- break;
- case EMetricType::COUNTER:
- static_cast<TCounter*>(metric.Get())->Reset();
- break;
- case EMetricType::RATE:
- static_cast<TRate*>(metric.Get())->Reset();
- break;
- case EMetricType::HIST:
- case EMetricType::HIST_RATE:
- static_cast<THistogram*>(metric.Get())->Reset();
- break;
- case EMetricType::UNKNOWN:
- case EMetricType::DSUMMARY:
- case EMetricType::LOGHIST:
- break;
- }
+ metricValue.Metric->Reset();
}
}
@@ -257,40 +235,6 @@ namespace NMonitoring {
Metrics_.clear();
}
- template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args>
- TMetric* TMetricRegistry::Metric(TLabelsType&& labels, TMetricOpts&& opts, Args&&... args) {
- {
- TReadGuard g{*Lock_};
-
- auto it = Metrics_.find(labels);
- if (it != Metrics_.end()) {
- Y_ENSURE(it->second.Metric->Type() == type, "cannot create metric " << labels
- << " with type " << MetricTypeToStr(type)
- << ", because registry already has same metric with type " << MetricTypeToStr(it->second.Metric->Type()));
- Y_ENSURE(it->second.Opts.MemOnly == opts.MemOnly,"cannot create metric " << labels
- << " with memOnly=" << opts.MemOnly
- << ", because registry already has same metric with memOnly=" << it->second.Opts.MemOnly);
- return static_cast<TMetric*>(it->second.Metric.Get());
- }
- }
-
- {
- IMetricPtr metric = MakeIntrusive<TMetric>(std::forward<Args>(args)...);
-
- TWriteGuard g{*Lock_};
- // decltype(Metrics_)::iterator breaks build on windows
- THashMap<ILabelsPtr, TMetricValue>::iterator it;
- TMetricValue metricValue = {metric, opts};
- if constexpr (!std::is_convertible_v<TLabelsType, ILabelsPtr>) {
- it = Metrics_.emplace(new TLabels{std::forward<TLabelsType>(labels)}, std::move(metricValue)).first;
- } else {
- it = Metrics_.emplace(std::forward<TLabelsType>(labels), std::move(metricValue)).first;
- }
-
- return static_cast<TMetric*>(it->second.Metric.Get());
- }
- }
-
void TMetricRegistry::RemoveMetric(const ILabels& labels) noexcept {
TWriteGuard g{*Lock_};
Metrics_.erase(labels);
diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h
index f60467cf91..7669a8c088 100644
--- a/library/cpp/monlib/metrics/metric_registry.h
+++ b/library/cpp/monlib/metrics/metric_registry.h
@@ -274,13 +274,45 @@ namespace NMonitoring {
TMetricOpts Opts;
};
+ protected:
+ template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args>
+ TMetric* Metric(TLabelsType&& labels, TMetricOpts&& opts, Args&&... args) {
+ {
+ TReadGuard g{*Lock_};
+
+ auto it = Metrics_.find(labels);
+ if (it != Metrics_.end()) {
+ Y_ENSURE(it->second.Metric->Type() == type, "cannot create metric " << labels
+ << " with type " << MetricTypeToStr(type)
+ << ", because registry already has same metric with type " << MetricTypeToStr(it->second.Metric->Type()));
+ Y_ENSURE(it->second.Opts.MemOnly == opts.MemOnly,"cannot create metric " << labels
+ << " with memOnly=" << opts.MemOnly
+ << ", because registry already has same metric with memOnly=" << it->second.Opts.MemOnly);
+ return static_cast<TMetric*>(it->second.Metric.Get());
+ }
+ }
+
+ {
+ IMetricPtr metric = MakeIntrusive<TMetric>(std::forward<Args>(args)...);
+
+ TWriteGuard g{*Lock_};
+ // decltype(Metrics_)::iterator breaks build on windows
+ THashMap<ILabelsPtr, TMetricValue>::iterator it;
+ TMetricValue metricValue = {metric, opts};
+ if constexpr (!std::is_convertible_v<TLabelsType, ILabelsPtr>) {
+ it = Metrics_.emplace(new TLabels{std::forward<TLabelsType>(labels)}, std::move(metricValue)).first;
+ } else {
+ it = Metrics_.emplace(std::forward<TLabelsType>(labels), std::move(metricValue)).first;
+ }
+
+ return static_cast<TMetric*>(it->second.Metric.Get());
+ }
+ }
+
private:
THolder<TRWMutex> Lock_ = MakeHolder<TRWMutex>();
THashMap<ILabelsPtr, TMetricValue> Metrics_;
- template <typename TMetric, EMetricType type, typename TLabelsType, typename... Args>
- TMetric* Metric(TLabelsType&& labels, TMetricOpts&& opts, Args&&... args);
-
TLabels CommonLabels_;
};
diff --git a/library/cpp/neh/http2.cpp b/library/cpp/neh/http2.cpp
index f10fdc3b3e..daf73ba0d1 100644
--- a/library/cpp/neh/http2.cpp
+++ b/library/cpp/neh/http2.cpp
@@ -912,7 +912,6 @@ namespace {
THttpConnManager()
: TotalConn(0)
, EP_(THttp2Options::AsioThreads)
- , InPurging_(0)
, MaxConnId_(0)
, Shutdown_(false)
{
@@ -1011,7 +1010,7 @@ namespace {
}
void SuggestPurgeCache() {
- if (AtomicTryLock(&InPurging_)) {
+ if (InPurging_.TryAcquire()) {
//evaluate the usefulness of purging the cache
//если в кеше мало соединений (< MaxConnId_/16 или 64), не чистим кеш
if (Cache_.Size() > (Min((size_t)AtomicGet(MaxConnId_), (size_t)1024U) >> 4)) {
@@ -1031,7 +1030,7 @@ namespace {
return; //memo: thread MUST unlock InPurging_ (see DoExecute())
}
}
- AtomicUnlock(&InPurging_);
+ InPurging_.Release();
}
}
@@ -1049,7 +1048,7 @@ namespace {
PurgeCache();
- AtomicUnlock(&InPurging_);
+ InPurging_.Release();
}
}
@@ -1076,7 +1075,7 @@ namespace {
TExecutorsPool EP_;
TConnCache<THttpConn> Cache_;
- TAtomic InPurging_;
+ TSpinLock InPurging_;
TAtomic MaxConnId_;
TAutoPtr<IThreadFactory::IThread> T_;
diff --git a/library/cpp/neh/https.cpp b/library/cpp/neh/https.cpp
index ece7d3cf2d..99db8a44cc 100644
--- a/library/cpp/neh/https.cpp
+++ b/library/cpp/neh/https.cpp
@@ -11,7 +11,6 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
-#include <openssl/bio.h>
#include <openssl/x509v3.h>
#include <library/cpp/openssl/init/init.h>
@@ -26,12 +25,10 @@
#include <util/generic/list.h>
#include <util/generic/utility.h>
#include <util/network/socket.h>
-#include <util/stream/str.h>
#include <util/stream/zlib.h>
#include <util/string/builder.h>
#include <util/string/cast.h>
#include <util/system/condvar.h>
-#include <util/system/error.h>
#include <util/system/types.h>
#include <util/thread/factory.h>
@@ -448,8 +445,7 @@ namespace NNeh {
};
TConnCache()
- : InPurging_(0)
- , MaxConnId_(0)
+ : MaxConnId_(0)
, Shutdown_(false)
{
T_ = SystemThreadFactory()->Run(this);
@@ -557,7 +553,7 @@ namespace NNeh {
private:
void SuggestPurgeCache() {
- if (AtomicTryLock(&InPurging_)) {
+ if (InPurging_.TryAcquire()) {
//evaluate the usefulness of purging the cache
//если в кеше мало соединений (< MaxConnId_/16 или 64), не чистим кеш
if ((size_t)CachedConnections.Val() > (Min((size_t)MaxConnId_.load(std::memory_order_acquire), (size_t)1024U) >> 4)) {
@@ -577,7 +573,7 @@ namespace NNeh {
return; //memo: thread MUST unlock InPurging_ (see DoExecute())
}
}
- AtomicUnlock(&InPurging_);
+ InPurging_.Release();
}
}
@@ -594,7 +590,7 @@ namespace NNeh {
PurgeCache();
- AtomicUnlock(&InPurging_);
+ InPurging_.Release();
}
}
@@ -660,7 +656,7 @@ namespace NNeh {
NHttp::TLockFreeSequence<TConnList> Lst_;
- TAtomic InPurging_;
+ TSpinLock InPurging_;
std::atomic<size_t> MaxConnId_;
TAutoPtr<IThreadFactory::IThread> T_;
diff --git a/library/cpp/svnversion/svnversion.h b/library/cpp/svnversion/svnversion.h
index b99615daa9..b1f8de5723 100644
--- a/library/cpp/svnversion/svnversion.h
+++ b/library/cpp/svnversion/svnversion.h
@@ -10,4 +10,4 @@
#include <util/system/compiler.h>
// Automatically generated functions.
-#include "build/scripts/c_templates/svnversion.h"
+#include <build/scripts/c_templates/svnversion.h> // IWYU pragma: export
diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp
index 1440186d78..41bf2b20ab 100644
--- a/library/cpp/testing/common/env.cpp
+++ b/library/cpp/testing/common/env.cpp
@@ -141,7 +141,6 @@ namespace NPrivate {
void TTestEnv::ReInitialize() {
IsRunningFromTest = false;
- ArcadiaTestsDataDir = "";
SourceRoot = "";
BuildRoot = "";
WorkPath = "";
@@ -171,11 +170,6 @@ namespace NPrivate {
BuildRoot = value->GetStringSafe("");
}
- value = context.GetValueByPath("runtime.atd_root");
- if (value) {
- ArcadiaTestsDataDir = value->GetStringSafe("");
- }
-
value = context.GetValueByPath("runtime.work_path");
if (value) {
WorkPath = value->GetStringSafe("");
@@ -249,10 +243,6 @@ namespace NPrivate {
BuildRoot = GetEnv("ARCADIA_BUILD_ROOT");
}
- if (!ArcadiaTestsDataDir) {
- ArcadiaTestsDataDir = GetEnv("ARCADIA_TESTS_DATA_DIR");
- }
-
if (!WorkPath) {
WorkPath = GetEnv("TEST_WORK_PATH");
}
diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h
index 6cd840442f..f9a5aff5d3 100644
--- a/library/cpp/testing/common/env.h
+++ b/library/cpp/testing/common/env.h
@@ -69,7 +69,6 @@ namespace NPrivate {
void AddTestParam(TStringBuf name, TStringBuf value);
bool IsRunningFromTest;
- TString ArcadiaTestsDataDir;
TString SourceRoot;
TString BuildRoot;
TString WorkPath;
diff --git a/library/cpp/testing/gtest/gtest.h b/library/cpp/testing/gtest/gtest.h
index a4d0c775d0..258a4459a9 100644
--- a/library/cpp/testing/gtest/gtest.h
+++ b/library/cpp/testing/gtest/gtest.h
@@ -1,11 +1,13 @@
#pragma once
+// IWYU pragma: begin_exports
#include <library/cpp/testing/gtest/matchers.h>
#include <library/cpp/testing/gtest_extensions/gtest_extensions.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
+// IWYU pragma: end_exports
#include <optional>
#include <string_view>
diff --git a/library/cpp/testing/gtest_extensions/gtest_extensions.h b/library/cpp/testing/gtest_extensions/gtest_extensions.h
index e20532241e..e4f336fd54 100644
--- a/library/cpp/testing/gtest_extensions/gtest_extensions.h
+++ b/library/cpp/testing/gtest_extensions/gtest_extensions.h
@@ -1,6 +1,8 @@
#pragma once
+// IWYU pragma: begin_exports
#include "assertions.h"
#include "matchers.h"
#include "pretty_printers.h"
#include "probe.h"
+// IWYU pragma: end_exports
diff --git a/library/cpp/threading/future/future.h b/library/cpp/threading/future/future.h
index 35db9abbe2..91ade3f6e5 100644
--- a/library/cpp/threading/future/future.h
+++ b/library/cpp/threading/future/future.h
@@ -1,4 +1,6 @@
#pragma once
+// IWYU pragma: begin_exports
#include "core/future.h"
#include "wait/wait.h"
+// IWYU pragma: end_exports
diff --git a/library/cpp/threading/local_executor/local_executor.h b/library/cpp/threading/local_executor/local_executor.h
index c1c824f67c..4eb67b034e 100644
--- a/library/cpp/threading/local_executor/local_executor.h
+++ b/library/cpp/threading/local_executor/local_executor.h
@@ -54,8 +54,12 @@ namespace NPar {
// @param flags Same as for `Exec`.
virtual void ExecRange(TIntrusivePtr<ILocallyExecutable> exec, int firstId, int lastId, int flags) = 0;
- // 0-based ILocalExecutor worker thread identification
+ // returns:
+ // 0 for for a thread outside the internal pool
+ // (because ILocalExecutor is allowed to use a calling thread to execute tasks as well),
+ // 1 ... GetThreadCount() for a thread inside the internal pool
virtual int GetWorkerThreadId() const noexcept = 0;
+
virtual int GetThreadCount() const noexcept = 0;
// Describes a range of tasks with parameters from integer range [FirstId, LastId).
@@ -237,7 +241,6 @@ namespace NPar {
int GetLPQueueSize() const noexcept;
void ClearLPQueue();
- // 0-based TLocalExecutor worker thread identification
int GetWorkerThreadId() const noexcept override;
int GetThreadCount() const noexcept override;
diff --git a/library/cpp/threading/local_executor/tbb_local_executor.cpp b/library/cpp/threading/local_executor/tbb_local_executor.cpp
index 65d6659443..91a8460b0e 100644
--- a/library/cpp/threading/local_executor/tbb_local_executor.cpp
+++ b/library/cpp/threading/local_executor/tbb_local_executor.cpp
@@ -14,9 +14,21 @@ int NPar::TTbbLocalExecutor<RespectTls>::GetThreadCount() const noexcept {
template <bool RespectTls>
int NPar::TTbbLocalExecutor<RespectTls>::GetWorkerThreadId() const noexcept {
- return TbbArena.execute([] {
- return tbb::this_task_arena::current_thread_index();
- });
+ static thread_local int WorkerThreadId = -1;
+ if (WorkerThreadId == -1) {
+ // Can't rely on return value except checking that it is 'not_initialized' because of
+ // "Since a thread may exit the arena at any time if it does not execute a task, the index of
+ // a thread may change between any two tasks"
+ // (https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/task_scheduler/task_arena/this_task_arena_ns#_CPPv4N3tbb15this_task_arena20current_thread_indexEv)
+ const auto tbbThreadIndex = tbb::this_task_arena::current_thread_index();
+ if (tbbThreadIndex == tbb::task_arena::not_initialized) {
+ // This thread does not belong to TBB worker threads
+ WorkerThreadId = 0;
+ } else {
+ WorkerThreadId = ++RegisteredThreadCounter;
+ }
+ }
+ return WorkerThreadId;
}
template <bool RespectTls>
diff --git a/library/cpp/threading/local_executor/tbb_local_executor.h b/library/cpp/threading/local_executor/tbb_local_executor.h
index 8d790db18c..f67c07349d 100644
--- a/library/cpp/threading/local_executor/tbb_local_executor.h
+++ b/library/cpp/threading/local_executor/tbb_local_executor.h
@@ -9,6 +9,9 @@
#include <contrib/libs/tbb/include/tbb/task_arena.h>
#include <contrib/libs/tbb/include/tbb/task_group.h>
+#include <atomic>
+
+
namespace NPar {
template <bool RespectTls = false>
class TTbbLocalExecutor final: public ILocalExecutor {
@@ -16,10 +19,11 @@ namespace NPar {
TTbbLocalExecutor(int nThreads)
: ILocalExecutor()
, TbbArena(nThreads)
- , NumberOfTbbThreads(nThreads) {}
+ , NumberOfTbbThreads(nThreads)
+ , RegisteredThreadCounter(0)
+ {}
~TTbbLocalExecutor() noexcept override {}
- // 0-based ILocalExecutor worker thread identification
virtual int GetWorkerThreadId() const noexcept override;
virtual int GetThreadCount() const noexcept override;
@@ -45,5 +49,7 @@ namespace NPar {
mutable tbb::task_arena TbbArena;
tbb::task_group Group;
int NumberOfTbbThreads;
+
+ mutable std::atomic_int RegisteredThreadCounter;
};
}
diff --git a/library/cpp/tld/tlds-alpha-by-domain.txt b/library/cpp/tld/tlds-alpha-by-domain.txt
index a118629445..99d76b90cb 100644
--- a/library/cpp/tld/tlds-alpha-by-domain.txt
+++ b/library/cpp/tld/tlds-alpha-by-domain.txt
@@ -1,4 +1,4 @@
-# Version 2025033101, Last Updated Tue Apr 1 07:07:01 2025 UTC
+# Version 2025040700, Last Updated Mon Apr 7 07:07:01 2025 UTC
AAA
AARP
ABB