aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-08-23 12:34:36 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-08-23 12:49:44 +0300
commit10ac4b53185c5638e7dae756765beb5f60019451 (patch)
treef585d14c643a169289d30d80949eeca66ebf3480 /contrib
parent319516652c1958750928209614d95cef4f97bf02 (diff)
downloadydb-10ac4b53185c5638e7dae756765beb5f60019451.tar.gz
Intermediate changes
Diffstat (limited to 'contrib')
-rw-r--r--contrib/restricted/google/benchmark/include/benchmark/benchmark.h7
-rw-r--r--contrib/restricted/google/benchmark/src/benchmark.cc14
-rw-r--r--contrib/restricted/google/benchmark/src/benchmark_api_internal.cc9
-rw-r--r--contrib/restricted/google/benchmark/src/benchmark_api_internal.h3
-rw-r--r--contrib/restricted/google/benchmark/src/benchmark_runner.cc29
-rw-r--r--contrib/restricted/google/benchmark/src/complexity.cc12
-rw-r--r--contrib/restricted/google/benchmark/src/perf_counters.cc2
-rw-r--r--contrib/restricted/google/benchmark/test/ya.make2
-rw-r--r--contrib/restricted/google/benchmark/tools/compare/ya.make4
-rw-r--r--contrib/restricted/google/benchmark/tools/ya.make2
-rw-r--r--contrib/restricted/google/benchmark/ya.make6
11 files changed, 44 insertions, 46 deletions
diff --git a/contrib/restricted/google/benchmark/include/benchmark/benchmark.h b/contrib/restricted/google/benchmark/include/benchmark/benchmark.h
index c80105df55..4cdb4515cb 100644
--- a/contrib/restricted/google/benchmark/include/benchmark/benchmark.h
+++ b/contrib/restricted/google/benchmark/include/benchmark/benchmark.h
@@ -1004,7 +1004,8 @@ class BENCHMARK_EXPORT State {
State(std::string name, IterationCount max_iters,
const std::vector<int64_t>& ranges, int thread_i, int n_threads,
internal::ThreadTimer* timer, internal::ThreadManager* manager,
- internal::PerfCountersMeasurement* perf_counters_measurement);
+ internal::PerfCountersMeasurement* perf_counters_measurement,
+ ProfilerManager* profiler_manager);
void StartKeepRunning();
// Implementation of KeepRunning() and KeepRunningBatch().
@@ -1019,6 +1020,7 @@ class BENCHMARK_EXPORT State {
internal::ThreadTimer* const timer_;
internal::ThreadManager* const manager_;
internal::PerfCountersMeasurement* const perf_counters_measurement_;
+ ProfilerManager* const profiler_manager_;
friend class internal::BenchmarkInstance;
};
@@ -1832,14 +1834,11 @@ class BENCHMARK_EXPORT BenchmarkReporter {
internal::Skipped skipped;
std::string skip_message;
- // Total iterations across all threads.
IterationCount iterations;
int64_t threads;
int64_t repetition_index;
int64_t repetitions;
TimeUnit time_unit;
-
- // Total time across all threads.
double real_accumulated_time;
double cpu_accumulated_time;
diff --git a/contrib/restricted/google/benchmark/src/benchmark.cc b/contrib/restricted/google/benchmark/src/benchmark.cc
index 374c5141c9..b7767bd00a 100644
--- a/contrib/restricted/google/benchmark/src/benchmark.cc
+++ b/contrib/restricted/google/benchmark/src/benchmark.cc
@@ -168,7 +168,8 @@ void UseCharPointer(char const volatile* const v) {
State::State(std::string name, IterationCount max_iters,
const std::vector<int64_t>& ranges, int thread_i, int n_threads,
internal::ThreadTimer* timer, internal::ThreadManager* manager,
- internal::PerfCountersMeasurement* perf_counters_measurement)
+ internal::PerfCountersMeasurement* perf_counters_measurement,
+ ProfilerManager* profiler_manager)
: total_iterations_(0),
batch_leftover_(0),
max_iterations(max_iters),
@@ -182,7 +183,8 @@ State::State(std::string name, IterationCount max_iters,
threads_(n_threads),
timer_(timer),
manager_(manager),
- perf_counters_measurement_(perf_counters_measurement) {
+ perf_counters_measurement_(perf_counters_measurement),
+ profiler_manager_(profiler_manager) {
BM_CHECK(max_iterations != 0) << "At least one iteration must be run";
BM_CHECK_LT(thread_index_, threads_)
<< "thread_index must be less than threads";
@@ -207,7 +209,7 @@ State::State(std::string name, IterationCount max_iters,
#if defined(__INTEL_COMPILER)
#pragma warning push
#pragma warning(disable : 1875)
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#endif
@@ -225,7 +227,7 @@ State::State(std::string name, IterationCount max_iters,
offsetof(State, skipped_) <= (cache_line_size - sizeof(skipped_)), "");
#if defined(__INTEL_COMPILER)
#pragma warning pop
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#if defined(__NVCC__)
@@ -302,6 +304,8 @@ void State::StartKeepRunning() {
BM_CHECK(!started_ && !finished_);
started_ = true;
total_iterations_ = skipped() ? 0 : max_iterations;
+ if (BENCHMARK_BUILTIN_EXPECT(profiler_manager_ != nullptr, false))
+ profiler_manager_->AfterSetupStart();
manager_->StartStopBarrier();
if (!skipped()) ResumeTiming();
}
@@ -315,6 +319,8 @@ void State::FinishKeepRunning() {
total_iterations_ = 0;
finished_ = true;
manager_->StartStopBarrier();
+ if (BENCHMARK_BUILTIN_EXPECT(profiler_manager_ != nullptr, false))
+ profiler_manager_->BeforeTeardownStop();
}
namespace internal {
diff --git a/contrib/restricted/google/benchmark/src/benchmark_api_internal.cc b/contrib/restricted/google/benchmark/src/benchmark_api_internal.cc
index 286f986530..4b569d7982 100644
--- a/contrib/restricted/google/benchmark/src/benchmark_api_internal.cc
+++ b/contrib/restricted/google/benchmark/src/benchmark_api_internal.cc
@@ -92,9 +92,10 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx,
State BenchmarkInstance::Run(
IterationCount iters, int thread_id, internal::ThreadTimer* timer,
internal::ThreadManager* manager,
- internal::PerfCountersMeasurement* perf_counters_measurement) const {
+ internal::PerfCountersMeasurement* perf_counters_measurement,
+ ProfilerManager* profiler_manager) const {
State st(name_.function_name, iters, args_, thread_id, threads_, timer,
- manager, perf_counters_measurement);
+ manager, perf_counters_measurement, profiler_manager);
benchmark_.Run(st);
return st;
}
@@ -102,7 +103,7 @@ State BenchmarkInstance::Run(
void BenchmarkInstance::Setup() const {
if (setup_) {
State st(name_.function_name, /*iters*/ 1, args_, /*thread_id*/ 0, threads_,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr, nullptr);
setup_(st);
}
}
@@ -110,7 +111,7 @@ void BenchmarkInstance::Setup() const {
void BenchmarkInstance::Teardown() const {
if (teardown_) {
State st(name_.function_name, /*iters*/ 1, args_, /*thread_id*/ 0, threads_,
- nullptr, nullptr, nullptr);
+ nullptr, nullptr, nullptr, nullptr);
teardown_(st);
}
}
diff --git a/contrib/restricted/google/benchmark/src/benchmark_api_internal.h b/contrib/restricted/google/benchmark/src/benchmark_api_internal.h
index 94f516531b..659a71440e 100644
--- a/contrib/restricted/google/benchmark/src/benchmark_api_internal.h
+++ b/contrib/restricted/google/benchmark/src/benchmark_api_internal.h
@@ -44,7 +44,8 @@ class BenchmarkInstance {
State Run(IterationCount iters, int thread_id, internal::ThreadTimer* timer,
internal::ThreadManager* manager,
- internal::PerfCountersMeasurement* perf_counters_measurement) const;
+ internal::PerfCountersMeasurement* perf_counters_measurement,
+ ProfilerManager* profiler_manager) const;
private:
BenchmarkName name_;
diff --git a/contrib/restricted/google/benchmark/src/benchmark_runner.cc b/contrib/restricted/google/benchmark/src/benchmark_runner.cc
index f5032e94dd..a38093937a 100644
--- a/contrib/restricted/google/benchmark/src/benchmark_runner.cc
+++ b/contrib/restricted/google/benchmark/src/benchmark_runner.cc
@@ -93,7 +93,6 @@ BenchmarkReporter::Run CreateRunReport(
report.repetitions = repeats;
if (!report.skipped) {
- // This is the total time across all threads.
if (b.use_manual_time()) {
report.real_accumulated_time = results.manual_time_used;
} else {
@@ -126,14 +125,15 @@ BenchmarkReporter::Run CreateRunReport(
// Adds the stats collected for the thread into manager->results.
void RunInThread(const BenchmarkInstance* b, IterationCount iters,
int thread_id, ThreadManager* manager,
- PerfCountersMeasurement* perf_counters_measurement) {
+ PerfCountersMeasurement* perf_counters_measurement,
+ ProfilerManager* profiler_manager) {
internal::ThreadTimer timer(
b->measure_process_cpu_time()
? internal::ThreadTimer::CreateProcessCpuTime()
: internal::ThreadTimer::Create());
- State st =
- b->Run(iters, thread_id, &timer, manager, perf_counters_measurement);
+ State st = b->Run(iters, thread_id, &timer, manager,
+ perf_counters_measurement, profiler_manager);
BM_CHECK(st.skipped() || st.iterations() >= st.max_iterations)
<< "Benchmark returned before State::KeepRunning() returned false!";
{
@@ -269,12 +269,14 @@ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations() {
// Run all but one thread in separate threads
for (std::size_t ti = 0; ti < pool.size(); ++ti) {
pool[ti] = std::thread(&RunInThread, &b, iters, static_cast<int>(ti + 1),
- manager.get(), perf_counters_measurement_ptr);
+ manager.get(), perf_counters_measurement_ptr,
+ /*profiler_manager=*/nullptr);
}
// And run one thread here directly.
// (If we were asked to run just one thread, we don't create new threads.)
// Yes, we need to do this here *after* we start the separate threads.
- RunInThread(&b, iters, 0, manager.get(), perf_counters_measurement_ptr);
+ RunInThread(&b, iters, 0, manager.get(), perf_counters_measurement_ptr,
+ /*profiler_manager=*/nullptr);
// The main thread has finished. Now let's wait for the other threads.
manager->WaitForAllThreads();
@@ -290,10 +292,6 @@ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations() {
// And get rid of the manager.
manager.reset();
- // If we were measuring whole-process CPU usage then each thread reports
- // total CPU time of all threads. Divide by threads to get real value.
- if (b.measure_process_cpu_time()) i.results.cpu_time_used /= b.threads();
-
BM_VLOG(2) << "Ran in " << i.results.cpu_time_used << "/"
<< i.results.real_time_used << "\n";
@@ -309,9 +307,6 @@ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations() {
i.seconds = i.results.real_time_used;
}
- // Adjust time stats to average since they were reported by all threads.
- i.seconds /= b.threads();
-
return i;
}
@@ -417,7 +412,8 @@ MemoryManager::Result* BenchmarkRunner::RunMemoryManager(
manager.reset(new internal::ThreadManager(1));
b.Setup();
RunInThread(&b, memory_iterations, 0, manager.get(),
- perf_counters_measurement_ptr);
+ perf_counters_measurement_ptr,
+ /*profiler_manager=*/nullptr);
manager->WaitForAllThreads();
manager.reset();
b.Teardown();
@@ -431,11 +427,10 @@ void BenchmarkRunner::RunProfilerManager() {
std::unique_ptr<internal::ThreadManager> manager;
manager.reset(new internal::ThreadManager(1));
b.Setup();
- profiler_manager->AfterSetupStart();
RunInThread(&b, profile_iterations, 0, manager.get(),
- /*perf_counters_measurement_ptr=*/nullptr);
+ /*perf_counters_measurement_ptr=*/nullptr,
+ /*profiler_manager=*/profiler_manager);
manager->WaitForAllThreads();
- profiler_manager->BeforeTeardownStop();
manager.reset();
b.Teardown();
}
diff --git a/contrib/restricted/google/benchmark/src/complexity.cc b/contrib/restricted/google/benchmark/src/complexity.cc
index eee3122646..63acd504d7 100644
--- a/contrib/restricted/google/benchmark/src/complexity.cc
+++ b/contrib/restricted/google/benchmark/src/complexity.cc
@@ -27,7 +27,6 @@ namespace benchmark {
// Internal function to calculate the different scalability forms
BigOFunc* FittingCurve(BigO complexity) {
- static const double kLog2E = 1.44269504088896340736;
switch (complexity) {
case oN:
return [](IterationCount n) -> double { return static_cast<double>(n); };
@@ -36,15 +35,12 @@ BigOFunc* FittingCurve(BigO complexity) {
case oNCubed:
return [](IterationCount n) -> double { return std::pow(n, 3); };
case oLogN:
- /* Note: can't use log2 because Android's GNU STL lacks it */
- return [](IterationCount n) {
- return kLog2E * std::log(static_cast<double>(n));
+ return [](IterationCount n) -> double {
+ return std::log2(static_cast<double>(n));
};
case oNLogN:
- /* Note: can't use log2 because Android's GNU STL lacks it */
- return [](IterationCount n) {
- return kLog2E * static_cast<double>(n) *
- std::log(static_cast<double>(n));
+ return [](IterationCount n) -> double {
+ return static_cast<double>(n) * std::log2(static_cast<double>(n));
};
case o1:
default:
diff --git a/contrib/restricted/google/benchmark/src/perf_counters.cc b/contrib/restricted/google/benchmark/src/perf_counters.cc
index 17f7c3200f..66ac6f0afb 100644
--- a/contrib/restricted/google/benchmark/src/perf_counters.cc
+++ b/contrib/restricted/google/benchmark/src/perf_counters.cc
@@ -218,7 +218,7 @@ PerfCounters PerfCounters::Create(
GetErrorLogInstance() << "***WARNING*** Failed to start counters. "
"Claring out all counters.\n";
- // Close all peformance counters
+ // Close all performance counters
for (int id : counter_ids) {
::close(id);
}
diff --git a/contrib/restricted/google/benchmark/test/ya.make b/contrib/restricted/google/benchmark/test/ya.make
index 1aa8acd78a..0c2cad107d 100644
--- a/contrib/restricted/google/benchmark/test/ya.make
+++ b/contrib/restricted/google/benchmark/test/ya.make
@@ -4,7 +4,7 @@ GTEST(benchmark_gtest)
WITHOUT_LICENSE_TEXTS()
-VERSION(1.8.5)
+VERSION(1.9.0)
LICENSE(Apache-2.0)
diff --git a/contrib/restricted/google/benchmark/tools/compare/ya.make b/contrib/restricted/google/benchmark/tools/compare/ya.make
index 74e7cb446f..cf364865b5 100644
--- a/contrib/restricted/google/benchmark/tools/compare/ya.make
+++ b/contrib/restricted/google/benchmark/tools/compare/ya.make
@@ -4,9 +4,9 @@ PY3_PROGRAM()
WITHOUT_LICENSE_TEXTS()
-VERSION(1.8.5)
+VERSION(1.9.0)
-ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.8.5.tar.gz)
+ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.9.0.tar.gz)
LICENSE(Apache-2.0)
diff --git a/contrib/restricted/google/benchmark/tools/ya.make b/contrib/restricted/google/benchmark/tools/ya.make
index 699754c6c2..c010117d64 100644
--- a/contrib/restricted/google/benchmark/tools/ya.make
+++ b/contrib/restricted/google/benchmark/tools/ya.make
@@ -1,6 +1,6 @@
# Generated by devtools/yamaker.
-VERSION(1.8.5)
+VERSION(1.9.0)
IF (NOT USE_STL_SYSTEM)
IF (NOT USE_SYSTEM_PYTHON OR NOT _SYSTEM_PYTHON27)
diff --git a/contrib/restricted/google/benchmark/ya.make b/contrib/restricted/google/benchmark/ya.make
index 1293df88d3..73451b6535 100644
--- a/contrib/restricted/google/benchmark/ya.make
+++ b/contrib/restricted/google/benchmark/ya.make
@@ -2,9 +2,9 @@
LIBRARY()
-VERSION(1.8.5)
+VERSION(1.9.0)
-ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.8.5.tar.gz)
+ORIGINAL_SOURCE(https://github.com/google/benchmark/archive/v1.9.0.tar.gz)
LICENSE(Apache-2.0)
@@ -21,7 +21,7 @@ NO_UTIL()
CFLAGS(
GLOBAL -DBENCHMARK_STATIC_DEFINE
- -DBENCHMARK_VERSION=\"v1.8.5\"
+ -DBENCHMARK_VERSION=\"v1.9.0\"
-DHAVE_POSIX_REGEX
-DHAVE_PTHREAD_AFFINITY
-DHAVE_STD_REGEX