diff options
author | alexvru <alexvru@ydb.tech> | 2023-08-07 19:44:47 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2023-08-07 21:49:19 +0300 |
commit | 39be171bb25ea0ee82a970b3ddacd128fbb95845 (patch) | |
tree | 31bfcbff36bbc411f16e849cc7ec9fa357646dc4 /library/cpp/actors/core/mailbox.h | |
parent | 2a7d26c691d3f5c8f056443dd190679bcc293f84 (diff) | |
download | ydb-39be171bb25ea0ee82a970b3ddacd128fbb95845.tar.gz |
Report actor usage activity KIKIMR-11082
Diffstat (limited to 'library/cpp/actors/core/mailbox.h')
-rw-r--r-- | library/cpp/actors/core/mailbox.h | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/library/cpp/actors/core/mailbox.h b/library/cpp/actors/core/mailbox.h index 6339b6fc23..0f1c3abc10 100644 --- a/library/cpp/actors/core/mailbox.h +++ b/library/cpp/actors/core/mailbox.h @@ -25,7 +25,30 @@ namespace NActors { // 17 bits: line // 12 bits: index of mailbox inside of line - struct TMailboxHeader { + struct TMailboxHeader; + + template<bool> + struct TMailboxUsageImpl { + void Push(ui64 /*localId*/) {} + void ProcessEvents(TMailboxHeader* /*mailbox*/) {} + }; + + template<> + struct TMailboxUsageImpl<true> { + struct TPendingEvent { + ui64 LocalId; + ui64 Timestamp; + }; + NThreading::TReadAsFilledQueue<TPendingEvent> PendingEventQueue; + + ~TMailboxUsageImpl(); + void Push(ui64 localId); + void ProcessEvents(TMailboxHeader *mailbox); + }; + + struct TMailboxHeader + : TMailboxUsageImpl<ActorLibCollectUsageStats> + { struct TMailboxActorPack { enum EType { Simple = 0, @@ -351,7 +374,7 @@ namespace NActors { } static TSimpleMailbox* Get(ui32 hint, void* line) { - return (TSimpleMailbox*)((ui8*)line + hint * 64); // + return (TSimpleMailbox*)((ui8*)line + 64 + (hint - 1) * AlignedSize()); // } static const TMailboxType::EType MailboxType = TMailboxType::Simple; constexpr static ui32 AlignedSize() { @@ -362,8 +385,6 @@ namespace NActors { bool CleanupEvents(); }; - static_assert(sizeof(TSimpleMailbox) == 64, "expect sizeof(TSimpleMailbox) == 64"); - struct TRevolvingMailbox: public TMailboxHeader { // 4 bytes - state // 4 bytes - knobs @@ -387,7 +408,7 @@ namespace NActors { } static TRevolvingMailbox* Get(ui32 hint, void* line) { - return (TRevolvingMailbox*)((ui8*)line + 64 + (hint - 1) * 128); + return (TRevolvingMailbox*)((ui8*)line + 64 + (hint - 1) * AlignedSize()); } constexpr static ui64 MaxMailboxesInLine() { @@ -402,8 +423,6 @@ namespace NActors { bool CleanupEvents(); }; - static_assert(sizeof(TRevolvingMailbox) == 128, "expect sizeof(TRevolvingMailbox) == 128"); - struct THTSwapMailbox: public TMailboxHeader { using TQueueType = NThreading::THTSwapQueue<IEventHandle*>; @@ -430,7 +449,7 @@ namespace NActors { } static THTSwapMailbox* Get(ui32 hint, void* line) { - return (THTSwapMailbox*)((ui8*)line + 64 + (hint - 1) * 64); + return (THTSwapMailbox*)((ui8*)line + 64 + (hint - 1) * AlignedSize()); } constexpr static ui64 MaxMailboxesInLine() { @@ -451,9 +470,6 @@ namespace NActors { } }; - static_assert(sizeof(THTSwapMailbox) == 64, - "expect sizeof(THTSwapMailbox) == 64"); - struct TReadAsFilledMailbox: public TMailboxHeader { using TQueueType = NThreading::TReadAsFilledQueue<IEventHandle>; @@ -480,7 +496,7 @@ namespace NActors { } static TReadAsFilledMailbox* Get(ui32 hint, void* line) { - return (TReadAsFilledMailbox*)((ui8*)line + 64 + (hint - 1) * 192); + return (TReadAsFilledMailbox*)((ui8*)line + 64 + (hint - 1) * AlignedSize()); } constexpr static ui64 MaxMailboxesInLine() { @@ -502,9 +518,6 @@ namespace NActors { } }; - static_assert(sizeof(TReadAsFilledMailbox) == 192, - "expect sizeof(TReadAsFilledMailbox) == 192"); - struct TTinyReadAsFilledMailbox: public TMailboxHeader { using TQueueType = NThreading::TReadAsFilledQueue< IEventHandle, @@ -533,7 +546,7 @@ namespace NActors { } static TTinyReadAsFilledMailbox* Get(ui32 hint, void* line) { - return (TTinyReadAsFilledMailbox*)((ui8*)line + 64 + (hint - 1) * 192); + return (TTinyReadAsFilledMailbox*)((ui8*)line + 64 + (hint - 1) * AlignedSize()); } constexpr static ui64 MaxMailboxesInLine() { @@ -554,8 +567,5 @@ namespace NActors { return done; } }; - - static_assert(sizeof(TTinyReadAsFilledMailbox) == 192, - "expect sizeof(TTinyReadAsFilledMailbox) == 192"); }; } |