leostera / reactor

🚀 Native Actors for Reason and OCaml
70 stars 5 forks source link

High CPU consumption with no traffic in the system #13

Open baransu opened 5 years ago

baransu commented 5 years ago

Right now we run few infinite loops all the time, even when we don't have any running processes. That makes our CPU to not like us that much as we would like to. To experience that, left any example after all messages have been sent and all tasks have been handled.

I have little experience with Unix processes so I have no idea if it's a good idea to kill workers and respawn them when there is new traffic in the system - I assume it's not. I believe together we can figure something out!

leostera commented 5 years ago

@tcoopman brought up on Discord today that we'd probably want a way of sleeping an actor until it's received a new message. After some discussion, having a Sleep(next_state) behavior seemed ideal to put the evaluation of an actor on-hold until there are new messages for it to consume.

tcoopman commented 5 years ago

As a way of tracking this, if your run example one without any changes to the code, you can see the high cpu usage.