-
Notifications
You must be signed in to change notification settings - Fork 52
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
Concurrency #1920
Comments
I would love to make use of concurrency somehow. It may be tricky to apply to evaluation of the robot CESK machines, since If it is any help, I started working on a "timing diagram" of the robot execution sequence. However, there may be an opportunity to run "goal evaluation" in parallel with robot execution, since "goal evaluation" cannot mutate the state of the world. We might need to be able to "roll back" to a previous world state after robot execution if the goal evaluation decided that the scenario has been won/lost. |
Actually there may be an interesting opportunity to impose restrictions (through some kind of effect monad?) on the radius of observability/influence of robots, so that they might be executed concurrently without risk of "race conditions" so long as their "circles of influence" do not intersect. Since there are quite a few robot commands that act at a distance (as well as system robots for which distance restrictions can be ignored), it would take some effort to cover all of the edge cases. |
@kostmo perhaps we could analyze if the robot could influence others at a distance. I imagine a lot of robots only run commands that affect neighborhood cells and the others we could run before them. |
Maybe we could have it such that each robot runs asynchronously for their one tick, then returns say, a pair of a new CESK state and some outward-facing action they want to perform. A main thread would then perform said actions deterministically. |
@xsebek Some ideas: There are some actions which cannot affect other robots, but most of them take 0 ticks to execute. (e.g. |
However a robot's "circle of influence" is infinite because of the improbable effects of the |
Actually, thinking about it some more, since the |
@noahyor my point was that we could identify robots that want to teleport etc. and do only those synchronously. |
Just wrote up some thoughts inspired by this discussion at #1925. Eager to hear what others think. |
Currently, Swarm runs on one thread.
At first, this is not really a problem, as Swarm does not have to do much computation. However, as you build more robots, the maximum tick rate decreases due to the constraints of the single core it is running on.
In the extreme case of the Conway's Game of Life Scenario, I took these screenshots. (using WSL, see #1825)
I think one of the most obvious places to add concurrency is in the CESK evaluation of robots.
We could use the async package to do so.
The text was updated successfully, but these errors were encountered: