aboutsummaryrefslogtreecommitdiffstats
path: root/util/system
diff options
context:
space:
mode:
authorcerevra <cerevra@yandex-team.ru>2022-02-10 16:45:59 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:59 +0300
commit4f292c7e2fd0a41da93fda51b2d440c979a330b7 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/system
parentbf41dd01f6c920583e9faae7cd55ed25e547e052 (diff)
downloadydb-4f292c7e2fd0a41da93fda51b2d440c979a330b7.tar.gz
Restoring authorship annotation for <cerevra@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
-rw-r--r--util/system/fasttime.cpp2
-rw-r--r--util/system/madvise.cpp170
-rw-r--r--util/system/madvise.h30
-rw-r--r--util/system/thread.cpp30
-rw-r--r--util/system/thread.h92
-rw-r--r--util/system/thread_ut.cpp94
-rw-r--r--util/system/yassert.cpp10
7 files changed, 214 insertions, 214 deletions
diff --git a/util/system/fasttime.cpp b/util/system/fasttime.cpp
index 512de42872..057a814f0a 100644
--- a/util/system/fasttime.cpp
+++ b/util/system/fasttime.cpp
@@ -33,7 +33,7 @@ namespace {
inline TSymbols()
: Func(nullptr)
{
- // not DEFAULT, cause library/cpp/gettimeofday
+ // not DEFAULT, cause library/cpp/gettimeofday
Func = reinterpret_cast<TFunc>(dlsym(RTLD_NEXT, "gettimeofday"));
#if defined(_musl_)
diff --git a/util/system/madvise.cpp b/util/system/madvise.cpp
index 0e7aea280a..58c894e3ef 100644
--- a/util/system/madvise.cpp
+++ b/util/system/madvise.cpp
@@ -19,22 +19,22 @@
#ifndef MADV_DODUMP /* This flag is defined in sys/mman.h since Linux 3.4, but currently old libc header is in use \
for capability with Ubuntu 12.04, so we need to define it here manually */
#define MADV_DODUMP 17 /* Undo the effect of an earlier MADV_DONTDUMP */
-#endif
-
+#endif
+
namespace {
- void Madvise(int flag, const void* cbegin, size_t size) {
+ void Madvise(int flag, const void* cbegin, size_t size) {
static const size_t pageSize = NSystemInfo::GetPageSize();
void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
size = AlignUp(size, pageSize);
#if defined(_win_)
- if (!VirtualFree((LPVOID)begin, size, flag)) {
- TString err(LastSystemErrorText());
- ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")"
- << " returned error: " << err;
+ if (!VirtualFree((LPVOID)begin, size, flag)) {
+ TString err(LastSystemErrorText());
+ ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")"
+ << " returned error: " << err;
}
#else
- if (-1 == madvise(begin, size, flag)) {
+ if (-1 == madvise(begin, size, flag)) {
TString err(LastSystemErrorText());
ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")"
<< " returned error: " << err;
@@ -44,83 +44,83 @@ namespace {
}
void MadviseSequentialAccess(const void* begin, size_t size) {
-#if !defined(_win_)
- Madvise(MADV_SEQUENTIAL, begin, size);
-#endif
-}
-
-void MadviseSequentialAccess(TArrayRef<const char> data) {
- MadviseSequentialAccess(data.data(), data.size());
-}
-
-void MadviseSequentialAccess(TArrayRef<const ui8> data) {
- MadviseSequentialAccess(data.data(), data.size());
-}
-
+#if !defined(_win_)
+ Madvise(MADV_SEQUENTIAL, begin, size);
+#endif
+}
+
+void MadviseSequentialAccess(TArrayRef<const char> data) {
+ MadviseSequentialAccess(data.data(), data.size());
+}
+
+void MadviseSequentialAccess(TArrayRef<const ui8> data) {
+ MadviseSequentialAccess(data.data(), data.size());
+}
+
void MadviseRandomAccess(const void* begin, size_t size) {
-#if !defined(_win_)
- Madvise(MADV_RANDOM, begin, size);
-#endif
-}
-
-void MadviseRandomAccess(TArrayRef<const char> data) {
- MadviseRandomAccess(data.data(), data.size());
-}
-
-void MadviseRandomAccess(TArrayRef<const ui8> data) {
- MadviseRandomAccess(data.data(), data.size());
-}
-
+#if !defined(_win_)
+ Madvise(MADV_RANDOM, begin, size);
+#endif
+}
+
+void MadviseRandomAccess(TArrayRef<const char> data) {
+ MadviseRandomAccess(data.data(), data.size());
+}
+
+void MadviseRandomAccess(TArrayRef<const ui8> data) {
+ MadviseRandomAccess(data.data(), data.size());
+}
+
void MadviseEvict(const void* begin, size_t size) {
-#if defined(_win_)
- Madvise(MEM_DECOMMIT, begin, size);
-#elif defined(_linux_) || defined(_cygwin_)
- Madvise(MADV_DONTNEED, begin, size);
-#else // freebsd, osx
- Madvise(MADV_FREE, begin, size);
-#endif
-}
-
-void MadviseEvict(TArrayRef<const char> data) {
- MadviseEvict(data.data(), data.size());
-}
-
-void MadviseEvict(TArrayRef<const ui8> data) {
- MadviseEvict(data.data(), data.size());
-}
-
+#if defined(_win_)
+ Madvise(MEM_DECOMMIT, begin, size);
+#elif defined(_linux_) || defined(_cygwin_)
+ Madvise(MADV_DONTNEED, begin, size);
+#else // freebsd, osx
+ Madvise(MADV_FREE, begin, size);
+#endif
+}
+
+void MadviseEvict(TArrayRef<const char> data) {
+ MadviseEvict(data.data(), data.size());
+}
+
+void MadviseEvict(TArrayRef<const ui8> data) {
+ MadviseEvict(data.data(), data.size());
+}
+
void MadviseExcludeFromCoreDump(const void* begin, size_t size) {
-#if defined(_darwin_)
- // Don't try to call function with flag which doesn't work
- // https://st.yandex-team.ru/PASSP-31755#6050bbafc68f501f2c22caab
- Y_UNUSED(begin);
- Y_UNUSED(size);
-#elif !defined(_win_)
- Madvise(MADV_DONTDUMP, begin, size);
-#endif
-}
-
-void MadviseExcludeFromCoreDump(TArrayRef<const char> data) {
- MadviseExcludeFromCoreDump(data.data(), data.size());
-}
-
-void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data) {
- MadviseExcludeFromCoreDump(data.data(), data.size());
-}
-
-void MadviseIncludeIntoCoreDump(const void* begin, size_t size) {
-#if defined(_darwin_)
- Y_UNUSED(begin);
- Y_UNUSED(size);
-#elif !defined(_win_)
- Madvise(MADV_DODUMP, begin, size);
-#endif
-}
-
-void MadviseIncludeIntoCoreDump(TArrayRef<const char> data) {
- MadviseIncludeIntoCoreDump(data.data(), data.size());
-}
-
-void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data) {
- MadviseIncludeIntoCoreDump(data.data(), data.size());
-}
+#if defined(_darwin_)
+ // Don't try to call function with flag which doesn't work
+ // https://st.yandex-team.ru/PASSP-31755#6050bbafc68f501f2c22caab
+ Y_UNUSED(begin);
+ Y_UNUSED(size);
+#elif !defined(_win_)
+ Madvise(MADV_DONTDUMP, begin, size);
+#endif
+}
+
+void MadviseExcludeFromCoreDump(TArrayRef<const char> data) {
+ MadviseExcludeFromCoreDump(data.data(), data.size());
+}
+
+void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data) {
+ MadviseExcludeFromCoreDump(data.data(), data.size());
+}
+
+void MadviseIncludeIntoCoreDump(const void* begin, size_t size) {
+#if defined(_darwin_)
+ Y_UNUSED(begin);
+ Y_UNUSED(size);
+#elif !defined(_win_)
+ Madvise(MADV_DODUMP, begin, size);
+#endif
+}
+
+void MadviseIncludeIntoCoreDump(TArrayRef<const char> data) {
+ MadviseIncludeIntoCoreDump(data.data(), data.size());
+}
+
+void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data) {
+ MadviseIncludeIntoCoreDump(data.data(), data.size());
+}
diff --git a/util/system/madvise.h b/util/system/madvise.h
index d875cce245..606733152e 100644
--- a/util/system/madvise.h
+++ b/util/system/madvise.h
@@ -2,29 +2,29 @@
#include "defaults.h"
-#include <util/generic/array_ref.h>
-
+#include <util/generic/array_ref.h>
+
/// see linux madvise(MADV_SEQUENTIAL)
void MadviseSequentialAccess(const void* begin, size_t size);
-void MadviseSequentialAccess(TArrayRef<const char> data);
-void MadviseSequentialAccess(TArrayRef<const ui8> data);
+void MadviseSequentialAccess(TArrayRef<const char> data);
+void MadviseSequentialAccess(TArrayRef<const ui8> data);
/// see linux madvise(MADV_RANDOM)
void MadviseRandomAccess(const void* begin, size_t size);
-void MadviseRandomAccess(TArrayRef<const char> data);
-void MadviseRandomAccess(TArrayRef<const ui8> data);
+void MadviseRandomAccess(TArrayRef<const char> data);
+void MadviseRandomAccess(TArrayRef<const ui8> data);
/// see linux madvise(MADV_DONTNEED)
void MadviseEvict(const void* begin, size_t size);
-void MadviseEvict(TArrayRef<const char> data);
-void MadviseEvict(TArrayRef<const ui8> data);
+void MadviseEvict(TArrayRef<const char> data);
+void MadviseEvict(TArrayRef<const ui8> data);
/// see linux madvise(MADV_DONTDUMP)
void MadviseExcludeFromCoreDump(const void* begin, size_t size);
-void MadviseExcludeFromCoreDump(TArrayRef<const char> data);
-void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data);
-
-/// see linux madvise(MADV_DODUMP)
-void MadviseIncludeIntoCoreDump(const void* begin, size_t size);
-void MadviseIncludeIntoCoreDump(TArrayRef<const char> data);
-void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data);
+void MadviseExcludeFromCoreDump(TArrayRef<const char> data);
+void MadviseExcludeFromCoreDump(TArrayRef<const ui8> data);
+
+/// see linux madvise(MADV_DODUMP)
+void MadviseIncludeIntoCoreDump(const void* begin, size_t size);
+void MadviseIncludeIntoCoreDump(TArrayRef<const char> data);
+void MadviseIncludeIntoCoreDump(TArrayRef<const ui8> data);
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index d529776f49..6236746c2d 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -251,23 +251,23 @@ namespace {
class TThread::TImpl: public TThreadBase {
public:
- inline TImpl(const TParams& params, THolder<TCallableBase> callable = {})
+ inline TImpl(const TParams& params, THolder<TCallableBase> callable = {})
: TThreadBase(params)
- , Callable_(std::move(callable))
+ , Callable_(std::move(callable))
{
}
inline TId Id() const noexcept {
return ThreadIdHashFunction(SystemThreadId());
}
-
- static THolder<TImpl> Create(THolder<TCallableBase> callable) {
- TParams params(TCallableBase::ThreadWorker, callable.Get());
- return MakeHolder<TImpl>(std::move(params), std::move(callable));
- }
-
-private:
- THolder<TCallableBase> Callable_;
+
+ static THolder<TImpl> Create(THolder<TCallableBase> callable) {
+ TParams params(TCallableBase::ThreadWorker, callable.Get());
+ return MakeHolder<TImpl>(std::move(params), std::move(callable));
+ }
+
+private:
+ THolder<TCallableBase> Callable_;
};
TThread::TThread(const TParams& p)
@@ -280,11 +280,11 @@ TThread::TThread(TThreadProc threadProc, void* param)
{
}
-TThread::TThread(TPrivateCtor, THolder<TCallableBase> callable)
- : Impl_(TImpl::Create(std::move(callable)))
-{
-}
-
+TThread::TThread(TPrivateCtor, THolder<TCallableBase> callable)
+ : Impl_(TImpl::Create(std::move(callable)))
+{
+}
+
TThread::~TThread() {
Join();
}
diff --git a/util/system/thread.h b/util/system/thread.h
index 588c96985f..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -13,10 +13,10 @@
bool SetHighestThreadPriority();
class TThread {
- template <typename Callable>
- struct TCallableParams;
- struct TPrivateCtor {};
-
+ template <typename Callable>
+ struct TCallableParams;
+ struct TPrivateCtor {};
+
public:
using TThreadProc = void* (*)(void*);
using TId = size_t;
@@ -75,23 +75,23 @@ public:
TThread(const TParams& params);
TThread(TThreadProc threadProc, void* param);
- template <typename Callable>
- TThread(Callable&& callable)
- : TThread(TPrivateCtor{},
+ template <typename Callable>
+ TThread(Callable&& callable)
+ : TThread(TPrivateCtor{},
MakeHolder<TCallableParams<Callable>>(std::forward<Callable>(callable)))
{
- }
-
- TThread(TParams&& params)
- : TThread((const TParams&)params)
- {
- }
-
- TThread(TParams& params)
- : TThread((const TParams&)params)
- {
- }
-
+ }
+
+ TThread(TParams&& params)
+ : TThread((const TParams&)params)
+ {
+ }
+
+ TThread(TParams& params)
+ : TThread((const TParams&)params)
+ {
+ }
+
~TThread();
void Start();
@@ -126,33 +126,33 @@ public:
static bool CanGetCurrentThreadName();
private:
- struct TCallableBase {
- virtual ~TCallableBase() = default;
- virtual void run() = 0;
-
- static void* ThreadWorker(void* arg) {
- static_cast<TCallableBase*>(arg)->run();
- return nullptr;
- }
- };
-
- template <typename Callable>
- struct TCallableParams: public TCallableBase {
- TCallableParams(Callable&& callable)
- : Callable_(std::forward<Callable>(callable))
- {
- }
-
- Callable Callable_;
-
- void run() override {
- Callable_();
- }
- };
-
- TThread(TPrivateCtor, THolder<TCallableBase> callable);
-
-private:
+ struct TCallableBase {
+ virtual ~TCallableBase() = default;
+ virtual void run() = 0;
+
+ static void* ThreadWorker(void* arg) {
+ static_cast<TCallableBase*>(arg)->run();
+ return nullptr;
+ }
+ };
+
+ template <typename Callable>
+ struct TCallableParams: public TCallableBase {
+ TCallableParams(Callable&& callable)
+ : Callable_(std::forward<Callable>(callable))
+ {
+ }
+
+ Callable Callable_;
+
+ void run() override {
+ Callable_();
+ }
+ };
+
+ TThread(TPrivateCtor, THolder<TCallableBase> callable);
+
+private:
class TImpl;
THolder<TImpl> Impl_;
};
diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp
index 0a50a36e59..d820898fd5 100644
--- a/util/system/thread_ut.cpp
+++ b/util/system/thread_ut.cpp
@@ -178,52 +178,52 @@ Y_UNIT_TEST_SUITE(TSysThreadTest) {
UNIT_ASSERT(sl.StackBegin);
UNIT_ASSERT(sl.StackLength > 0);
}
-
- Y_UNIT_TEST(TestFunc) {
- std::atomic_bool flag = {false};
- TThread thread([&flag]() { flag = true; });
-
- thread.Start();
- UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
- UNIT_ASSERT(flag);
- }
-
- Y_UNIT_TEST(TestCopyFunc) {
- std::atomic_bool flag = {false};
- auto func = [&flag]() { flag = true; };
-
- TThread thread(func);
- thread.Start();
- UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
-
- TThread thread2(func);
- thread2.Start();
- UNIT_ASSERT_VALUES_EQUAL(thread2.Join(), nullptr);
-
- UNIT_ASSERT(flag);
- }
-
- Y_UNIT_TEST(TestCallable) {
- std::atomic_bool flag = {false};
-
+
+ Y_UNIT_TEST(TestFunc) {
+ std::atomic_bool flag = {false};
+ TThread thread([&flag]() { flag = true; });
+
+ thread.Start();
+ UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT(flag);
+ }
+
+ Y_UNIT_TEST(TestCopyFunc) {
+ std::atomic_bool flag = {false};
+ auto func = [&flag]() { flag = true; };
+
+ TThread thread(func);
+ thread.Start();
+ UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
+
+ TThread thread2(func);
+ thread2.Start();
+ UNIT_ASSERT_VALUES_EQUAL(thread2.Join(), nullptr);
+
+ UNIT_ASSERT(flag);
+ }
+
+ Y_UNIT_TEST(TestCallable) {
+ std::atomic_bool flag = {false};
+
struct TCallable: TMoveOnly {
- std::atomic_bool* Flag_;
-
- TCallable(std::atomic_bool* flag)
- : Flag_(flag)
- {
- }
-
- void operator()() {
- *Flag_ = true;
- }
- };
-
- TCallable foo(&flag);
- TThread thread(std::move(foo));
-
- thread.Start();
- UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
- UNIT_ASSERT(flag);
- }
+ std::atomic_bool* Flag_;
+
+ TCallable(std::atomic_bool* flag)
+ : Flag_(flag)
+ {
+ }
+
+ void operator()() {
+ *Flag_ = true;
+ }
+ };
+
+ TCallable foo(&flag);
+ TThread thread(std::move(foo));
+
+ thread.Start();
+ UNIT_ASSERT_VALUES_EQUAL(thread.Join(), nullptr);
+ UNIT_ASSERT(flag);
+ }
};
diff --git a/util/system/yassert.cpp b/util/system/yassert.cpp
index e84055effa..0f586648b7 100644
--- a/util/system/yassert.cpp
+++ b/util/system/yassert.cpp
@@ -5,7 +5,7 @@
#include "spinlock.h"
#include "src_root.h"
-#include <util/datetime/base.h>
+#include <util/datetime/base.h>
#include <util/generic/singleton.h>
#include <util/generic/strbuf.h>
#include <util/generic/string.h>
@@ -63,14 +63,14 @@ void ::NPrivate::Panic(const TStaticBuf& file, int line, const char* function, c
namespace NPrivate {
[[noreturn]] Y_NO_INLINE void InternalPanicImpl(int line, const char* function, const char* expr, int, int, int, const TStringBuf file, const char* errorMessage, size_t errorMessageSize) noexcept try {
TStringBuf errorMsg{errorMessage, errorMessageSize};
- const TString now = TInstant::Now().ToStringLocal();
-
+ const TString now = TInstant::Now().ToStringLocal();
+
TString r;
TStringOutput o(r);
if (expr) {
- o << "VERIFY failed (" << now << "): " << errorMsg << Endl;
+ o << "VERIFY failed (" << now << "): " << errorMsg << Endl;
} else {
- o << "FAIL (" << now << "): " << errorMsg << Endl;
+ o << "FAIL (" << now << "): " << errorMsg << Endl;
}
o << " " << file << ":" << line << Endl;
if (expr) {