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

Multithreaded job/task system #2020

Open
slime73 opened this issue Feb 11, 2024 · 3 comments
Open

Multithreaded job/task system #2020

slime73 opened this issue Feb 11, 2024 · 3 comments
Labels
feature New feature or request
Milestone

Comments

@slime73
Copy link
Member

slime73 commented Feb 11, 2024

Computers, consoles, and phones all have more than one CPU core these days. But aside from audio/video decoding, all of love's own internal code is singlethreaded. We do have APIs to run Lua code in multiple OS threads, but because each thread needs its own Lua instance it takes work to use efficiently in a lot of situations - independent heavy algorithm processing and asset loading are the two easiest ways to use love's threads right now.

Most modern game engines have an integrated job/task system they use with a thread pool, to parallelize their own work (for example render command generation or physics simulation) and often to parallelize game code, all in a fairly simple manner.

It'd be nice to have something like that in love - maybe just for internal use to start (if good uses can be found) since more infrastructure and profiling work would need to be done to make it really solid in Lua code. In particular it becomes a lot easier to know how to use and misuse a job/task system when there's a way to visualize the different parts of a frame and what job threads are doing in a given section, and there would be details to figure out for keeping jobified Lua functions side effect free in a given job thread.

enkiTS seems like a solid library for the base of this sort of thing.

@slime73 slime73 added this to the 13.0 milestone Feb 11, 2024
@slime73 slime73 added the feature New feature or request label Feb 11, 2024
@HDPLocust
Copy link

It is also very good to transfer network interaction (especially UDP) to a child thread, otherwise lags in the game can lead to the loss of datagrams, both receiving and sending. Perhaps it would also be nice to transfer interaction with ENet to other threads.

@slime73
Copy link
Member Author

slime73 commented Feb 12, 2024

For networking, a dedicated thread (which is already possible) might make more sense than a job system (which is also already possible, just not as integrated as I'd like). However I'm not sure even a dedicated thread is super useful most of the time for realtime networking.

@HDPLocust
Copy link

However I'm not sure even a dedicated thread is super useful most of the time for realtime networking.

Yes, no one is stopping you from using love2d threads for network activity in versions 7-12. There is no need to build them into the framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants