Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to send big data using the messaging system of actor? #153

Open
Gabirel opened this issue Jan 3, 2021 · 2 comments
Open

Comments

@Gabirel
Copy link

Gabirel commented Jan 3, 2021

Hi, I am new to the actor-based system. This is my first time to use the actor framework. And I really like riker. It is well-documented and elegant.

But, I ran into a serious issue several days ago and I don't know how to solve it.

How can I send big messages between actors? If I send the messages between actors, I have to derive Clone and Copy traits for the data structs which I used for wrapping messages. Clone is so a big issue to ignore, especially for big messages.

For example, I have a receiver actor for receiving TcpStream. Then the receiver actor processes it, stores some necessary information, and then pass it to the next actor for future processing.

It simply acts like this:

Big Big TcpStream --> receiver actor --> Big big struct (converted from receiver actor) --> A actor (recording some basic info) --> B actor (processes it, or stores it) --> End

So, in my opinion, it is not a good idea to pass big data struct around between actors. It could impact the performance greatly possibly. Maybe is it not a good idea to use an actor-based framework? Maybe I should just stick to the traditional threading methods?

Or, is it possible to pass the reference to that big data struct between actors? (maybe use a pool or something?)


PS:

  • I know this issue is not highly related to the riker itself. But it would be extremely helpful to point out something for me.
  • Are there some projects using riker right now? It will be really nice for me to imitate those codes. (Maybe it is also really nice for a newbie, like me.)
@hardliner66
Copy link
Contributor

I think we should try to get rid of the Clone requirement. There should be no need to clone a Message. Moving it around is definitely a bit harder, but it should work.

In the meantime you could try the following:
Instead of passing the data directly, you can wrap it into an Arc. This way only the Arc gets cloned, which should be way cheaper.

@Gabirel
Copy link
Author

Gabirel commented Jan 10, 2021

@hardliner66 Thanks for your advice. I will try to wrap big struct to Arc.

elegaanz pushed a commit to Plume-org/Plume that referenced this issue Jan 12, 2021
elegaanz pushed a commit to Plume-org/Plume that referenced this issue Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants