Page 1 of 1

Mod threads

PostPosted: Sat Dec 13, 2014 19:33
by neko259
Does minetest use one threads for all mods now or a thread per each mod?

Re: Mod threads

PostPosted: Sat Dec 13, 2014 19:34
by Krock
neko259 wrote:Does minetest use one threads for all mods now or a thread per each mod?

Lua runs on one thread - you can notice the lag when a Lua mapgen generates terrain.

Re: Mod threads

PostPosted: Sat Dec 13, 2014 19:36
by neko259
Krock wrote:
neko259 wrote:Does minetest use one threads for all mods now or a thread per each mod?

Lua runs on one thread - you can notice the lag when a Lua mapgen generates terrain.

Does anyone work to make it use more threads? I think this would greatly improve performance. Or am I wrong?

Re: Mod threads

PostPosted: Sat Dec 13, 2014 19:42
by Krock
neko259 wrote:Does anyone work to make it use more threads? I think this would greatly improve performance. Or am I wrong?

The serverlist already uses async HTTP requests to get the data.
I'm not sure if the threads could conflict each other.
You can start developing anytime.

Re: Mod threads

PostPosted: Sat Dec 13, 2014 19:44
by neko259
Krock wrote:You can start developing anytime.

I'm not very familiar with C++, and can do almost nothing for multithreading in lua. If minetest was in python or java...

Re: Mod threads

PostPosted: Sun Dec 14, 2014 11:23
by rubenwardy
In the sims 3, each object has its own thread. It works because they can request a resource and lock it.

You would need to completely redesign the modding API. It is very unlikely to happen.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 13:41
by neko259
rubenwardy wrote:In the sims 3, each object has its own thread. It works because they can request a resource and lock it.

You would need to completely redesign the modding API. It is very unlikely to happen.

Why do you have to break or change anything? The only thing that will be locked is working with the server (and the locking can be done on the server without changing mods api).
If you mean that one mod can use other mod, I can agree. But in that case, we can at least make a separate thread for all mods, not make them work in the same thread as server.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 14:04
by Linuxdirk
neko259 wrote:If minetest was in python or java...

I’m happy that it isn’t. Python is awesome and Java is …uhm … versatile … in a way. But both aren’t optimized for performance.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 14:05
by neko259
Linuxdirk wrote:
neko259 wrote:If minetest was in python or java...

I’m happy that it isn’t. Python is awesome and Java is …uhm … versatile … in a way. But both aren’t optimized for performance.

Don't judge them on the software you seen on the internet. They can be very perfomant, but you won't see good optimized java applications that are used in enterprise.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 14:26
by Linuxdirk
neko259 wrote:They can be very perfomant, but you won't see good optimized java applications that are used in enterprise.

Every good Java fanboy knows: “Java is the fastest programming language in the world, programmers just do it wrong all the time”. Same with Python fanboys (I’m sometimes one of them, but only a little *g*).

The problem is: Both languages are interpreted. Interpreted languages are always slower than compiled languages performing the same task.

I’m happy that the Minetest code is written in a compiled language for all the critical tasks. I wish mods would use Python instead of Lua but that’s not that much of a problem since Lua is pretty easy to understand.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 15:40
by neko259
Linuxdirk wrote:The problem is: Both languages are interpreted. Interpreted languages are always slower than compiled languages performing the same task.

I’m happy that the Minetest code is written in a compiled language for all the critical tasks. I wish mods would use Python instead of Lua but that’s not that much of a problem since Lua is pretty easy to understand.

This is true in words, but in real life the difference between 99.5% and 100% performance is not always seen. And interpreted languages can speed up development (even optimizations development) and make mistakes less frequent. I don't think percents of speed in some places are more important that the absense of segfaults.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 16:30
by ArguablySane
Linuxdirk wrote:I’m happy that the Minetest code is written in a compiled language for all the critical tasks. I wish mods would use Python instead of Lua but that’s not that much of a problem since Lua is pretty easy to understand.

Honestly I'd rather write mods in Java, not because I prefer the language but because it would be faster. When trying to do iteration-heavy mapgen in lua I'm always conscious of the fact that it's going to run significantly slower than native code.

Re: Mod threads

PostPosted: Sun Dec 14, 2014 16:58
by rubenwardy
Ironic how ruby is more pythonic than python. In my opinion, anyway. (As long as you use it right, of course)