Browse Source

Restoring authorship annotation for Alexey Borzenkov <snaury@yandex-team.ru>. Commit 1 of 2.

Alexey Borzenkov 3 years ago
parent
commit
22d92781ba

+ 3 - 3
contrib/libs/grpc/src/core/lib/surface/call.cc

@@ -63,8 +63,8 @@
 #include "src/core/lib/transport/status_metadata.h"
 #include "src/core/lib/transport/status_metadata.h"
 #include "src/core/lib/transport/transport.h"
 #include "src/core/lib/transport/transport.h"
 
 
-#include <util/system/yassert.h>
-
+#include <util/system/yassert.h> 
+ 
 /** The maximum number of concurrent batches possible.
 /** The maximum number of concurrent batches possible.
     Based upon the maximum number of individually queueable ops in the batch
     Based upon the maximum number of individually queueable ops in the batch
     api:
     api:
@@ -1915,7 +1915,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
 
 
   GRPC_CALL_INTERNAL_REF(call, "completion");
   GRPC_CALL_INTERNAL_REF(call, "completion");
   if (!is_notify_tag_closure) {
   if (!is_notify_tag_closure) {
-    Y_VERIFY(grpc_cq_begin_op(call->cq, notify_tag));
+    Y_VERIFY(grpc_cq_begin_op(call->cq, notify_tag)); 
   }
   }
   bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
   bctl->set_num_steps_to_complete((has_send_ops ? 1 : 0) + num_recv_ops);
 
 

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

@@ -37,10 +37,10 @@ namespace NActors {
         TlsActivationContext->ExecutorThread.Schedule(deadline, ev, cookie);
         TlsActivationContext->ExecutorThread.Schedule(deadline, ev, cookie);
     }
     }
 
 
-    void TActivationContext::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) {
-        TlsActivationContext->ExecutorThread.Schedule(deadline, ev, cookie);
-    }
-
+    void TActivationContext::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) { 
+        TlsActivationContext->ExecutorThread.Schedule(deadline, ev, cookie); 
+    } 
+ 
     void TActivationContext::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) {
     void TActivationContext::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) {
         TlsActivationContext->ExecutorThread.Schedule(delta, ev, cookie);
         TlsActivationContext->ExecutorThread.Schedule(delta, ev, cookie);
     }
     }
@@ -87,14 +87,14 @@ namespace NActors {
         return TlsActivationContext->ExecutorThread.ActorSystem;
         return TlsActivationContext->ExecutorThread.ActorSystem;
     }
     }
 
 
-    i64 TActivationContext::GetCurrentEventTicks() {
+    i64 TActivationContext::GetCurrentEventTicks() { 
         return GetCycleCountFast() - TlsActivationContext->EventStart;
         return GetCycleCountFast() - TlsActivationContext->EventStart;
-    }
-
-    double TActivationContext::GetCurrentEventTicksAsSeconds() {
-        return NHPTimer::GetSeconds(GetCurrentEventTicks());
-    }
-
+    } 
+ 
+    double TActivationContext::GetCurrentEventTicksAsSeconds() { 
+        return NHPTimer::GetSeconds(GetCurrentEventTicks()); 
+    } 
+ 
     TActorId TActorContext::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) const {
     TActorId TActorContext::Register(IActor* actor, TMailboxType::EType mailboxType, ui32 poolId) const {
         return ExecutorThread.RegisterActor(actor, mailboxType, poolId, SelfID);
         return ExecutorThread.RegisterActor(actor, mailboxType, poolId, SelfID);
     }
     }
@@ -107,10 +107,10 @@ namespace NActors {
         ExecutorThread.Schedule(deadline, new IEventHandle(SelfID, TActorId(), ev), cookie);
         ExecutorThread.Schedule(deadline, new IEventHandle(SelfID, TActorId(), ev), cookie);
     }
     }
 
 
-    void TActorContext::Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie) const {
-        ExecutorThread.Schedule(deadline, new IEventHandle(SelfID, TActorId(), ev), cookie);
-    }
-
+    void TActorContext::Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie) const { 
+        ExecutorThread.Schedule(deadline, new IEventHandle(SelfID, TActorId(), ev), cookie); 
+    } 
+ 
     void TActorContext::Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie) const {
     void TActorContext::Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie) const {
         ExecutorThread.Schedule(delta, new IEventHandle(SelfID, TActorId(), ev), cookie);
         ExecutorThread.Schedule(delta, new IEventHandle(SelfID, TActorId(), ev), cookie);
     }
     }
@@ -119,10 +119,10 @@ namespace NActors {
         TlsActivationContext->ExecutorThread.Schedule(deadline, new IEventHandle(SelfActorId, TActorId(), ev), cookie);
         TlsActivationContext->ExecutorThread.Schedule(deadline, new IEventHandle(SelfActorId, TActorId(), ev), cookie);
     }
     }
 
 
-    void IActor::Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie) const noexcept {
-        TlsActivationContext->ExecutorThread.Schedule(deadline, new IEventHandle(SelfActorId, TActorId(), ev), cookie);
-    }
-
+    void IActor::Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie) const noexcept { 
+        TlsActivationContext->ExecutorThread.Schedule(deadline, new IEventHandle(SelfActorId, TActorId(), ev), cookie); 
+    } 
+ 
     void IActor::Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie) const noexcept {
     void IActor::Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie) const noexcept {
         TlsActivationContext->ExecutorThread.Schedule(delta, new IEventHandle(SelfActorId, TActorId(), ev), cookie);
         TlsActivationContext->ExecutorThread.Schedule(delta, new IEventHandle(SelfActorId, TActorId(), ev), cookie);
     }
     }
@@ -131,10 +131,10 @@ namespace NActors {
         return TlsActivationContext->ExecutorThread.ActorSystem->Timestamp();
         return TlsActivationContext->ExecutorThread.ActorSystem->Timestamp();
     }
     }
 
 
-    TMonotonic TActivationContext::Monotonic() {
-        return TlsActivationContext->ExecutorThread.ActorSystem->Monotonic();
-    }
-
+    TMonotonic TActivationContext::Monotonic() { 
+        return TlsActivationContext->ExecutorThread.ActorSystem->Monotonic(); 
+    } 
+ 
     TInstant TActorContext::Now() const {
     TInstant TActorContext::Now() const {
         return ExecutorThread.ActorSystem->Timestamp();
         return ExecutorThread.ActorSystem->Timestamp();
     }
     }

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

@@ -1,7 +1,7 @@
 #pragma once
 #pragma once
 
 
 #include "event.h"
 #include "event.h"
-#include "monotonic.h"
+#include "monotonic.h" 
 #include <util/system/tls.h>
 #include <util/system/tls.h>
 #include <library/cpp/actors/util/local_process_key.h>
 #include <library/cpp/actors/util/local_process_key.h>
 
 
@@ -24,13 +24,13 @@ namespace NActors {
     public:
     public:
         TMailboxHeader& Mailbox;
         TMailboxHeader& Mailbox;
         TExecutorThread& ExecutorThread;
         TExecutorThread& ExecutorThread;
-        const NHPTimer::STime EventStart;
+        const NHPTimer::STime EventStart; 
 
 
     protected:
     protected:
-        explicit TActivationContext(TMailboxHeader& mailbox, TExecutorThread& executorThread, NHPTimer::STime eventStart)
+        explicit TActivationContext(TMailboxHeader& mailbox, TExecutorThread& executorThread, NHPTimer::STime eventStart) 
             : Mailbox(mailbox)
             : Mailbox(mailbox)
             , ExecutorThread(executorThread)
             , ExecutorThread(executorThread)
-            , EventStart(eventStart)
+            , EventStart(eventStart) 
         {
         {
         }
         }
 
 
@@ -40,22 +40,22 @@ namespace NActors {
         /**
         /**
          * Schedule one-shot event that will be send at given time point in the future.
          * Schedule one-shot event that will be send at given time point in the future.
          *
          *
-         * @param deadline   the wallclock time point in future when event must be send
+         * @param deadline   the wallclock time point in future when event must be send 
          * @param ev         the event to send
          * @param ev         the event to send
          * @param cookie     cookie that will be piggybacked with event
          * @param cookie     cookie that will be piggybacked with event
          */
          */
         static void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr);
         static void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr);
 
 
         /**
         /**
-         * Schedule one-shot event that will be send at given time point in the future.
-         *
-         * @param deadline   the monotonic time point in future when event must be send
-         * @param ev         the event to send
-         * @param cookie     cookie that will be piggybacked with event
-         */
-        static void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr);
-
-        /**
+         * Schedule one-shot event that will be send at given time point in the future. 
+         * 
+         * @param deadline   the monotonic time point in future when event must be send 
+         * @param ev         the event to send 
+         * @param cookie     cookie that will be piggybacked with event 
+         */ 
+        static void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr); 
+ 
+        /** 
          * Schedule one-shot event that will be send after given delay.
          * Schedule one-shot event that will be send after given delay.
          *
          *
          * @param delta      the time from now to delay event sending
          * @param delta      the time from now to delay event sending
@@ -65,7 +65,7 @@ namespace NActors {
         static void Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr);
         static void Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr);
 
 
         static TInstant Now();
         static TInstant Now();
-        static TMonotonic Monotonic();
+        static TMonotonic Monotonic(); 
         NLog::TSettings* LoggerSettings() const;
         NLog::TSettings* LoggerSettings() const;
 
 
         // register new actor in ActorSystem on new fresh mailbox.
         // register new actor in ActorSystem on new fresh mailbox.
@@ -83,16 +83,16 @@ namespace NActors {
 
 
         static TActorId InterconnectProxy(ui32 nodeid);
         static TActorId InterconnectProxy(ui32 nodeid);
         static TActorSystem* ActorSystem();
         static TActorSystem* ActorSystem();
-
-        static i64 GetCurrentEventTicks();
-        static double GetCurrentEventTicksAsSeconds();
+ 
+        static i64 GetCurrentEventTicks(); 
+        static double GetCurrentEventTicksAsSeconds(); 
     };
     };
 
 
     struct TActorContext: public TActivationContext {
     struct TActorContext: public TActivationContext {
         const TActorId SelfID;
         const TActorId SelfID;
 
 
         explicit TActorContext(TMailboxHeader& mailbox, TExecutorThread& executorThread, NHPTimer::STime eventStart, const TActorId& selfID)
         explicit TActorContext(TMailboxHeader& mailbox, TExecutorThread& executorThread, NHPTimer::STime eventStart, const TActorId& selfID)
-            : TActivationContext(mailbox, executorThread, eventStart)
+            : TActivationContext(mailbox, executorThread, eventStart) 
             , SelfID(selfID)
             , SelfID(selfID)
         {
         {
         }
         }
@@ -110,22 +110,22 @@ namespace NActors {
         /**
         /**
          * Schedule one-shot event that will be send at given time point in the future.
          * Schedule one-shot event that will be send at given time point in the future.
          *
          *
-         * @param deadline   the wallclock time point in future when event must be send
+         * @param deadline   the wallclock time point in future when event must be send 
          * @param ev         the event to send
          * @param ev         the event to send
          * @param cookie     cookie that will be piggybacked with event
          * @param cookie     cookie that will be piggybacked with event
          */
          */
         void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const;
         void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const;
 
 
         /**
         /**
-         * Schedule one-shot event that will be send at given time point in the future.
-         *
-         * @param deadline   the monotonic time point in future when event must be send
-         * @param ev         the event to send
-         * @param cookie     cookie that will be piggybacked with event
-         */
-        void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const;
-
-        /**
+         * Schedule one-shot event that will be send at given time point in the future. 
+         * 
+         * @param deadline   the monotonic time point in future when event must be send 
+         * @param ev         the event to send 
+         * @param cookie     cookie that will be piggybacked with event 
+         */ 
+        void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const; 
+ 
+        /** 
          * Schedule one-shot event that will be send after given delay.
          * Schedule one-shot event that will be send after given delay.
          *
          *
          * @param delta      the time from now to delay event sending
          * @param delta      the time from now to delay event sending
@@ -135,7 +135,7 @@ namespace NActors {
         void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const;
         void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const;
 
 
         TActorContext MakeFor(const TActorId& otherId) const {
         TActorContext MakeFor(const TActorId& otherId) const {
-            return TActorContext(Mailbox, ExecutorThread, EventStart, otherId);
+            return TActorContext(Mailbox, ExecutorThread, EventStart, otherId); 
         }
         }
 
 
         // register new actor in ActorSystem on new fresh mailbox.
         // register new actor in ActorSystem on new fresh mailbox.
@@ -179,22 +179,22 @@ namespace NActors {
         /**
         /**
          * Schedule one-shot event that will be send at given time point in the future.
          * Schedule one-shot event that will be send at given time point in the future.
          *
          *
-         * @param deadline   the wallclock time point in future when event must be send
+         * @param deadline   the wallclock time point in future when event must be send 
          * @param ev         the event to send
          * @param ev         the event to send
          * @param cookie     cookie that will be piggybacked with event
          * @param cookie     cookie that will be piggybacked with event
          */
          */
         virtual void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept = 0;
         virtual void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept = 0;
 
 
         /**
         /**
-         * Schedule one-shot event that will be send at given time point in the future.
-         *
-         * @param deadline   the monotonic time point in future when event must be send
-         * @param ev         the event to send
-         * @param cookie     cookie that will be piggybacked with event
-         */
-        virtual void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept = 0;
-
-        /**
+         * Schedule one-shot event that will be send at given time point in the future. 
+         * 
+         * @param deadline   the monotonic time point in future when event must be send 
+         * @param ev         the event to send 
+         * @param cookie     cookie that will be piggybacked with event 
+         */ 
+        virtual void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept = 0; 
+ 
+        /** 
          * Schedule one-shot event that will be send after given delay.
          * Schedule one-shot event that will be send after given delay.
          *
          *
          * @param delta      the time from now to delay event sending
          * @param delta      the time from now to delay event sending
@@ -240,11 +240,11 @@ namespace NActors {
             INTERCONNECT_SESSION_KILLER = 286,
             INTERCONNECT_SESSION_KILLER = 286,
             ACTOR_SYSTEM_SCHEDULER_ACTOR = 312,
             ACTOR_SYSTEM_SCHEDULER_ACTOR = 312,
             ACTOR_FUTURE_CALLBACK = 337,
             ACTOR_FUTURE_CALLBACK = 337,
-            INTERCONNECT_MONACTOR = 362,
+            INTERCONNECT_MONACTOR = 362, 
             INTERCONNECT_LOAD_ACTOR = 376,
             INTERCONNECT_LOAD_ACTOR = 376,
             INTERCONNECT_LOAD_RESPONDER = 377,
             INTERCONNECT_LOAD_RESPONDER = 377,
             NAMESERVICE = 450,
             NAMESERVICE = 450,
-            DNS_RESOLVER = 481,
+            DNS_RESOLVER = 481, 
             INTERCONNECT_PROXY_WRAPPER = 546,
             INTERCONNECT_PROXY_WRAPPER = 546,
         };
         };
 
 
@@ -362,7 +362,7 @@ namespace NActors {
         }
         }
 
 
         void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final;
         void Schedule(TInstant deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final;
-        void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final;
+        void Schedule(TMonotonic deadline, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final; 
         void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final;
         void Schedule(TDuration delta, IEventBase* ev, ISchedulerCookie* cookie = nullptr) const noexcept final;
 
 
         // register new actor in ActorSystem on new fresh mailbox.
         // register new actor in ActorSystem on new fresh mailbox.
@@ -456,7 +456,7 @@ namespace NActors {
 
 
     inline TActorContext TActivationContext::ActorContextFor(TActorId id) {
     inline TActorContext TActivationContext::ActorContextFor(TActorId id) {
         auto& tls = *TlsActivationContext;
         auto& tls = *TlsActivationContext;
-        return TActorContext(tls.Mailbox, tls.ExecutorThread, tls.EventStart, id);
+        return TActorContext(tls.Mailbox, tls.ExecutorThread, tls.EventStart, id); 
     }
     }
 
 
     class TDecorator : public IActor {
     class TDecorator : public IActor {

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

@@ -1,9 +1,9 @@
 #include "actor_coroutine.h"
 #include "actor_coroutine.h"
 #include "executor_thread.h"
 #include "executor_thread.h"
 
 
-#include <util/system/sanitizers.h>
+#include <util/system/sanitizers.h> 
 #include <util/system/type_name.h>
 #include <util/system/type_name.h>
-
+ 
 namespace NActors {
 namespace NActors {
     static constexpr size_t StackOverflowGap = 4096;
     static constexpr size_t StackOverflowGap = 4096;
     static char GoodStack[StackOverflowGap];
     static char GoodStack[StackOverflowGap];
@@ -92,8 +92,8 @@ namespace NActors {
         }
         }
 
 
         // prepare actor context for in-coroutine use
         // prepare actor context for in-coroutine use
-        TActivationContext *ac = TlsActivationContext;
-        TlsActivationContext = nullptr;
+        TActivationContext *ac = TlsActivationContext; 
+        TlsActivationContext = nullptr; 
         TActorContext ctx(ac->Mailbox, ac->ExecutorThread, ac->EventStart, SelfActorId);
         TActorContext ctx(ac->Mailbox, ac->ExecutorThread, ac->EventStart, SelfActorId);
         ActorContext = &ctx;
         ActorContext = &ctx;
 
 

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

@@ -12,13 +12,13 @@ namespace NActors {
     // next 20 bits - node id itself
     // next 20 bits - node id itself
 
 
     struct TActorId {
     struct TActorId {
-        static constexpr ui32 MaxServiceIDLength = 12;
-        static constexpr ui32 MaxPoolID = 0x000007FF;
-        static constexpr ui32 MaxNodeId = 0x000FFFFF;
-        static constexpr ui32 PoolIndexShift = 20;
-        static constexpr ui32 PoolIndexMask = MaxPoolID << PoolIndexShift;
-        static constexpr ui32 ServiceMask = 0x80000000;
-        static constexpr ui32 NodeIdMask = MaxNodeId;
+        static constexpr ui32 MaxServiceIDLength = 12; 
+        static constexpr ui32 MaxPoolID = 0x000007FF; 
+        static constexpr ui32 MaxNodeId = 0x000FFFFF; 
+        static constexpr ui32 PoolIndexShift = 20; 
+        static constexpr ui32 PoolIndexMask = MaxPoolID << PoolIndexShift; 
+        static constexpr ui32 ServiceMask = 0x80000000; 
+        static constexpr ui32 NodeIdMask = MaxNodeId; 
 
 
     private:
     private:
         union {
         union {

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

@@ -43,7 +43,7 @@ namespace NActors {
         , Scheduler(setup->Scheduler)
         , Scheduler(setup->Scheduler)
         , InterconnectCount((ui32)setup->Interconnect.ProxyActors.size())
         , InterconnectCount((ui32)setup->Interconnect.ProxyActors.size())
         , CurrentTimestamp(0)
         , CurrentTimestamp(0)
-        , CurrentMonotonic(0)
+        , CurrentMonotonic(0) 
         , CurrentIDCounter(RandomNumber<ui64>())
         , CurrentIDCounter(RandomNumber<ui64>())
         , SystemSetup(setup.Release())
         , SystemSetup(setup.Release())
         , DefSelfID(NodeId, "actorsystem")
         , DefSelfID(NodeId, "actorsystem")
@@ -69,15 +69,15 @@ namespace NActors {
 #endif
 #endif
 
 
         TActorId recipient = ev->GetRecipientRewrite();
         TActorId recipient = ev->GetRecipientRewrite();
-        const ui32 recpNodeId = recipient.NodeId();
+        const ui32 recpNodeId = recipient.NodeId(); 
 
 
         if (recpNodeId != NodeId && recpNodeId != 0) {
         if (recpNodeId != NodeId && recpNodeId != 0) {
             // if recipient is not local one - rewrite with forward instruction
             // if recipient is not local one - rewrite with forward instruction
             Y_VERIFY_DEBUG(!ev->HasEvent() || ev->GetBase()->IsSerializable());
             Y_VERIFY_DEBUG(!ev->HasEvent() || ev->GetBase()->IsSerializable());
-            Y_VERIFY(ev->Recipient == recipient,
-                "Event rewrite from %s to %s would be lost via interconnect",
-                ev->Recipient.ToString().c_str(),
-                recipient.ToString().c_str());
+            Y_VERIFY(ev->Recipient == recipient, 
+                "Event rewrite from %s to %s would be lost via interconnect", 
+                ev->Recipient.ToString().c_str(), 
+                recipient.ToString().c_str()); 
             recipient = InterconnectProxy(recpNodeId);
             recipient = InterconnectProxy(recpNodeId);
             ev->Rewrite(TEvInterconnect::EvForward, recipient);
             ev->Rewrite(TEvInterconnect::EvForward, recipient);
         }
         }
@@ -119,20 +119,20 @@ namespace NActors {
     }
     }
 
 
     void TActorSystem::Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const {
     void TActorSystem::Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const {
-        Schedule(deadline - Timestamp(), ev, cookie);
-    }
-
-    void TActorSystem::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const {
-        const auto current = Monotonic();
-        if (deadline < current)
-            deadline = current;
-
-        TTicketLock::TGuard guard(&ScheduleLock);
-        ScheduleQueue->Writer.Push(deadline.MicroSeconds(), ev.Release(), cookie);
+        Schedule(deadline - Timestamp(), ev, cookie); 
     }
     }
 
 
+    void TActorSystem::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const { 
+        const auto current = Monotonic(); 
+        if (deadline < current) 
+            deadline = current; 
+ 
+        TTicketLock::TGuard guard(&ScheduleLock); 
+        ScheduleQueue->Writer.Push(deadline.MicroSeconds(), ev.Release(), cookie); 
+    } 
+ 
     void TActorSystem::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const {
     void TActorSystem::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie) const {
-        const auto deadline = Monotonic() + delta;
+        const auto deadline = Monotonic() + delta; 
 
 
         TTicketLock::TGuard guard(&ScheduleLock);
         TTicketLock::TGuard guard(&ScheduleLock);
         ScheduleQueue->Writer.Push(deadline.MicroSeconds(), ev.Release(), cookie);
         ScheduleQueue->Writer.Push(deadline.MicroSeconds(), ev.Release(), cookie);
@@ -211,7 +211,7 @@ namespace NActors {
         TVector<NSchedulerQueue::TReader*> scheduleReaders;
         TVector<NSchedulerQueue::TReader*> scheduleReaders;
         scheduleReaders.push_back(&ScheduleQueue->Reader);
         scheduleReaders.push_back(&ScheduleQueue->Reader);
         CpuManager->PrepareStart(scheduleReaders, this);
         CpuManager->PrepareStart(scheduleReaders, this);
-        Scheduler->Prepare(this, &CurrentTimestamp, &CurrentMonotonic);
+        Scheduler->Prepare(this, &CurrentTimestamp, &CurrentMonotonic); 
         Scheduler->PrepareSchedules(&scheduleReaders.front(), (ui32)scheduleReaders.size());
         Scheduler->PrepareSchedules(&scheduleReaders.front(), (ui32)scheduleReaders.size());
 
 
         // setup interconnect proxies
         // setup interconnect proxies
@@ -242,9 +242,9 @@ namespace NActors {
         // ok, setup complete, we could destroy setup config
         // ok, setup complete, we could destroy setup config
         SystemSetup.Destroy();
         SystemSetup.Destroy();
 
 
-        Scheduler->PrepareStart();
+        Scheduler->PrepareStart(); 
         CpuManager->Start();
         CpuManager->Start();
-        Send(MakeSchedulerActorId(), new TEvSchedulerInitialize(scheduleReaders, &CurrentTimestamp, &CurrentMonotonic));
+        Send(MakeSchedulerActorId(), new TEvSchedulerInitialize(scheduleReaders, &CurrentTimestamp, &CurrentMonotonic)); 
         Scheduler->Start();
         Scheduler->Start();
     }
     }
 
 

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

@@ -27,7 +27,7 @@ namespace NActors {
         char data[12];
         char data[12];
         memcpy(data, "ICProxy@", 8);
         memcpy(data, "ICProxy@", 8);
         memcpy(data + 8, &destNodeId, sizeof(ui32));
         memcpy(data + 8, &destNodeId, sizeof(ui32));
-        return TActorId(0, TStringBuf(data, 12));
+        return TActorId(0, TStringBuf(data, 12)); 
     }
     }
 
 
     inline bool IsInterconnectProxyId(const TActorId& actorId) {
     inline bool IsInterconnectProxyId(const TActorId& actorId) {
@@ -69,7 +69,7 @@ namespace NActors {
         /**
         /**
          * Schedule one-shot event that will be send at given time point in the future.
          * Schedule one-shot event that will be send at given time point in the future.
          *
          *
-         * @param deadline   the wallclock time point in future when event must be send
+         * @param deadline   the wallclock time point in future when event must be send 
          * @param ev         the event to send
          * @param ev         the event to send
          * @param cookie     cookie that will be piggybacked with event
          * @param cookie     cookie that will be piggybacked with event
          * @param workerId   index of thread which will perform event dispatching
          * @param workerId   index of thread which will perform event dispatching
@@ -77,16 +77,16 @@ namespace NActors {
         virtual void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) = 0;
         virtual void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) = 0;
 
 
         /**
         /**
-         * Schedule one-shot event that will be send at given time point in the future.
-         *
-         * @param deadline   the monotonic time point in future when event must be send
-         * @param ev         the event to send
-         * @param cookie     cookie that will be piggybacked with event
+         * Schedule one-shot event that will be send at given time point in the future. 
+         * 
+         * @param deadline   the monotonic time point in future when event must be send 
+         * @param ev         the event to send 
+         * @param cookie     cookie that will be piggybacked with event 
          * @param workerId   index of thread which will perform event dispatching
          * @param workerId   index of thread which will perform event dispatching
-         */
+         */ 
         virtual void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) = 0;
         virtual void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) = 0;
-
-        /**
+ 
+        /** 
          * Schedule one-shot event that will be send after given delay.
          * Schedule one-shot event that will be send after given delay.
          *
          *
          * @param delta      the time from now to delay event sending
          * @param delta      the time from now to delay event sending
@@ -136,9 +136,9 @@ namespace NActors {
         virtual ~ISchedulerThread() {
         virtual ~ISchedulerThread() {
         }
         }
 
 
-        virtual void Prepare(TActorSystem* actorSystem, volatile ui64* currentTimestamp, volatile ui64* currentMonotonic) = 0;
+        virtual void Prepare(TActorSystem* actorSystem, volatile ui64* currentTimestamp, volatile ui64* currentMonotonic) = 0; 
         virtual void PrepareSchedules(NSchedulerQueue::TReader** readers, ui32 scheduleReadersCount) = 0;
         virtual void PrepareSchedules(NSchedulerQueue::TReader** readers, ui32 scheduleReadersCount) = 0;
-        virtual void PrepareStart() { /* empty */ }
+        virtual void PrepareStart() { /* empty */ } 
         virtual void Start() = 0;
         virtual void Start() = 0;
         virtual void PrepareStop() = 0;
         virtual void PrepareStop() = 0;
         virtual void Stop() = 0;
         virtual void Stop() = 0;
@@ -226,7 +226,7 @@ namespace NActors {
         TArrayHolder<TActorId> Interconnect;
         TArrayHolder<TActorId> Interconnect;
 
 
         volatile ui64 CurrentTimestamp;
         volatile ui64 CurrentTimestamp;
-        volatile ui64 CurrentMonotonic;
+        volatile ui64 CurrentMonotonic; 
         volatile ui64 CurrentIDCounter;
         volatile ui64 CurrentIDCounter;
 
 
         THolder<NSchedulerQueue::TQueueType> ScheduleQueue;
         THolder<NSchedulerQueue::TQueueType> ScheduleQueue;
@@ -264,22 +264,22 @@ namespace NActors {
         /**
         /**
          * Schedule one-shot event that will be send at given time point in the future.
          * Schedule one-shot event that will be send at given time point in the future.
          *
          *
-         * @param deadline   the wallclock time point in future when event must be send
+         * @param deadline   the wallclock time point in future when event must be send 
          * @param ev         the event to send
          * @param ev         the event to send
          * @param cookie     cookie that will be piggybacked with event
          * @param cookie     cookie that will be piggybacked with event
          */
          */
         void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr) const;
         void Schedule(TInstant deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr) const;
 
 
         /**
         /**
-         * Schedule one-shot event that will be send at given time point in the future.
-         *
-         * @param deadline   the monotonic time point in future when event must be send
-         * @param ev         the event to send
-         * @param cookie     cookie that will be piggybacked with event
-         */
-        void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr) const;
-
-        /**
+         * Schedule one-shot event that will be send at given time point in the future. 
+         * 
+         * @param deadline   the monotonic time point in future when event must be send 
+         * @param ev         the event to send 
+         * @param cookie     cookie that will be piggybacked with event 
+         */ 
+        void Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie = nullptr) const; 
+ 
+        /** 
          * Schedule one-shot event that will be send after given delay.
          * Schedule one-shot event that will be send after given delay.
          *
          *
          * @param delta      the time from now to delay event sending
          * @param delta      the time from now to delay event sending
@@ -340,10 +340,10 @@ namespace NActors {
             return TInstant::MicroSeconds(RelaxedLoad(&CurrentTimestamp));
             return TInstant::MicroSeconds(RelaxedLoad(&CurrentTimestamp));
         }
         }
 
 
-        TMonotonic Monotonic() const {
-            return TMonotonic::MicroSeconds(RelaxedLoad(&CurrentMonotonic));
-        }
-
+        TMonotonic Monotonic() const { 
+            return TMonotonic::MicroSeconds(RelaxedLoad(&CurrentMonotonic)); 
+        } 
+ 
         template <typename T>
         template <typename T>
         T* AppData() const {
         T* AppData() const {
             return (T*)AppData0;
             return (T*)AppData0;

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

@@ -4,7 +4,7 @@
 #include "event_pb.h"
 #include "event_pb.h"
 
 
 #include <library/cpp/actors/protos/actors.pb.h>
 #include <library/cpp/actors/protos/actors.pb.h>
-#include <util/system/unaligned_mem.h>
+#include <util/system/unaligned_mem.h> 
 
 
 namespace NActors {
 namespace NActors {
     struct TEvents {
     struct TEvents {
@@ -161,9 +161,9 @@ namespace NActors {
         private:
         private:
             static TString MakeData(ui32 sourceType, ui32 reason) {
             static TString MakeData(ui32 sourceType, ui32 reason) {
                 TString s = TString::Uninitialized(sizeof(ui32) + sizeof(ui32));
                 TString s = TString::Uninitialized(sizeof(ui32) + sizeof(ui32));
-                char *p = s.Detach();
-                WriteUnaligned<ui32>(p + 0, sourceType);
-                WriteUnaligned<ui32>(p + 4, reason);
+                char *p = s.Detach(); 
+                WriteUnaligned<ui32>(p + 0, sourceType); 
+                WriteUnaligned<ui32>(p + 4, reason); 
                 return s;
                 return s;
             }
             }
         };
         };

+ 3 - 3
library/cpp/actors/core/events_undelivered.cpp

@@ -32,9 +32,9 @@ namespace NActors {
     IEventBase* TEvents::TEvUndelivered::Load(TEventSerializedData* bufs) {
     IEventBase* TEvents::TEvUndelivered::Load(TEventSerializedData* bufs) {
         TString str = bufs->GetString();
         TString str = bufs->GetString();
         Y_VERIFY(str.size() == (sizeof(ui32) + sizeof(ui32)));
         Y_VERIFY(str.size() == (sizeof(ui32) + sizeof(ui32)));
-        const char* p = str.data();
-        const ui64 sourceType = ReadUnaligned<ui32>(p + 0);
-        const ui64 reason = ReadUnaligned<ui32>(p + 4);
+        const char* p = str.data(); 
+        const ui64 sourceType = ReadUnaligned<ui32>(p + 0); 
+        const ui64 reason = ReadUnaligned<ui32>(p + 4); 
         return new TEvUndelivered(sourceType, reason);
         return new TEvUndelivered(sourceType, reason);
     }
     }
 
 

+ 32 - 32
library/cpp/actors/core/executor_pool_basic.cpp

@@ -87,17 +87,17 @@ namespace NActors {
         if (x < 0) {
         if (x < 0) {
 #if defined ACTORSLIB_COLLECT_EXEC_STATS
 #if defined ACTORSLIB_COLLECT_EXEC_STATS
             if (AtomicGetAndIncrement(ThreadUtilization) == 0) {
             if (AtomicGetAndIncrement(ThreadUtilization) == 0) {
-                // Initially counter contains -t0, the pool start timestamp
-                // When the first thread goes to sleep we add t1, so the counter
-                // becomes t1-t0 >= 0, or the duration of max utilization so far.
-                // If the counter was negative and becomes positive, that means
-                // counter just turned into a duration and we should store that
-                // duration. Otherwise another thread raced with us and
-                // subtracted some other timestamp t2.
+                // Initially counter contains -t0, the pool start timestamp 
+                // When the first thread goes to sleep we add t1, so the counter 
+                // becomes t1-t0 >= 0, or the duration of max utilization so far. 
+                // If the counter was negative and becomes positive, that means 
+                // counter just turned into a duration and we should store that 
+                // duration. Otherwise another thread raced with us and 
+                // subtracted some other timestamp t2. 
                 const i64 t = GetCycleCountFast();
                 const i64 t = GetCycleCountFast();
-                const i64 x = AtomicGetAndAdd(MaxUtilizationCounter, t);
-                if (x < 0 && x + t > 0)
-                    AtomicStore(&MaxUtilizationAccumulator, x + t);
+                const i64 x = AtomicGetAndAdd(MaxUtilizationCounter, t); 
+                if (x < 0 && x + t > 0) 
+                    AtomicStore(&MaxUtilizationAccumulator, x + t); 
             }
             }
 #endif
 #endif
 
 
@@ -126,7 +126,7 @@ namespace NActors {
                     if (!doSpin) {
                     if (!doSpin) {
                         break;
                         break;
                     }
                     }
-                    if (RelaxedLoad(&StopFlag)) {
+                    if (RelaxedLoad(&StopFlag)) { 
                         break;
                         break;
                     }
                     }
                 }
                 }
@@ -159,20 +159,20 @@ namespace NActors {
 
 
 #if defined ACTORSLIB_COLLECT_EXEC_STATS
 #if defined ACTORSLIB_COLLECT_EXEC_STATS
             if (AtomicDecrement(ThreadUtilization) == 0) {
             if (AtomicDecrement(ThreadUtilization) == 0) {
-                // When we started sleeping counter contained t1-t0, or the
-                // last duration of max utilization. Now we subtract t2 >= t1,
-                // which turns counter negative again, and the next sleep cycle
-                // at timestamp t3 would be adding some new duration t3-t2.
-                // If the counter was positive and becomes negative that means
-                // there are no current races with other threads and we should
-                // store the last positive duration we observed. Multiple
-                // threads may be adding and subtracting values in potentially
-                // arbitrary order, which would cause counter to oscillate
-                // around zero. When it crosses zero is a good indication of a
-                // correct value.
+                // When we started sleeping counter contained t1-t0, or the 
+                // last duration of max utilization. Now we subtract t2 >= t1, 
+                // which turns counter negative again, and the next sleep cycle 
+                // at timestamp t3 would be adding some new duration t3-t2. 
+                // If the counter was positive and becomes negative that means 
+                // there are no current races with other threads and we should 
+                // store the last positive duration we observed. Multiple 
+                // threads may be adding and subtracting values in potentially 
+                // arbitrary order, which would cause counter to oscillate 
+                // around zero. When it crosses zero is a good indication of a 
+                // correct value. 
                 const i64 t = GetCycleCountFast();
                 const i64 t = GetCycleCountFast();
-                const i64 x = AtomicGetAndAdd(MaxUtilizationCounter, -t);
-                if (x > 0 && x - t < 0)
+                const i64 x = AtomicGetAndAdd(MaxUtilizationCounter, -t); 
+                if (x > 0 && x - t < 0) 
                     AtomicStore(&MaxUtilizationAccumulator, x);
                     AtomicStore(&MaxUtilizationAccumulator, x);
             }
             }
 #endif
 #endif
@@ -305,18 +305,18 @@ namespace NActors {
 
 
     void TBasicExecutorPool::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) {
     void TBasicExecutorPool::Schedule(TMonotonic deadline, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) {
         Y_VERIFY_DEBUG(workerId < PoolThreads);
         Y_VERIFY_DEBUG(workerId < PoolThreads);
-
-        const auto current = ActorSystem->Monotonic();
-        if (deadline < current)
-            deadline = current;
-
+ 
+        const auto current = ActorSystem->Monotonic(); 
+        if (deadline < current) 
+            deadline = current; 
+ 
         ScheduleWriters[workerId].Push(deadline.MicroSeconds(), ev.Release(), cookie);
         ScheduleWriters[workerId].Push(deadline.MicroSeconds(), ev.Release(), cookie);
-    }
-
+    } 
+ 
     void TBasicExecutorPool::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) {
     void TBasicExecutorPool::Schedule(TDuration delta, TAutoPtr<IEventHandle> ev, ISchedulerCookie* cookie, TWorkerId workerId) {
         Y_VERIFY_DEBUG(workerId < PoolThreads);
         Y_VERIFY_DEBUG(workerId < PoolThreads);
 
 
-        const auto deadline = ActorSystem->Monotonic() + delta;
+        const auto deadline = ActorSystem->Monotonic() + delta; 
         ScheduleWriters[workerId].Push(deadline.MicroSeconds(), ev.Release(), cookie);
         ScheduleWriters[workerId].Push(deadline.MicroSeconds(), ev.Release(), cookie);
     }
     }
 
 

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