aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authortpashkin <tpashkin@yandex-team.ru>2022-02-10 16:46:41 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:41 +0300
commit5475379a04e37df30085bd1724f1c57e3f40996f (patch)
tree95d77e29785a3bd5be6260b1c9d226a551376ecf /library/cpp
parentc3d34b9b40eb534dfd2c549342274f3d61844688 (diff)
downloadydb-5475379a04e37df30085bd1724f1c57e3f40996f.tar.gz
Restoring authorship annotation for <tpashkin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/lwtrace/control.h2
-rw-r--r--library/cpp/lwtrace/log_shuttle.cpp108
-rw-r--r--library/cpp/lwtrace/log_shuttle.h68
-rw-r--r--library/cpp/lwtrace/probes.h12
-rw-r--r--library/cpp/lwtrace/shuttle.h96
-rw-r--r--library/cpp/lwtrace/trace.cpp8
-rw-r--r--library/cpp/lwtrace/trace_ut.cpp270
-rw-r--r--library/cpp/lwtrace/ya.make2
8 files changed, 283 insertions, 283 deletions
diff --git a/library/cpp/lwtrace/control.h b/library/cpp/lwtrace/control.h
index 16b24eafd2..51e13a11b2 100644
--- a/library/cpp/lwtrace/control.h
+++ b/library/cpp/lwtrace/control.h
@@ -123,7 +123,7 @@ namespace NLWTrace {
TCyclicDepot CyclicDepot;
TDurationDepot DurationDepot;
TAtomic LastTrackId;
- TAtomic LastSpanId;
+ TAtomic LastSpanId;
typedef TVector<std::pair<TProbe*, IExecutor*>> TProbes;
TProbes Probes;
bool Attached;
diff --git a/library/cpp/lwtrace/log_shuttle.cpp b/library/cpp/lwtrace/log_shuttle.cpp
index 695aa90b31..874f103697 100644
--- a/library/cpp/lwtrace/log_shuttle.cpp
+++ b/library/cpp/lwtrace/log_shuttle.cpp
@@ -1,67 +1,67 @@
#include "log_shuttle.h"
-#include "probes.h"
+#include "probes.h"
namespace NLWTrace {
- LWTRACE_USING(LWTRACE_INTERNAL_PROVIDER);
-
-#ifdef LWTRACE_DISABLE
-
- template <class TDepot>
+ LWTRACE_USING(LWTRACE_INTERNAL_PROVIDER);
+
+#ifdef LWTRACE_DISABLE
+
+ template <class TDepot>
bool TLogShuttle<TDepot>::DoFork(TShuttlePtr& child) {
Y_UNUSED(child);
- return false;
- }
-
- template <class TDepot>
+ return false;
+ }
+
+ template <class TDepot>
bool TLogShuttle<TDepot>::DoJoin(const TShuttlePtr& child) {
Y_UNUSED(child);
- return false;
- }
-
-#else
-
- template <class TDepot>
+ return false;
+ }
+
+#else
+
+ template <class TDepot>
bool TLogShuttle<TDepot>::DoFork(TShuttlePtr& child) {
if (child = Executor->RentShuttle()) {
child->SetParentSpanId(GetSpanId());
Executor->Cast(child)->SetIgnore(true);
- TParams params;
+ TParams params;
params.Param[0].CopyConstruct<ui64>(child->GetSpanId());
- bool result = DoAddProbe(&LWTRACE_GET_NAME(Fork).Probe, params, 0);
- TUserSignature<ui64>::DestroyParams(params);
- return result;
- }
- AtomicIncrement(ForkFailed);
- return false;
- }
-
- template <class TDepot>
- bool TLogShuttle<TDepot>::DoJoin(const TShuttlePtr& shuttle) {
- auto* child = Executor->Cast(shuttle);
- TParams params;
- params.Param[0].CopyConstruct<ui64>(child->GetSpanId());
- params.Param[1].CopyConstruct<ui64>(child->TrackLog.Items.size());
- bool result = DoAddProbe(&LWTRACE_GET_NAME(Join).Probe, params, 0);
- TUserSignature<ui64, ui64>::DestroyParams(params);
- if (result) {
- with_lock (Lock) {
- ssize_t n = MaxTrackLength - TrackLog.Items.size();
- for (auto& item: child->TrackLog.Items) {
- if (n-- <= 0) {
- TrackLog.Truncated = true;
- break;
- }
- TrackLog.Items.emplace_back(item);
- }
- }
- }
- AtomicAdd(ForkFailed, AtomicGet(child->ForkFailed));
- Executor->ParkShuttle(child);
- return result;
- }
-
-#endif
-
- template class TLogShuttle<TDurationDepot>;
- template class TLogShuttle<TCyclicDepot>;
+ bool result = DoAddProbe(&LWTRACE_GET_NAME(Fork).Probe, params, 0);
+ TUserSignature<ui64>::DestroyParams(params);
+ return result;
+ }
+ AtomicIncrement(ForkFailed);
+ return false;
+ }
+
+ template <class TDepot>
+ bool TLogShuttle<TDepot>::DoJoin(const TShuttlePtr& shuttle) {
+ auto* child = Executor->Cast(shuttle);
+ TParams params;
+ params.Param[0].CopyConstruct<ui64>(child->GetSpanId());
+ params.Param[1].CopyConstruct<ui64>(child->TrackLog.Items.size());
+ bool result = DoAddProbe(&LWTRACE_GET_NAME(Join).Probe, params, 0);
+ TUserSignature<ui64, ui64>::DestroyParams(params);
+ if (result) {
+ with_lock (Lock) {
+ ssize_t n = MaxTrackLength - TrackLog.Items.size();
+ for (auto& item: child->TrackLog.Items) {
+ if (n-- <= 0) {
+ TrackLog.Truncated = true;
+ break;
+ }
+ TrackLog.Items.emplace_back(item);
+ }
+ }
+ }
+ AtomicAdd(ForkFailed, AtomicGet(child->ForkFailed));
+ Executor->ParkShuttle(child);
+ return result;
+ }
+
+#endif
+
+ template class TLogShuttle<TDurationDepot>;
+ template class TLogShuttle<TCyclicDepot>;
}
diff --git a/library/cpp/lwtrace/log_shuttle.h b/library/cpp/lwtrace/log_shuttle.h
index 729a38615f..34d4cb4a85 100644
--- a/library/cpp/lwtrace/log_shuttle.h
+++ b/library/cpp/lwtrace/log_shuttle.h
@@ -46,19 +46,19 @@ namespace NLWTrace {
template <class TDepot>
class TLogShuttle: public IShuttle {
private:
- using TExecutor = TRunLogShuttleActionExecutor<TDepot>;
+ using TExecutor = TRunLogShuttleActionExecutor<TDepot>;
TTrackLog TrackLog;
- TExecutor* Executor;
+ TExecutor* Executor;
bool Ignore = false;
size_t MaxTrackLength;
TAdaptiveLock Lock;
- TAtomic ForkFailed = 0;
+ TAtomic ForkFailed = 0;
public:
- explicit TLogShuttle(TExecutor* executor)
- : IShuttle(executor->GetTraceIdx(), executor->NewSpanId())
- , Executor(executor)
- , MaxTrackLength(Executor->GetAction().GetMaxTrackLength() ? Executor->GetAction().GetMaxTrackLength() : 100)
+ explicit TLogShuttle(TExecutor* executor)
+ : IShuttle(executor->GetTraceIdx(), executor->NewSpanId())
+ , Executor(executor)
+ , MaxTrackLength(Executor->GetAction().GetMaxTrackLength() ? Executor->GetAction().GetMaxTrackLength() : 100)
{
}
@@ -67,7 +67,7 @@ namespace NLWTrace {
void DoDrop() override;
void DoSerialize(TShuttleTrace& msg) override;
bool DoFork(TShuttlePtr& child) override;
- bool DoJoin(const TShuttlePtr& child) override;
+ bool DoJoin(const TShuttlePtr& child) override;
void SetIgnore(bool ignore);
void Clear();
@@ -110,19 +110,19 @@ namespace NLWTrace {
TAtomic MissedTracks = 0;
TAtomic* LastTrackId;
- TAtomic* LastSpanId;
+ TAtomic* LastSpanId;
static constexpr int MaxShuttles = 100000;
public:
- TRunLogShuttleActionExecutor(ui64 traceIdx, const TRunLogShuttleAction& action, TDepot* depot, TAtomic* lastTrackId, TAtomic* lastSpanId);
+ TRunLogShuttleActionExecutor(ui64 traceIdx, const TRunLogShuttleAction& action, TDepot* depot, TAtomic* lastTrackId, TAtomic* lastSpanId);
~TRunLogShuttleActionExecutor();
bool DoExecute(TOrbit& orbit, const TParams& params) override;
void RecordShuttle(TLogShuttle<TDepot>* shuttle);
void ParkShuttle(TLogShuttle<TDepot>* shuttle);
- void DiscardShuttle();
- TShuttlePtr RentShuttle();
- ui64 NewSpanId();
+ void DiscardShuttle();
+ TShuttlePtr RentShuttle();
+ ui64 NewSpanId();
const TRunLogShuttleAction& GetAction() const {
return Action;
}
@@ -178,19 +178,19 @@ namespace NLWTrace {
void TLogShuttle<TDepot>::DoEndOfTrack() {
// Record track log if not ignored
if (!Ignore) {
- if (AtomicGet(ForkFailed)) {
- Executor->DiscardShuttle();
- } else {
- Executor->RecordShuttle(this);
- }
+ if (AtomicGet(ForkFailed)) {
+ Executor->DiscardShuttle();
+ } else {
+ Executor->RecordShuttle(this);
+ }
}
- Executor->ParkShuttle(this);
+ Executor->ParkShuttle(this);
}
template <class TDepot>
void TLogShuttle<TDepot>::DoDrop() {
// Do not track log results of dropped shuttles
- Executor->ParkShuttle(this);
+ Executor->ParkShuttle(this);
}
template <class TDepot>
@@ -239,13 +239,13 @@ namespace NLWTrace {
ui64 traceIdx,
const TRunLogShuttleAction& action,
TDepot* depot,
- TAtomic* lastTrackId,
- TAtomic* lastSpanId)
+ TAtomic* lastTrackId,
+ TAtomic* lastSpanId)
: TLogShuttleActionBase<TDepot>(traceIdx)
, Action(action)
, Depot(depot)
, LastTrackId(lastTrackId)
- , LastSpanId(lastSpanId)
+ , LastSpanId(lastSpanId)
{
ui64 size = Min<ui64>(Action.GetShuttlesCount() ? Action.GetShuttlesCount() : 1000, MaxShuttles); // Do not allow to allocate too much memory
AllShuttles.reserve(size);
@@ -277,11 +277,11 @@ namespace NLWTrace {
}
template <class TDepot>
- void TRunLogShuttleActionExecutor<TDepot>::DiscardShuttle() {
- AtomicIncrement(MissedTracks);
- }
-
- template <class TDepot>
+ void TRunLogShuttleActionExecutor<TDepot>::DiscardShuttle() {
+ AtomicIncrement(MissedTracks);
+ }
+
+ template <class TDepot>
void TRunLogShuttleActionExecutor<TDepot>::RecordShuttle(TLogShuttle<TDepot>* shuttle) {
if (Depot == nullptr) {
return;
@@ -312,12 +312,12 @@ namespace NLWTrace {
Parking.emplace_back(shuttle);
}
- template <class TDepot>
- ui64 TRunLogShuttleActionExecutor<TDepot>::NewSpanId()
- {
- return LastSpanId ? AtomicIncrement(*LastSpanId) : 0;
- }
-
+ template <class TDepot>
+ ui64 TRunLogShuttleActionExecutor<TDepot>::NewSpanId()
+ {
+ return LastSpanId ? AtomicIncrement(*LastSpanId) : 0;
+ }
+
////////////////////////////////////////////////////////////////////////////////
template <class TDepot>
diff --git a/library/cpp/lwtrace/probes.h b/library/cpp/lwtrace/probes.h
index 68810bd118..bff2fb455f 100644
--- a/library/cpp/lwtrace/probes.h
+++ b/library/cpp/lwtrace/probes.h
@@ -9,12 +9,12 @@
PROBE(DeserializationError, GROUPS("LWTraceError"), \
TYPES(TString, TString), \
NAMES("probeName", "providerName")) \
- PROBE(Fork, GROUPS(), \
- TYPES(ui64), \
- NAMES("spanId")) \
- PROBE(Join, GROUPS(), \
- TYPES(ui64, ui64), \
- NAMES("spanId", "trackLength")) \
+ PROBE(Fork, GROUPS(), \
+ TYPES(ui64), \
+ NAMES("spanId")) \
+ PROBE(Join, GROUPS(), \
+ TYPES(ui64, ui64), \
+ NAMES("spanId", "trackLength")) \
PROBE(OrbitIsUsedConcurrentlyError, GROUPS("LWTraceError"), \
TYPES(TString), \
NAMES("backtrace")) \
diff --git a/library/cpp/lwtrace/shuttle.h b/library/cpp/lwtrace/shuttle.h
index 85c6e4da61..fc1703aeb0 100644
--- a/library/cpp/lwtrace/shuttle.h
+++ b/library/cpp/lwtrace/shuttle.h
@@ -20,16 +20,16 @@ namespace NLWTrace {
class alignas(8) IShuttle: public TThrRefBase {
private:
ui64 TraceIdx;
- ui64 SpanId;
- ui64 ParentSpanId = 0;
+ ui64 SpanId;
+ ui64 ParentSpanId = 0;
TAtomic Status = 0;
static constexpr ui64 DeadFlag = 0x1ull;
TShuttlePtr Next;
public:
- explicit IShuttle(ui64 traceIdx, ui64 spanId)
+ explicit IShuttle(ui64 traceIdx, ui64 spanId)
: TraceIdx(traceIdx)
- , SpanId(spanId)
+ , SpanId(spanId)
{
}
@@ -40,18 +40,18 @@ namespace NLWTrace {
return TraceIdx;
}
- ui64 GetSpanId() const {
- return SpanId;
- }
-
- ui64 GetParentSpanId() const {
- return ParentSpanId;
- }
-
- void SetParentSpanId(ui64 parentSpanId) {
- ParentSpanId = parentSpanId;
- }
-
+ ui64 GetSpanId() const {
+ return SpanId;
+ }
+
+ ui64 GetParentSpanId() const {
+ return ParentSpanId;
+ }
+
+ void SetParentSpanId(ui64 parentSpanId) {
+ ParentSpanId = parentSpanId;
+ }
+
template <class F, class R>
R UnlessDead(F func, R dead) {
while (true) {
@@ -113,12 +113,12 @@ namespace NLWTrace {
UnlessDead([&] {
DoDrop();
});
- return Detach(); // Detached from orbit on Drop
- }
-
- TShuttlePtr Detach() {
+ return Detach(); // Detached from orbit on Drop
+ }
+
+ TShuttlePtr Detach() {
TShuttlePtr result;
- result.Swap(Next);
+ result.Swap(Next);
return result;
}
@@ -148,25 +148,25 @@ namespace NLWTrace {
return UnlessDead([&] {
return DoFork(child);
}, true);
- }
-
- bool Join(TShuttlePtr& child) {
+ }
+
+ bool Join(TShuttlePtr& child) {
return UnlessDead([&] {
return DoJoin(child);
}, false);
- }
-
- bool IsDead() {
- return AtomicGet(Status) & DeadFlag;
- }
-
+ }
+
+ bool IsDead() {
+ return AtomicGet(Status) & DeadFlag;
+ }
+
protected:
virtual bool DoAddProbe(TProbe* probe, const TParams& params, ui64 timestamp) = 0;
virtual void DoEndOfTrack() = 0;
virtual void DoDrop() = 0;
virtual void DoSerialize(TShuttleTrace& msg) = 0;
virtual bool DoFork(TShuttlePtr& child) = 0;
- virtual bool DoJoin(const TShuttlePtr& child) = 0;
+ virtual bool DoJoin(const TShuttlePtr& child) = 0;
};
// Not thread-safe orbit
@@ -274,8 +274,8 @@ namespace NLWTrace {
return false;
});
}
-
- bool Fork(TOrbit& child) {
+
+ bool Fork(TOrbit& child) {
return NotConcurrent([&] (TShuttlePtr& head) {
return child.NotConcurrent([&] (TShuttlePtr& cHead) {
bool result = true;
@@ -291,9 +291,9 @@ namespace NLWTrace {
return result;
});
});
- }
-
- void Join(TOrbit& child) {
+ }
+
+ void Join(TOrbit& child) {
NotConcurrent([&] (TShuttlePtr& head) {
child.NotConcurrent([&] (TShuttlePtr& cHead) {
TShuttlePtr* ref = &head;
@@ -307,21 +307,21 @@ namespace NLWTrace {
}
});
});
- }
-
+ }
+
private:
static void Join(TShuttlePtr& head, IShuttle* parent) {
TShuttlePtr* ref = &head;
- while (IShuttle* child = ref->Get()) {
- if (parent->GetTraceIdx() == child->GetTraceIdx() && parent->GetSpanId() == child->GetParentSpanId()) {
- TShuttlePtr next = child->Detach();
- parent->Join(*ref);
- *ref = next;
- } else {
- ref = &child->GetNext();
- }
- }
- }
+ while (IShuttle* child = ref->Get()) {
+ if (parent->GetTraceIdx() == child->GetTraceIdx() && parent->GetSpanId() == child->GetParentSpanId()) {
+ TShuttlePtr next = child->Detach();
+ parent->Join(*ref);
+ *ref = next;
+ } else {
+ ref = &child->GetNext();
+ }
+ }
+ }
template <class TFunc>
typename std::invoke_result<TFunc, TShuttlePtr&>::type NotConcurrent(TFunc func) {
diff --git a/library/cpp/lwtrace/trace.cpp b/library/cpp/lwtrace/trace.cpp
index 3c974c85a0..defcbfa434 100644
--- a/library/cpp/lwtrace/trace.cpp
+++ b/library/cpp/lwtrace/trace.cpp
@@ -631,9 +631,9 @@ namespace NLWTrace {
}
} else if (action.HasRunLogShuttleAction()) {
if (Query.GetLogDurationUs()) {
- actExec.Reset(new TRunLogShuttleActionExecutor<TDurationDepot>(TraceIdx, action.GetRunLogShuttleAction(), &DurationDepot, &LastTrackId, &LastSpanId));
+ actExec.Reset(new TRunLogShuttleActionExecutor<TDurationDepot>(TraceIdx, action.GetRunLogShuttleAction(), &DurationDepot, &LastTrackId, &LastSpanId));
} else {
- actExec.Reset(new TRunLogShuttleActionExecutor<TCyclicDepot>(TraceIdx, action.GetRunLogShuttleAction(), &CyclicDepot, &LastTrackId, &LastSpanId));
+ actExec.Reset(new TRunLogShuttleActionExecutor<TCyclicDepot>(TraceIdx, action.GetRunLogShuttleAction(), &CyclicDepot, &LastTrackId, &LastSpanId));
}
} else if (action.HasEditLogShuttleAction()) {
if (Query.GetLogDurationUs()) {
@@ -863,7 +863,7 @@ namespace NLWTrace {
, CyclicDepot(query.GetPerThreadLogSize() ? query.GetPerThreadLogSize() : 1000)
, DurationDepot(StoreDuration)
, LastTrackId(0)
- , LastSpanId(0)
+ , LastSpanId(0)
, Attached(true)
, Query(query)
{
@@ -993,7 +993,7 @@ namespace NLWTrace {
TManager::TManager(TProbeRegistry& registry, bool allowDestructiveActions)
: Registry(registry)
, DestructiveActionsAllowed(allowDestructiveActions)
- , SerializingExecutor(new TRunLogShuttleActionExecutor<TCyclicDepot>(0, {}, nullptr, nullptr, nullptr))
+ , SerializingExecutor(new TRunLogShuttleActionExecutor<TCyclicDepot>(0, {}, nullptr, nullptr, nullptr))
{
}
diff --git a/library/cpp/lwtrace/trace_ut.cpp b/library/cpp/lwtrace/trace_ut.cpp
index cb03e4fbde..412b7107ae 100644
--- a/library/cpp/lwtrace/trace_ut.cpp
+++ b/library/cpp/lwtrace/trace_ut.cpp
@@ -739,142 +739,142 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) {
manager.HandleTraceResponse(resp, manager.GetProbesMap(), orbit1).IsSuccess,
true);
}
-
- Y_UNIT_TEST(TrackForkJoin) {
- TManager mngr(*Singleton<TProbeRegistry>(), true);
- TQuery q;
- bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END(
- Blocks {
- ProbeDesc {
- Name: "NoParam"
- Provider: "LWTRACE_UT_PROVIDER"
- }
- Action {
- RunLogShuttleAction { }
- }
- }
+
+ Y_UNIT_TEST(TrackForkJoin) {
+ TManager mngr(*Singleton<TProbeRegistry>(), true);
+ TQuery q;
+ bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END(
+ Blocks {
+ ProbeDesc {
+ Name: "NoParam"
+ Provider: "LWTRACE_UT_PROVIDER"
+ }
+ Action {
+ RunLogShuttleAction { }
+ }
+ }
)END", &q);
-
- UNIT_ASSERT(parsed);
- mngr.New("Query1", q);
-
- {
- TOrbit a, b, c, d;
-
- // Graph:
- // c
- // / \
- // b-f-b-j-b
- // / \
- // a-f-a-f-a-j-a-j-a
- // \ /
- // d
- //
- // Merged track:
- // a-f(b)-a-f(d)-a-j(d,1)-d-a-j(b,6)-b-f(c)-b-j(c,1)-c-b-a
-
- LWTRACK(NoParam, a);
- a.Fork(b);
- LWTRACK(IntParam, a, 1);
- a.Fork(d);
- LWTRACK(IntParam, a, 2);
-
- LWTRACK(IntParam, b, 3);
- b.Fork(c);
- LWTRACK(IntParam, b, 4);
-
- LWTRACK(IntParam, c, 5);
- b.Join(c);
- LWTRACK(IntParam, b, 6);
-
- LWTRACK(IntParam, d, 7);
- a.Join(d);
- LWTRACK(IntParam, a, 8);
-
- a.Join(b);
- LWTRACK(IntParam, a, 9);
- }
-
- struct {
- void Push(TThread::TId, const TTrackLog& tl) {
- UNIT_ASSERT(tl.Items.size() == 16);
- UNIT_ASSERT(TString(tl.Items[0].Probe->Event.Name) == "NoParam");
- UNIT_ASSERT(TString(tl.Items[1].Probe->Event.Name) == "Fork");
- UNIT_ASSERT(tl.Items[2].Params.Param[0].Get<ui64>() == 1);
- UNIT_ASSERT(TString(tl.Items[3].Probe->Event.Name) == "Fork");
- UNIT_ASSERT(tl.Items[4].Params.Param[0].Get<ui64>() == 2);
- UNIT_ASSERT(TString(tl.Items[5].Probe->Event.Name) == "Join");
- UNIT_ASSERT(tl.Items[6].Params.Param[0].Get<ui64>() == 7);
- UNIT_ASSERT(tl.Items[7].Params.Param[0].Get<ui64>() == 8);
- UNIT_ASSERT(TString(tl.Items[8].Probe->Event.Name) == "Join");
- UNIT_ASSERT(tl.Items[9].Params.Param[0].Get<ui64>() == 3);
- UNIT_ASSERT(TString(tl.Items[10].Probe->Event.Name) == "Fork");
- UNIT_ASSERT(tl.Items[11].Params.Param[0].Get<ui64>() == 4);
- UNIT_ASSERT(TString(tl.Items[12].Probe->Event.Name) == "Join");
- UNIT_ASSERT(tl.Items[13].Params.Param[0].Get<ui64>() == 5);
- UNIT_ASSERT(tl.Items[14].Params.Param[0].Get<ui64>() == 6);
- UNIT_ASSERT(tl.Items[15].Params.Param[0].Get<ui64>() == 9);
- }
- } reader;
- mngr.ReadDepot("Query1", reader);
- }
-
- Y_UNIT_TEST(TrackForkError) {
- TManager mngr(*Singleton<TProbeRegistry>(), true);
- TQuery q;
- bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END(
- Blocks {
- ProbeDesc {
- Name: "NoParam"
- Provider: "LWTRACE_UT_PROVIDER"
- }
- Action {
- RunLogShuttleAction {
- MaxTrackLength: 100
- }
- }
- }
+
+ UNIT_ASSERT(parsed);
+ mngr.New("Query1", q);
+
+ {
+ TOrbit a, b, c, d;
+
+ // Graph:
+ // c
+ // / \
+ // b-f-b-j-b
+ // / \
+ // a-f-a-f-a-j-a-j-a
+ // \ /
+ // d
+ //
+ // Merged track:
+ // a-f(b)-a-f(d)-a-j(d,1)-d-a-j(b,6)-b-f(c)-b-j(c,1)-c-b-a
+
+ LWTRACK(NoParam, a);
+ a.Fork(b);
+ LWTRACK(IntParam, a, 1);
+ a.Fork(d);
+ LWTRACK(IntParam, a, 2);
+
+ LWTRACK(IntParam, b, 3);
+ b.Fork(c);
+ LWTRACK(IntParam, b, 4);
+
+ LWTRACK(IntParam, c, 5);
+ b.Join(c);
+ LWTRACK(IntParam, b, 6);
+
+ LWTRACK(IntParam, d, 7);
+ a.Join(d);
+ LWTRACK(IntParam, a, 8);
+
+ a.Join(b);
+ LWTRACK(IntParam, a, 9);
+ }
+
+ struct {
+ void Push(TThread::TId, const TTrackLog& tl) {
+ UNIT_ASSERT(tl.Items.size() == 16);
+ UNIT_ASSERT(TString(tl.Items[0].Probe->Event.Name) == "NoParam");
+ UNIT_ASSERT(TString(tl.Items[1].Probe->Event.Name) == "Fork");
+ UNIT_ASSERT(tl.Items[2].Params.Param[0].Get<ui64>() == 1);
+ UNIT_ASSERT(TString(tl.Items[3].Probe->Event.Name) == "Fork");
+ UNIT_ASSERT(tl.Items[4].Params.Param[0].Get<ui64>() == 2);
+ UNIT_ASSERT(TString(tl.Items[5].Probe->Event.Name) == "Join");
+ UNIT_ASSERT(tl.Items[6].Params.Param[0].Get<ui64>() == 7);
+ UNIT_ASSERT(tl.Items[7].Params.Param[0].Get<ui64>() == 8);
+ UNIT_ASSERT(TString(tl.Items[8].Probe->Event.Name) == "Join");
+ UNIT_ASSERT(tl.Items[9].Params.Param[0].Get<ui64>() == 3);
+ UNIT_ASSERT(TString(tl.Items[10].Probe->Event.Name) == "Fork");
+ UNIT_ASSERT(tl.Items[11].Params.Param[0].Get<ui64>() == 4);
+ UNIT_ASSERT(TString(tl.Items[12].Probe->Event.Name) == "Join");
+ UNIT_ASSERT(tl.Items[13].Params.Param[0].Get<ui64>() == 5);
+ UNIT_ASSERT(tl.Items[14].Params.Param[0].Get<ui64>() == 6);
+ UNIT_ASSERT(tl.Items[15].Params.Param[0].Get<ui64>() == 9);
+ }
+ } reader;
+ mngr.ReadDepot("Query1", reader);
+ }
+
+ Y_UNIT_TEST(TrackForkError) {
+ TManager mngr(*Singleton<TProbeRegistry>(), true);
+ TQuery q;
+ bool parsed = NProtoBuf::TextFormat::ParseFromString(R"END(
+ Blocks {
+ ProbeDesc {
+ Name: "NoParam"
+ Provider: "LWTRACE_UT_PROVIDER"
+ }
+ Action {
+ RunLogShuttleAction {
+ MaxTrackLength: 100
+ }
+ }
+ }
)END", &q);
-
- UNIT_ASSERT(parsed);
- mngr.New("Query1", q);
-
- constexpr size_t n = (100 + 2) / 3 + 1;
-
- {
- TVector<TVector<TOrbit>> span;
-
- while (1) {
- TVector<TOrbit> orbit(n);
-
- LWTRACK(NoParam, orbit[0]);
- if (!orbit[0].HasShuttles()) {
- break;
- }
- for (size_t i = 1; i < n; i++) {
- if (!orbit[i - 1].Fork(orbit[i])) {
- break;
- }
- LWTRACK(IntParam, orbit[i], i);
- }
-
- span.emplace_back(std::move(orbit));
- }
-
- for (auto& orbit: span) {
- for (auto it = orbit.rbegin(); it + 1 != orbit.rend(); it++) {
- (it + 1)->Join(*it);
- }
- }
- }
-
- struct {
- void Push(TThread::TId, const TTrackLog& tl) {
- UNIT_ASSERT(tl.Items.size() == 100);
- UNIT_ASSERT(tl.Truncated);
- }
- } reader;
- mngr.ReadDepot("Query1", reader);
- }
+
+ UNIT_ASSERT(parsed);
+ mngr.New("Query1", q);
+
+ constexpr size_t n = (100 + 2) / 3 + 1;
+
+ {
+ TVector<TVector<TOrbit>> span;
+
+ while (1) {
+ TVector<TOrbit> orbit(n);
+
+ LWTRACK(NoParam, orbit[0]);
+ if (!orbit[0].HasShuttles()) {
+ break;
+ }
+ for (size_t i = 1; i < n; i++) {
+ if (!orbit[i - 1].Fork(orbit[i])) {
+ break;
+ }
+ LWTRACK(IntParam, orbit[i], i);
+ }
+
+ span.emplace_back(std::move(orbit));
+ }
+
+ for (auto& orbit: span) {
+ for (auto it = orbit.rbegin(); it + 1 != orbit.rend(); it++) {
+ (it + 1)->Join(*it);
+ }
+ }
+ }
+
+ struct {
+ void Push(TThread::TId, const TTrackLog& tl) {
+ UNIT_ASSERT(tl.Items.size() == 100);
+ UNIT_ASSERT(tl.Truncated);
+ }
+ } reader;
+ mngr.ReadDepot("Query1", reader);
+ }
#endif // LWTRACE_DISABLE
}
diff --git a/library/cpp/lwtrace/ya.make b/library/cpp/lwtrace/ya.make
index d9accb3006..b11e3f916d 100644
--- a/library/cpp/lwtrace/ya.make
+++ b/library/cpp/lwtrace/ya.make
@@ -11,7 +11,7 @@ SRCS(
control.cpp
custom_action.cpp
kill_action.cpp
- log_shuttle.cpp
+ log_shuttle.cpp
perf.cpp
probes.cpp
shuttle.cpp