Comments (3)
@rogeralsing If we want to use the MailboxStatistics, then we need to also call ms.MessageReceived
when a system message is being processed. Otherwise, this can lead to starvation of other actors if an actor receives a sequence of systemMessages. Or MailboxStatistics should be expanded to include ms.SystemMessageReceived
so the total number of messages can be deduced from sum of user+sys messages.
from protoactor-go.
Mailbox is responsible for checking the throughput and yielding
You raise a valid concern. we do have the EndpointWriterMailbox
in remote
which does not even have a throughput setting, it simply reads x messages and send that as a batch to the target actor.
This makes me think that maybe the throughput setting shouldnt even be on the dispatcher?
As different mailbox implementations might have different ways to deal with how it consumes messages.
Maybe the dispatcher should only be responsible for scheduling some task onto whatever thread/goroutine/pool there is?
Thoughts on that?
from protoactor-go.
Let me start by saying that I think the dispatchers in golang cannot be as flexible as how AKKA use them. Go runtime does not provide the same flexibility as AKKA, e.g. there is no way to create an OS thread on demand. But at the same time, it provides nice features that omit the need for certain dispatchers. e.g., in AKKA, I/O heavy actors could be dispatched using a pinnedDispatcher which is used to create an additional java thread to handle that actor to avoid blocking other actors. But Go runtime handles that automatically in case a goroutine is blocked in a syscall for a long time.
So there are few cases that dispatchers can cover, i.e. calling goroutine dispatcher, where the calling actor's goroutine handle the destination's mailbox. Or goroutine pool dispatcher. As far as it goes with interacting with go runtime.
Some of the functionality I added such as AfterStart and BeforeTerminate or BeforeBatchStart are not necessary for the cases that can be implemented. e.g. AfterStart and BeforeTerminate can be added to a dispatcher by creating a wrapper function for processMessage in the dispatcher, pass the wrapper to the goroutine and write the AfterStart and beforeTerminate code before and after calling processMessage. But at the same time, I think dispatcher should have some control over when processMessage returns, e.g. if a goroutine needed to be used to process many mailboxes, the dispatcher should be able to force the mailbox to stop processing messages, even if there are still messages in the mailbox, and continue with another mailbox.
Having said that, I think the whole processMessage functionality and schedulerStatus are features of the dispatcher not the mailbox. The throughput number is also a feature of the dispatcher, along with the counter that keeps track of the number of messages processed. What if, I need a dispatcher that uses time quantum instead of number of messages to address fairness and liveliness? Although current design is good for performance, but I feel does not provide enough flexibility down the road for having variety of dispatchers.
Another issue is what if there is a dispatcher that requires a specific kind of mailbox? how can this dependency be addressed?
from protoactor-go.
Related Issues (20)
- ensureTopicKindRegistered is not a good idea HOT 1
- subscriber may block PubSubMemberDeliveryActor
- Remove sprintf logging HOT 1
- Batch message sent twice? HOT 2
- Logging is a breaking change HOT 1
- MemberStrategy is not work!!!
- Go coroutine thread safe HOT 2
- Is every actor message Receiver run in they own goroutine ? HOT 1
- How can a member within a cluster be restarted? HOT 2
- How can I make ‘Spawn’ return the error that occurred when 'Started' is received? HOT 4
- Data Race
- Possible memory leak HOT 1
- Go 1.21 slog HOT 3
- cluster.Request vs cluster.Call
- Port OpenTelemetry tracing from OpenTracing HOT 1
- About using your code, and copyright
- protoc-gen-gograinv2 cannot recognize google.protobuf.Empty
- How to do grain reentrance HOT 2
- Improve code generation HOT 1
- Remove GrainResponse HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoactor-go.