-
Notifications
You must be signed in to change notification settings - Fork 946
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
Improve visualization performance through multi-threading #2604
Comments
This looks interesting! Can I start working on it? |
Sure! |
Few models (like Wolf-Sheep) throw errors with unidirectional threading. I went ahead and added bidirectional sync for the simulator. Should we make bidirectional sync mandatory for all models, or keep it configurable? Also, any ideas on a better way to handle this—maybe using asyncio.Queue instead of events? |
Could you figure out why some models throw these errors? Do they need bidirectional sync, and if so any reason why? CC @quaquel |
Mesa currently runs model execution and visualization rendering on the same thread, creating performance bottlenecks when running computationally intensive models with multiple visualizations. This impacts responsiveness, especially in Jupyter notebooks. The UI can lag or freeze during model execution since visualization updates block the main thread.
We could improve performance by leveraging Solara's
use_thread()
functionality to run visualizations on separate threads from model execution. This would allow the model to continue executing while visualizations update asynchronously.There could be (at least) three threads:
Some key questions to resolve:
Next steps would be to prototype basic thread separation, benchmark improvements, and document the threading behavior.
See also:
CC @quaquel @Corvince
The text was updated successfully, but these errors were encountered: