Browse Source

Y_VERIFY->Y_ABORT_UNLESS at ^l

https://clubs.at.yandex-team.ru/arcadia/29404
ilnurkh 1 year ago
parent
commit
e601ca03f8

+ 4 - 4
library/cpp/actors/core/actor.cpp

@@ -18,7 +18,7 @@ namespace NActors {
             ui64 count = value >> T::TimestampBits;
 
             count += Increment;
-            Y_VERIFY((count & ~T::CountMask) == 0);
+            Y_ABORT_UNLESS((count & ~T::CountMask) == 0);
 
             ui64 timestamp = value;
             if (Increment == 1 && count == 1) {
@@ -53,7 +53,7 @@ namespace NActors {
             used += (static_cast<ui64>(time) - value) & TimestampMask;
         }
 
-        Y_VERIFY(LastUsageTimestamp <= time);
+        Y_ABORT_UNLESS(LastUsageTimestamp <= time);
         ui64 passed = time - LastUsageTimestamp;
         LastUsageTimestamp = time;
 
@@ -188,7 +188,7 @@ namespace NActors {
 
     void IActor::Die(const TActorContext& ctx) {
         if (ctx.SelfID)
-            Y_VERIFY(ctx.SelfID == SelfActorId);
+            Y_ABORT_UNLESS(ctx.SelfID == SelfActorId);
         PassAway();
     }
 
@@ -206,7 +206,7 @@ namespace NActors {
     }
 
     void TActorVirtualBehaviour::Receive(IActor* actor, std::unique_ptr<IEventHandle> ev) {
-        Y_VERIFY(!!ev && ev->GetBase());
+        Y_ABORT_UNLESS(!!ev && ev->GetBase());
         ev->GetBase()->Execute(actor, std::move(ev));
     }
 

+ 4 - 4
library/cpp/actors/core/actor.h

@@ -475,7 +475,7 @@ namespace NActors {
                 }
 
                 ~TRecurseContext() {
-                    Y_VERIFY(TlsActivationContext == this, "TlsActivationContext mismatch; probably InvokeOtherActor was invoked from a coroutine");
+                    Y_ABORT_UNLESS(TlsActivationContext == this, "TlsActivationContext mismatch; probably InvokeOtherActor was invoked from a coroutine");
                     TlsActivationContext = Prev;
                 }
             } context(actor.SelfId());
@@ -902,7 +902,7 @@ namespace NActors {
 
     template <ESendingType SendingType>
     TActorId IActor::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) const noexcept {
-        Y_VERIFY(actor);
+        Y_ABORT_UNLESS(actor);
         return TlsActivationContext->ExecutorThread.RegisterActor<SendingType>(actor, mailboxType, poolId, SelfActorId);
     }
 
@@ -910,8 +910,8 @@ namespace NActors {
     template <ESendingType SendingType>
     TActorId TActorSystem::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 executorPool,
                         ui64 revolvingCounter, const TActorId& parentId) {
-        Y_VERIFY(actor);
-        Y_VERIFY(executorPool < ExecutorPoolCount, "executorPool# %" PRIu32 ", ExecutorPoolCount# %" PRIu32,
+        Y_ABORT_UNLESS(actor);
+        Y_ABORT_UNLESS(executorPool < ExecutorPoolCount, "executorPool# %" PRIu32 ", ExecutorPoolCount# %" PRIu32,
                 (ui32)executorPool, (ui32)ExecutorPoolCount);
         if constexpr (SendingType == ESendingType::Common) {
             return CpuManager->GetExecutorPool(executorPool)->Register(actor, mailboxType, revolvingCounter, parentId);

+ 1 - 1
library/cpp/actors/core/actor_bootstrapped.h

@@ -16,7 +16,7 @@ namespace NActors {
         }
 
         STFUNC(StateBootstrap) {
-            Y_VERIFY(ev->GetTypeRewrite() == TEvents::TSystem::Bootstrap, "Unexpected bootstrap message");
+            Y_ABORT_UNLESS(ev->GetTypeRewrite() == TEvents::TSystem::Bootstrap, "Unexpected bootstrap message");
             using T = decltype(&TDerived::Bootstrap);
             TDerived& self = static_cast<TDerived&>(*this);
             if constexpr (std::is_invocable_v<T, TDerived, const TActorContext&>) {

+ 7 - 7
library/cpp/actors/core/actor_coroutine.cpp

@@ -57,7 +57,7 @@ namespace NActors {
         }
 
         // ensure we have no unprocessed event and return back to actor system to receive one
-        Y_VERIFY(!Finished);
+        Y_ABORT_UNLESS(!Finished);
 
         // obtain pending event and ensure we've got one
         while (THolder<IEventHandle> event = ReturnToActorSystem()) {
@@ -72,7 +72,7 @@ namespace NActors {
 
     bool TActorCoroImpl::ProcessEvent(THolder<IEventHandle> ev) {
         if (!SelfActorId) { // process bootstrap message, extract actor ids
-            Y_VERIFY(ev->GetTypeRewrite() == TEvents::TSystem::Bootstrap);
+            Y_ABORT_UNLESS(ev->GetTypeRewrite() == TEvents::TSystem::Bootstrap);
             SelfActorId = ev->Recipient;
             ParentActorId = ev->Sender;
             ev.Reset();
@@ -97,7 +97,7 @@ namespace NActors {
     void TActorCoroImpl::Resume(THolder<IEventHandle> ev) {
         BeforeResume();
 
-        Y_VERIFY(!PendingEvent);
+        Y_ABORT_UNLESS(!PendingEvent);
         PendingEvent.Swap(ev);
 
 #if CORO_THROUGH_THREADS
@@ -106,7 +106,7 @@ namespace NActors {
         OutEvent.Wait();
 #else
         // save caller context for a later return
-        Y_VERIFY(!ActorSystemContext);
+        Y_ABORT_UNLESS(!ActorSystemContext);
         TExceptionSafeContext actorSystemContext;
         ActorSystemContext = &actorSystemContext;
 
@@ -114,7 +114,7 @@ namespace NActors {
         ActorSystemContext->SwitchTo(&FiberContext);
 #endif
 
-        Y_VERIFY(!PendingEvent);
+        Y_ABORT_UNLESS(!PendingEvent);
     }
 
     void TActorCoroImpl::DoRun() {
@@ -150,7 +150,7 @@ namespace NActors {
         }
 #else
         TExceptionSafeContext* returnContext = std::exchange(ActorSystemContext, nullptr);
-        Y_VERIFY(returnContext);
+        Y_ABORT_UNLESS(returnContext);
         if (StoreTlsState) {
             StoreTlsState(this);
         }
@@ -165,7 +165,7 @@ namespace NActors {
         } else {
             // we have returned from the actor system and it kindly asks us to terminate the coroutine as it is being
             // stopped
-            Y_VERIFY(InvokedFromDtor);
+            Y_ABORT_UNLESS(InvokedFromDtor);
             throw TDtorException();
         }
     }

+ 1 - 1
library/cpp/actors/core/actor_virtual.h

@@ -21,7 +21,7 @@ public:
     {
         Y_VERIFY_DEBUG(dynamic_cast<TEvent*>(Handle->GetBase()));
         Event = static_cast<TEvent*>(Handle->GetBase());
-        Y_VERIFY(Event);
+        Y_ABORT_UNLESS(Event);
     }
 };
 

+ 1 - 1
library/cpp/actors/core/actorid.h

@@ -50,7 +50,7 @@ namespace NActors {
         }
 
         explicit TActorId(ui32 nodeId, const TStringBuf& x) noexcept {
-            Y_VERIFY(x.size() <= MaxServiceIDLength, "service id is too long");
+            Y_ABORT_UNLESS(x.size() <= MaxServiceIDLength, "service id is too long");
             Raw.N.LocalId = 0;
             Raw.N.Hint = 0;
             Raw.N.NodeId = nodeId | ServiceMask;

+ 4 - 4
library/cpp/actors/core/actorsystem.cpp

@@ -106,7 +106,7 @@ namespace NActors {
         if (recpNodeId != NodeId && recpNodeId != 0) {
             // if recipient is not local one - rewrite with forward instruction
             Y_VERIFY_DEBUG(!ev->HasEvent() || ev->GetBase()->IsSerializable());
-            Y_VERIFY(ev->Recipient == recipient,
+            Y_ABORT_UNLESS(ev->Recipient == recipient,
                 "Event rewrite from %s to %s would be lost via interconnect",
                 ev->Recipient.ToString().c_str(),
                 recipient.ToString().c_str());
@@ -255,7 +255,7 @@ namespace NActors {
     }
 
     void TActorSystem::Start() {
-        Y_VERIFY(StartExecuted == false);
+        Y_ABORT_UNLESS(StartExecuted == false);
         StartExecuted = true;
 
         ScheduleQueue.Reset(new NSchedulerQueue::TQueueType());
@@ -273,7 +273,7 @@ namespace NActors {
                 TActorSetupCmd& x = setup.ProxyActors[i];
                 if (x.Actor) {
                     Interconnect[i] = Register(x.Actor.release(), x.MailboxType, x.PoolId, i);
-                    Y_VERIFY(!!Interconnect[i]);
+                    Y_ABORT_UNLESS(!!Interconnect[i]);
                 }
             }
             ProxyWrapperFactory = std::move(SystemSetup->Interconnect.ProxyWrapperFactory);
@@ -284,7 +284,7 @@ namespace NActors {
             for (ui32 i = 0, e = (ui32)SystemSetup->LocalServices.size(); i != e; ++i) {
                 std::pair<TActorId, TActorSetupCmd>& x = SystemSetup->LocalServices[i];
                 const TActorId xid = Register(x.second.Actor.release(), x.second.MailboxType, x.second.PoolId, i);
-                Y_VERIFY(!!xid);
+                Y_ABORT_UNLESS(!!xid);
                 if (!!x.first)
                     RegisterLocalService(x.first, xid);
             }

+ 1 - 1
library/cpp/actors/core/actorsystem.h

@@ -117,7 +117,7 @@ namespace NActors {
 
         ui32 GetThreads(ui32 poolId) const {
             auto result = GetThreadsOptional(poolId);
-            Y_VERIFY(result, "undefined pool id: %" PRIu32, (ui32)poolId);
+            Y_ABORT_UNLESS(result, "undefined pool id: %" PRIu32, (ui32)poolId);
             return *result;
         }
 

+ 7 - 7
library/cpp/actors/core/balancer.cpp

@@ -51,11 +51,11 @@ namespace NActors {
             ui64 idle = std::clamp<i64>(1024 - cpuIdle * 512, 0, 1023);
             ui64 scale = std::clamp<i64>(1024 - scaleFactor * 32, 0, 1023);
 
-            Y_VERIFY(ui64(load)     < (1ull << 2ull));
-            Y_VERIFY(ui64(priority) < (1ull << 8ull));
-            Y_VERIFY(ui64(scale)    < (1ull << 10ull));
-            Y_VERIFY(ui64(idle)     < (1ull << 10ull));
-            Y_VERIFY(ui64(poolId)   < (1ull << 6ull));
+            Y_ABORT_UNLESS(ui64(load)     < (1ull << 2ull));
+            Y_ABORT_UNLESS(ui64(priority) < (1ull << 8ull));
+            Y_ABORT_UNLESS(ui64(scale)    < (1ull << 10ull));
+            Y_ABORT_UNLESS(ui64(idle)     < (1ull << 10ull));
+            Y_ABORT_UNLESS(ui64(poolId)   < (1ull << 6ull));
 
             static_assert(ui64(MaxPools) <= (1ull << 6ull));
 
@@ -135,7 +135,7 @@ namespace NActors {
                 Config.MinCpus = std::clamp<ui32>(Config.MinCpus, 1, Config.Cpus);
                 Config.MaxCpus = Max<ui32>(Config.MaxCpus, Config.Cpus);
             } else {
-                Y_VERIFY(Config.Cpus == 0,
+                Y_ABORT_UNLESS(Config.Cpus == 0,
                         "Unexpected negative Config.Cpus# %" PRIi64,
                         (i64)Config.Cpus);
                 Config.MinCpus = 0;
@@ -205,7 +205,7 @@ namespace NActors {
     }
 
     void TBalancer::SetPoolStats(TPoolId pool, const TBalancerStats& stats) {
-        Y_VERIFY(pool < MaxPools);
+        Y_ABORT_UNLESS(pool < MaxPools);
         TPool& p = Pools[pool];
         p.Prev = p.Next;
         p.Next = stats;

+ 10 - 10
library/cpp/actors/core/benchmark_ut.cpp

@@ -210,8 +210,8 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             : Params(params)
             , ActiveEventRegistry_(activeEventRegistry)
         {
-            Y_VERIFY(!Params.Container.empty());
-            Y_VERIFY(Params.Right - Params.Left + 1 <= static_cast<i32>(Params.Container.size()),
+            Y_ABORT_UNLESS(!Params.Container.empty());
+            Y_ABORT_UNLESS(Params.Right - Params.Left + 1 <= static_cast<i32>(Params.Container.size()),
                 "left: %d, right: %d, cont.size: %d", Params.Left, Params.Right, static_cast<i32>(Params.Container.size()));
             ActiveEventRegistry_.SetActive(this);
         }
@@ -242,7 +242,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             switch (ev->GetTypeRewrite()) {
                 hFunc(TEvQuickSort, Handle);
                 default:
-                    Y_VERIFY(false);
+                    Y_ABORT_UNLESS(false);
             }
         }
 
@@ -373,7 +373,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
 
             BENCH_START(thread);
 
-            Y_VERIFY(threadPool.AddAndOwn(THolder(new TQuickSortTask(params, activeThreadRegistry))));
+            Y_ABORT_UNLESS(threadPool.AddAndOwn(THolder(new TQuickSortTask(params, activeThreadRegistry))));
             UNIT_ASSERT_C(activeThreadRegistry.WaitForAllInactive(60s), "timeout");
 
             threaPoolSortDurationTotal += std::chrono::duration_cast<std::chrono::microseconds>(BENCH_END(thread));
@@ -491,7 +491,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             switch (ev->GetTypeRewrite()) {
                 hFunc(TEvKvSendRequests, Handle);
                 default:
-                    Y_VERIFY(false);
+                    Y_ABORT_UNLESS(false);
             }
         }
 
@@ -529,7 +529,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             switch (ev->GetTypeRewrite()) {
                 hFunc(TEvKvSearch, Handle);
                 default:
-                    Y_VERIFY(false);
+                    Y_ABORT_UNLESS(false);
             }
         }
 
@@ -587,7 +587,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             }
         }
 
-        Y_VERIFY(keys.size() >= requestsNumber);
+        Y_ABORT_UNLESS(keys.size() >= requestsNumber);
 
         std::random_shuffle(keys.begin(), keys.end());
         keys.resize(requestsNumber);
@@ -709,7 +709,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             BENCH_START(kvSearch);
 
             for (auto& key : keysToSearch) {
-                Y_VERIFY(threadPool.AddAndOwn(THolder(new TKvSearchTask(key, dict))));
+                Y_ABORT_UNLESS(threadPool.AddAndOwn(THolder(new TKvSearchTask(key, dict))));
             }
 
             // CondVar logic gives too much of overhead (2-10 times more than just sleep_for)
@@ -897,7 +897,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
                 hFunc(TEvSumSendRequests, HandleRequest);
                 hFunc(TEvSumVectorResult, HandleResult);
                 default:
-                    Y_VERIFY(false);
+                    Y_ABORT_UNLESS(false);
             }
         }
 
@@ -974,7 +974,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
             switch (ev->GetTypeRewrite()) {
                 hFunc(TEvSumVector, Handle);
                 default:
-                    Y_VERIFY(false);
+                    Y_ABORT_UNLESS(false);
             }
         }
 

Some files were not shown because too many files changed in this diff