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

Multithreading #8

Open
magicaldave opened this issue Jul 3, 2023 · 4 comments
Open

Multithreading #8

magicaldave opened this issue Jul 3, 2023 · 4 comments

Comments

@magicaldave
Copy link
Member

A previous version of tes3mp includes an async branch which may be of interest to @YvanCywan , some additional details on the use case for multithreading could be useful as well.

Server load is generally pretty light so I'd like to understand why this work was done to begin with and whether it's truly beneficial.

https://github.com/uramer/CoreScripts

@YvanCywan
Copy link
Member

Urm's CoreScripts is not the official, it implements async through Lua's coroutines, which is a completely viable solution that we could use.

@YvanCywan
Copy link
Member

YvanCywan commented Jul 26, 2023

I've performed some research, looking into how FiveM and Uramer handles coroutines.

We need a simple wrapped for creating threads, a scheduler (automated execution and resumption of coroutines) and a set of timers. We would usually be able to do this with the "effil" Lua package, but it does not seem to want to build on my system. However, this feature for asynchronous code will take a while. It will also require exhaustive testing.

I suggest we break this down into 3 or 4 smaller issues.

@SaintMercury
Copy link

I think I had issues building effil on newer versions of msvc, though, I was fairly naive at the time. I could try again and possibly track the issue and hopefully get a build/release for it for us to personally use.

Effil was pretty promising when I looked at it, and fairly simple. It also depends on how the threading model would work.

I present that we do somethink like a job scheduler where you pass a function that accepts an argument of tes3mp object o puill and send whatever data you need.

ScheduleTask(function (tes3mp)
   tes3mp.LogMessage(1, "Executed Task")
end)

We'd probably need something for triggering event handlers too obvs, but this was my theory on getting it to work when I experimented with it.

@SaintMercury
Copy link

I'd also like to add that async =/= concurrent =/ parallel.

Async might get some benefit, but it does require writing scripts to somewhat aggressively use yield, where as parallelism we can probably try to keep most scripting still just basic-ish lua.

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

3 participants