MULTI-THREADING on ROBLOX?!

Поділитися
Вставка
  • Опубліковано 23 лис 2024

КОМЕНТАРІ • 93

  • @Infinitelucidmaze
    @Infinitelucidmaze 8 місяців тому +14

    This taught me more about debugging which is really good to know if you're an advance scripter

  • @ipadgeek05
    @ipadgeek05 9 місяців тому +43

    Something I recommend is not multi-threading everything. I spoke to someone and they said don’t multi-thread it can make lower-end devices crash quite often.

    • @BockyDuh
      @BockyDuh 9 місяців тому +5

      thats cause older cpus lack propper mutithreading capability. so it cam cause crashes.

    • @ipadgeek05
      @ipadgeek05 9 місяців тому +6

      @@BockyDuh yeah, lower-end devices as i said. CPU's are interesting though. they execute code differently.

    • @BockyDuh
      @BockyDuh 9 місяців тому +1

      @@ipadgeek05 yeah. Mostly
      its older arcatechture cpus.

    • @alexanderdouble
      @alexanderdouble 5 місяців тому +12

      WE DON'T GIVE A DAMN ABOUT PEASANTS ❌🚫⛔

    • @Te.le.
      @Te.le. 5 місяців тому +4

      No just dont muiltithread in general. Roblox is serialized for stability. If a chunk of data is access twice over from multiple threads of scripts and one decided to modify it. It causes data racing which can take out all the scripts running on the effective data chunk. Its MUCH safer to run on roblox's serial execution. This WILL happen on any device.

  • @synkka1221
    @synkka1221 9 місяців тому +27

    will definitely be using this for my mesh deformation ocean so thanks! I've been trying to optimize it as much as I could for months and knew I should've been using this but it seemed so daunting. It'll be a pain to implement considering all the large module scripts associated with my system but now i have some motivation at least lol

  • @acelaox6836
    @acelaox6836 9 місяців тому +18

    next it's gonna be cuquantum in luau

  • @uncommonsaucers2355
    @uncommonsaucers2355 9 місяців тому +5

    Thanks a lot! I'm now going to run millions of square root calculations on the local player when they're fighting in PVP to make them break their computer when they lose.
    Seriously though. This was useful.

  • @Krysiuba1
    @Krysiuba1 9 місяців тому +8

    omfg your explanation is so good, i understood everything from this, thank you

  • @JoshTheKneeSnatcher
    @JoshTheKneeSnatcher 9 місяців тому +1

    Thank you man, I made collision detection with spherecasting and the somehow my game was lagging. This definitely helps with what I was going for

  • @Illumina1414
    @Illumina1414 9 місяців тому +8

    This is really perfect for my project. I'm making an RPG with Dark Souls inspired enemy AI who make many different decisions based on many different math calculations. I was worried having possibly hundreds of complex AI might cause performance issues like Deepwoken has, however with this I'll be able to optimise my game efficiently. Really nice video, I have instantly liked and subscribed.

    • @justsomeguy8597
      @justsomeguy8597 9 місяців тому +1

      goodluck with your project!

    • @Tobi-hs9pt
      @Tobi-hs9pt Місяць тому

      For me, I thought Deepwoken had amazing performance.

    • @Illumina1414
      @Illumina1414 Місяць тому

      @@Tobi-hs9pt I think the poor latency issues made the performance seem worse than it is. The devs seem to blame it on the NPCs.

  • @Czectly
    @Czectly 9 місяців тому +2

    Thank you i was really curious about this and i think it's a very interesting concept within lua their is actually alot more then i thought to it

  • @ItsSpaceManPlays
    @ItsSpaceManPlays 5 місяців тому +1

    This is an absolutely great video you explained it so well i bet even a new scripter could understand it

  • @fabiandidiercobobitriago
    @fabiandidiercobobitriago 8 місяців тому +1

    Excellent video, thank you! I've only seen 2 of your videos and I bought your Udemy course, I'm sure it's worth it.

  • @nin9578
    @nin9578 9 місяців тому +1

    You should make a video on editable meshes and images

  • @MiniSodaDev
    @MiniSodaDev 9 місяців тому +1

    This is going to help so much, thank you.

  • @honkhonk8009
    @honkhonk8009 6 місяців тому

    Making a Helldivers type game for fun.
    I was thinking of using this to manage the NPC's but so far the tasks getting desynched is too much a pain to deal with lmfao.

  • @ЮраСуворов-у8ф
    @ЮраСуворов-у8ф 9 місяців тому +1

    Thank you for this tutorial im can optimize my game! 👍

  • @SlightlySchizophrenic
    @SlightlySchizophrenic 8 місяців тому

    No way this bro made a deer tornado while tryna explain parallel executing and task desynchronization

  • @mewristem
    @mewristem 9 місяців тому +1

    Very helpful and perfect tysm!

  • @Nykomil
    @Nykomil 9 місяців тому

    And I still get ~20fps average while before I had 60. damn you developers!!

  • @skyblox-eo5se
    @skyblox-eo5se 10 днів тому

    hi . If i use a modular approach in scripting where there is only one local/script ad many modules , how do i use parallel luau?

  • @MarkoBrainz
    @MarkoBrainz 6 місяців тому +1

    Quick question! At 11:25 you made 3 connections and created a profile for each process, in order it has the numbers "1", "2" and "3". But in the profiler it says "3", "2", "1". So it's in order.. but reversed. I don't quite understand why though?

    • @crusherfire1
      @crusherfire1  6 місяців тому +1

      Good eye! While I'm not exactly sure the reasoning behind why this happens, this same pattern exists with regular connections as well. It must be some kind of internal thing relating to task scheduling.

    • @mahmoudayman6423
      @mahmoudayman6423 11 днів тому +1

      ​​@@crusherfire1It might have to do with the deferring of the connections. They follow a rule where it is.. "first in, last out", so the last connection (heartbeat 3) is executed first
      Edit: That means, the first connection will be executed last, while the latest connections will be executed first
      I guess this is the case with deferring functions

  • @macjoeplays
    @macjoeplays 9 місяців тому

    😌 Amazing video. Why not Roblox Engine set their defaults from Serial to Parallel so there is no need to make some extras for parallel computing. Like just calling some function then wallah, the scripts are now set to parallel or Roblox Engine can automatically assign task computations for each available worker of the CPU 🤔then Player and Game Dev will surprise that the game is now optimize by 1million times

    • @lordnazzer
      @lordnazzer 7 місяців тому

      It will crash low end devices if things are parallel by default.

  • @edgyman519
    @edgyman519 5 місяців тому

    AWESOME dude

  • @justsomeguy8597
    @justsomeguy8597 9 місяців тому

    thank you

  • @YellowPeace
    @YellowPeace 3 місяці тому

    If I had a class with some method like;
    local Entity = {}
    --more class stuff
    Entity:Pathfind()
    How Would I use multithreading, since even if I have 100 entities, they all use the same pathfind function???
    If anybody could help me with this, it would be greatly appreciated!

  • @Fellthrogures
    @Fellthrogures 19 днів тому

    The one thing TSB doesnt have

  • @SudoSed
    @SudoSed 9 місяців тому

    Hello, I am taking the course called Roblox studio on the Udemy platform. However, the course currently does not have a Turkish subtitle option. I have a request to add Turkish subtitles. Help me in this matter.

    • @crusherfire1
      @crusherfire1  9 місяців тому +1

      Udemy only offers a couple automatic subtitles, so I have to manually translate and add subtitles to Turkish which may take me a bit of time.
      I'll try to add them ASAP

    • @SudoSed
      @SudoSed 9 місяців тому

      @@crusherfire1 Thank you very much! I wish you good work!

  • @CurINC
    @CurINC 2 місяці тому

    nice video! (i have not watched yet)

  • @decat4
    @decat4 9 місяців тому +1

    (what i said is wrong read replies if anyone else comes by this)
    one thing you shouldve mentioned is task.spawn, this does one thing similar to actors and runs the code in parallel, so you don't need to make a script in a separate actor for everything, you can just use task.spawn to run multiple npcs in paralell for example.
    thanks so much for this video though, this will help a lot, a question though, are there limits to what can be given a profile label? for example i tried to label a while loop inside of a function but i've yet to see it anywhere despite it triggerring most of the functions of my NPCs

    • @crusherfire1
      @crusherfire1  9 місяців тому +3

      I'm sorry, but that is incorrect. The task library, like task.defer() and task.spawn() execute functions in a new coroutine thread, not a processor thread. I mentioned that coroutine threads are not the same as processor threads.
      Coroutines still execute in serial, except, they can have their flow manipulated using yield functions like coroutine.yield(). Only 1 coroutine executes at a time. So, no, task.spawn() does not run code in parallel.

    • @decat4
      @decat4 9 місяців тому

      @@crusherfire1 dang i misread the profiler then, so is it possibile to run multiple loops within the same code in paralell or is that done with task.desynchronize?

    • @crusherfire1
      @crusherfire1  9 місяців тому +2

      @@decat4 In order for code to be executed in a separate thread, the script where the code is executing has to be within an actor.
      If you have two while loops in the same script and both running in parallel, they will still be executing one after the other because they are inside of the same script in the same actor (executing on the same thread). However, those two while loops will also be separate from the current thread executing in a different thread.
      If those while loops are split into two separate scripts under two separate actors, then the two while loops will be executing in separate threads at the same time.
      Making a script a child of an actor doesn't make the code automatically run in parallel. You must define where using task.desynchronize() to run in parallel and using task.synchronize() to run in serial.
      Or you can also use :ConnectParallel() on events which automatically runs the connected callback in parallel without needing to call task.desynchronize()

    • @decat4
      @decat4 9 місяців тому

      @@crusherfire1 huge thank you for the explanation,

  • @cracktusdev
    @cracktusdev 9 місяців тому

    NICE VIDEO MAN!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @Sanchayan_Mallick
    @Sanchayan_Mallick 7 місяців тому +1

    What font did you use in the video? I want to use it for studio.

  • @kokobroxd
    @kokobroxd 6 місяців тому

    the graph doesnt show up for me

  • @Kitsune_Dev
    @Kitsune_Dev 9 місяців тому

    What about Serial killers and Parallel killers?

    • @thisisaperson1536
      @thisisaperson1536 9 місяців тому +1

      uhhh
      serial killers kill one by one and parallel killers kill many at once or something
      parallel killers are scarier man, remember to pray

  • @osanixian1499
    @osanixian1499 9 місяців тому

    This is a great tutorial, I just have one question. It seems that parallel luau can only parallelize scripts, not any function in that script. This is a problem as I have a script that (hilariously) does need to iterate over a table 1 million times. Due to my array being separated into chunks, I would love to use parallel lua to run all the chunks in parallel, hopefully increasing performance. But it seems this is not possible as this only takes place inside one script. Also what happens if you try to run in parallel more scripts than there are workers?

    • @crusherfire1
      @crusherfire1  9 місяців тому

      Yes, you would have to figure out a way to separate your code into multiple scripts, as you need multiple actors to split into separate threads.
      In the case you have more actors than threads, the workload is distributed across all threads (like the deer in the video). Roblox recommends splitting long computations into separate scripts, as the granularity allows for more even distribution of tasks among threads.

    • @osanixian1499
      @osanixian1499 9 місяців тому

      ​@@crusherfire1 Is it possible to process in parallel using remote functions? Using remote functions would simplify spreading the data around and ease collection of it, though invoking a new actor might be a struggle.

    • @crusherfire1
      @crusherfire1  9 місяців тому

      @@osanixian1499
      The properties for remote functions and bindable functions aren't labeled with a safety label, so I'm gonna say no?
      Of course, you can easily just set up a test and see if you're able to use to it in parallel. If it errors, then you've got your answer.
      I'm not sure why you would need to use a remote function/bindable function? If you need to share data between actors, use a bindable event, you can use the Actor messaging system, and there is even a data type called SharedTable that was made specifically for use in Parallel Luau, and you can store them in a shared registry.
      create.roblox.com/docs/reference/engine/datatypes/SharedTable

  • @stavros222
    @stavros222 9 місяців тому

    "Luau" ok. Lets not talk about who thought of this name

  • @j_ray01
    @j_ray01 8 місяців тому

    youre so cool

  • @chan3_.
    @chan3_. 9 місяців тому

    guy went from being russian to a coder 💀

  • @ExoticFoxy
    @ExoticFoxy 9 місяців тому

    Parrarel me amu???

  • @elainecristina6215
    @elainecristina6215 9 місяців тому

    multi

  • @VangelTheDarkSide
    @VangelTheDarkSide 7 днів тому

    25:11

  • @the_chosen_one1235
    @the_chosen_one1235 9 місяців тому +1

    ViewportFrame tutorial or else...

    • @crusherfire1
      @crusherfire1  9 місяців тому

      or else what 🤔

    • @thisisaperson1536
      @thisisaperson1536 9 місяців тому

      set viewportframe's current camera property to a camera (any camera)
      it will now render parts and models *parented to the viewportframe*, if ViewportFrame.CurrentCamera can see it.
      it won't look high quality but there's no good way to fix that so lol

    • @the_chosen_one1235
      @the_chosen_one1235 9 місяців тому

      buddy im pretty sure most people know that but its the camera positioning that gets most people@@thisisaperson1536

  • @letter-a
    @letter-a 9 місяців тому

    a

  • @SPDM_Riky47
    @SPDM_Riky47 8 місяців тому

    So, how do i achive something like task.spawn that uses actual different threads

  • @idoscripts
    @idoscripts 9 місяців тому

    do u have a discord?

    • @crusherfire1
      @crusherfire1  9 місяців тому +1

      I do, but it's not public

    • @idoscripts
      @idoscripts 9 місяців тому

      @@crusherfire1Are you talking about discord server or personal account

    • @crusherfire1
      @crusherfire1  9 місяців тому +1

      ​@@idoscripts I have a server, but it's private (reserved for my students).

    • @idoscripts
      @idoscripts 9 місяців тому

      @@crusherfire1 How do I become a student?

    • @idoscripts
      @idoscripts 9 місяців тому

      Never mind, figured it out. Is there any chance I could get a fan discount?

  • @tal5667
    @tal5667 8 місяців тому

    I did
    ```for i = 1, math.huge do
    --blah blah the coede math.sqeurit
    end```
    it's vame crs game crashed

    • @tal5667
      @tal5667 8 місяців тому

      nvm it loaded