generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: True Lua Multi-threading

Previous Thread :: Next Thread 
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
20 Dec 2011 03:30 PM
Is there a way to do actual multi-threading with Lua? Probably using something like the debug library?
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
20 Dec 2011 03:33 PM
Lua Lanes, gewgl it
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
20 Dec 2011 03:40 PM
Ooh cool :D (*cough* ROBLOX should use it *cough*)
Report Abuse
Varp is not online. Varp
Joined: 18 Nov 2009
Total Posts: 5333
20 Dec 2011 04:39 PM
"(*cough* ROBLOX should use it *cough*)"

Please complete the following sentence:

"Concurrent multithreading in Lua enables programers to __________ and is therefore worth the cost of introducing bugs and increasing the difficulty of learning the language."
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
20 Dec 2011 04:40 PM
First a question: Whats a programer??
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
20 Dec 2011 04:43 PM
"Concurrent multithreading in Lua enables programers to run multiple pieces of code at the same time and is therefore worth the cost of introducing bugs and increasing the difficulty of learning the language."
I see your point.
Report Abuse
LocalChum is not online. LocalChum
Joined: 04 Mar 2011
Total Posts: 6906
20 Dec 2011 04:43 PM
@aboy

Win. Just win.
Report Abuse
Varp is not online. Varp
Joined: 18 Nov 2009
Total Posts: 5333
20 Dec 2011 04:44 PM
"First a question: Whats a programer??"

It's a typo. It's very much less important than the rest of the post. Also, if you must ask me about grammar, maybe you should consider using apostrophes.
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
20 Dec 2011 04:46 PM
grammar ~= spelling
Report Abuse
Varp is not online. Varp
Joined: 18 Nov 2009
Total Posts: 5333
20 Dec 2011 04:46 PM
"Concurrent multithreading in Lua enables programmers to run multiple pieces of code at the same time and is therefore worth the cost of introducing bugs and increasing the difficulty of learning the language."

The phrase "at the same time" isn't very concise. Coroutines have a behavior that is similar to that. Why are they not adequate?
Report Abuse
aboy5643a is not online. aboy5643a
Joined: 20 Nov 2010
Total Posts: 2785
20 Dec 2011 04:47 PM
@Varp's last post

This.
Report Abuse
GeniusRobot is not online. GeniusRobot
Joined: 14 Oct 2011
Total Posts: 194
20 Dec 2011 04:51 PM
@Varp: Aboy5643a was just trolling.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
20 Dec 2011 04:51 PM
For the most part they are; currently I don't have any use for this sort of thing. In terms that would give you an answer, I don't really have any examples right now. If I run into a problem that could use this very well, the work-around will probably be annoying (to me, anyway) and sloppy. Normally, I don't really have a problem with those work-arounds.
Now, what is the plural of work-around??? Spell-check says that that's a word but work-arounds isn't. Stupid red squiggles.
Report Abuse
jackjgiffin is not online. jackjgiffin
Joined: 09 Jul 2012
Total Posts: 68
10 Jul 2016 05:49 PM
The roblox wiki is full of ugly little lies about how coroutines are at the same time on different threads when infact they are not. The truth is that coroutines are all on the same thread executed sequentially. The way lua coroutines work is by reordering and inserting into this sequential list of instructions to perform so as to emulate. If you are like me, and you want quick & easy proof of this, then do this (if you are running Microsoft Windows 7):
0. Close any currently opened Roblox Studio places (if you don't, then you will perform step #9 incorrectly as you will be very confused).
1. In Roblox Studio, create a new empty place.
2. Paste this into the command bar and run it (spaces don't matter).
f=function()while true do end end delay(0,f)delay(0,f)
After running that code, you will notice that it caused Roblox to freeze up. That is the purpose of the code, so DO NOT exit out of Roblox Studio if you want that set of steps to work.
3. Press Ctrl + Alt + Delete
4. Click on the 'Start Task Manager'
5. Goto the 'Performance' tab and count the number of boxes under 'CPU Usage History'. This is the number of cores your computer has (you must remember or write down this number for step 11).
6. Goto processes tab and then goto 'View' then click on 'Select Columns...'.
7. Make sure a checkmark is in the box for 'CPU Usage' and then press okay.
8. Click on the 'Applications' tab.
9. Left click on 'ROBLOX Studio' and then click 'Go To Process'.
10. Goto 'View' then click on 'Refresh Now'.
11. Now, observe the number at the CPU column of the highlighted row in the Task Manager. If it reads 100 (because it is a percentage) divided by the number of CPU cores your computer has (from step #5) then Roblox Studio is not multithreaded because only one physical core is used, but 2 roblox 'threads' were created which means that Roblox's threading system is emulated. But, if it reads 200 (2 times 100 because percent) divided by the number of CPU cores your computer has (from step #5) then that means that roblox is multi-threaded because 2 roblox 'threads' were created, and those threads are executing in parallel instead of sequentially, so Roblox's threading system is not emulated, rather it is the far faster hardware.

Why doesn't roblox currently support multithreading? It is because they don't tap into the c++ multithreading api. It may seem like a difficult task to tap into the c++ multithreading api, but actually (based on my fair knowledge of c++), they will (provided that their thread-emulating is not way over complicated) only have to add a few lines of code into the roblox thread-emulator so that lua code can be synchronously executed on different cores of the computer.

My educated guess regarding server-side multithreading which might be Roblox's reason for not implementing it is because Roblox probably has their servers setup for different servers of different games to run on different cores of the games at roblox, and (I am taking an educated guess that) games with a greater number-of-servers to robux-spent-on-game-per-interval-of-time are given higher priority than games with a lesser of that ratio. If that holds true, then it is good and logical for roblox to prevent server-side multi-threading. But regarding client-side multithreading, the issue with it is that you could just create many threads and have them all running "while true do end" to dominate the CPU power of the clients PC or you could just create thousands of threads to clog up the kernal to lag out the client to the point at which they would have to forcefully turn of their computer (by holding the power button) which could corrupt (not corrupt as in infect with malware, rather corrupt as in the computer will not start properly (i.e the dreaded hellish BSOD caused by microsoft's evilness and incompetence)) their computer if a running program is i the middle of making registry changes (Examples: updating windows, maybe installing new software ). An easy fix to this would be limiting the affinity of the lua threads to all of the cores except for 1 and setting the thread's priority to the lowest, and have the threading system set up so that instead of creating new hardware threads (which could easily be abused to clog up the kernel), there would be a different hardware thread per each core (except for the unused core) that would emulate a threading system (so that users do not have so set up their own far less efficient thread-emulating system just to have 2 or more different functions run on the same physical core) per each core (which would be inefficient, but it would be essential as it prevents abuse of the multithreading) and your local script can request to be runned by a thread-emulator on that specific core.

If you (the person reading this post) are roblox staff then you will want read the next sentence. If roblox enabled client-side multithreading (with my advised security measures included) then roblox will be a lot more profitable because it will allow game developers to distribute the load of the computation of their games onto the clients computers so that instead of the client's computer barely being used while the computers at roblox are being worked to the absolute maximum (which is what is currently the case), instead game developers (such as myself) with find ways and distribute scripts (via free models) to other game developers to make the clients computers doing the hard work (which won't create annoying lag (and in some games, it will alleviate lag) for the clients so long as the creator of the system used to distribute the workload is like myself in that they are a performance caring, expert at lua programing, well-rounded in many subjects outside roblox such as encoding/decoding, and conservative) instead of the computers at roblox doing the hard work. This will earn roblox money because they wont have to buy as expensive computers for their roblox servers and users will experience less lag which will cause them to get less frustrated which will increase their desire for roblox and thus sales of robux will go up. This won't degrade the security so long as the game creator places simple quick checks in the server script synchronizing the clients. For example, I am currently working on a mining game like Epic Mining 2. The checks I could place in to prevent virtually all hacking include checking to make sure the client doesn't break blocks faster than their blocks are capable of, adding in the server executing functions on the client side through REmoteEvent and secretly adding in a check using game:GetService('RunService').Stepped to ensure the user doesn't move faster than their walkspeed, adding up the money the client has on the server side rather than on the client side, (etc.).

Finally, A topic that came up was about it adding unnecessary difficulty for beginners. Well, the solution is actually fairly evident. If multithreading were to be fully implemented, it would certainly not be just some global function. rather, it would be accessed by something like "game:GetService('ThreadScheduler')". If you think that it would not be very commonly used then think again. There would be countless uses for it. For example, it could be used for a super-precise wait function (something that roblox lacks for absolutely no reason). You could create far more sophisticated encoders and decoders to alleviate stress from the user's network (if you think that this would be impractical because you think it should be roblox's duty to do this then try going as far in depth about data compression as I did and then rethink your position), if your games limited number of specific physics updates that could happen then you could set up a sophisticated networking system between clients to decrease lag by having special numerical codes corresponding to the different physics updates, there would be an inconceivable amount less lag in games with lots of AI and at the same time the AI would have a huge amount more room for expansion. In short, the list goes on and on with the unlimited potential this would unlock.



Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
10 Jul 2016 05:55 PM
When someone posts an answer five years later. Gg.


-=[ RAP: 352,478 || DurstAuric; the narb of ROBLOX ]=-
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image