Awesome video im just starting in JOBS system! Few fixes i can potentially see: 1. you dont need to do complex math to get the direction angle to the player you can just do lookRotation = Quaternion.LookRotation(Vector3.forward, direction); direction being the positions substracted normalized, that saves math calculations in all 15000 units. 2. There is no need for IsDone since awake always happens first than any update. 3. TransformAccessArray should be Disposed on OnDestroy ideally. 4. Also there is no need to create a _enemyTransforms, you can just _accessArray.Add() every enemy once its instantiated. Hope this tips help a little bit. Thanks!
@Noixelfer2 ай бұрын
Also, you can calculate the distance first and use it to get the normalized vector a bit more efficient (by dividing PlayerPos - transform.position to the distance). And considering that most of the enemies will be outside the given range, you can do an early exit by comparing the square magnitude towards the enemy and only rotate the enemies that are far away.
@naolshow7 ай бұрын
The overhead at the end is not from job side, you are not disposing the rotation native array. And also you should not allocate and dispose the arrays each time since you are using the Persistent allocator, so either keep their reference by creating them at awake and disposing them in on destroy or simply allocate them and dispose them in update with a temporary allocator.
@RobLang7 ай бұрын
Really cool overview. Really appreciated the look at 15,000 individual jobs because I think the overhead would catch many out!
@majin29097 ай бұрын
I know you since 1k subs, I am glad u didn't gave up and are that far on youtube, hope you are making a good living now, at least good enough to survive
@b5fan5047 ай бұрын
A good video. I suspect some people may benefit from clarity that, essentially, every time you say 'thread' you could say 'core'. That's what you're allowing here; to spread more work across more CPU cores. I also like that you touched on their being no free lunch; it comes with its own overhead as everything does.
@bcreusot5 ай бұрын
Side note on performance improvement, (the rotation not being disposed and persistant have already been addressed). You should swap using Distance for DistanceSquared (ie : comparing the squared distance instead of the normal distance). The normal distance, include a squareRoot in its calculus which is def more costly that squaring the constant you are comparing it to.
@OIndieGabo7 ай бұрын
Just to add my take on "why 2 libraries for Jobs exist" and also why we keep seeing libraries (namespaces) with the same name. I am not sure if this is exactly the case but the JOBS library is an isolated solution. It might not necesserally been written to work solely for the UnityEngine. It is a solution on multithreading in a specific scenario. So you have the solution "Unity/Jobs" (using slashs so youtube does not mistake it with a link). It contains everything to make Jobs work. And then you need an implematation that actually takes advantage of that system and applies its usage in the way it needs to its own solution. That's why you have the "UnityEngine/Jobs". It is basically the UnityEngine having an implementation on how to use the Jobs library, wich happens to be made by Unity (the company).
@magnusm43 ай бұрын
I love JOBS and the GPU based VFX Graph along with burst compiler and such cause it's both an optimization but also a fun and rewarding challenge to learn while making a game. But the best is what you show in the beginning. Lots of stuff. You can make a simple 2D or 3D game but the scale of your particle effects and size can be impressive and still performant. It also makes smaller projects much easier to not get stuck on optimizing and less punishing for it.
@TheKr0ckeR22 күн бұрын
Great tutorial about Job system! I have a little unrelated question. How is the batch count is very small? Do you use GPU Instancing or smth like SRP batcher? If so, There is almost 14K saved by batching, what doest it affect? I'm pretty sure there is some trade-off on that, whats happening on saved batches? I mean even if we have 25 batch, Im not sure what happens to the saved batchings, more load on GPU?
@bitgridgames7 ай бұрын
Okay.. Im going to give this another shot. I need to start showing viewers how to make cool games and get more viewers. tough. Great video man
@muspuxx68662 ай бұрын
Why, at the end of the video proving it's ineffective, do you use an array but only utilize one element?
@TheArghnono7 ай бұрын
Excellent tutorial!
@Dragoncro0wn7 ай бұрын
Is it a bad idea to make the thread function like an update loop? Always running in the background doing its own tasks
@HumanityAsCode5 ай бұрын
You would probably run into a race condition doing that
@HumanityAsCode5 ай бұрын
Isn't this ECS with more steps? If you're operating on a list of 'entities' as it were why not skip the job and go full ECS
@k-63536 ай бұрын
Hi, I've seen JOB system when I started using Unity but i thought it was way too advance for me (i still do). All in all, Does this mean i cant implement JOB system into AI bots? or is there another way to optimize? Currently, I reach 20fps after spawning nearly 100 AI bots, equipped with Movement(patrol, chase many more), Combat etc. I get 15 fps with 350+ bots with their main AI script disabled. Would be greatly helpful if someone could lead me into a direction
@danielwertz87247 ай бұрын
Im a godot developer but love your videos. Feel like i still got a little out of it. Helps that I use c# in my day job and use threading frequently. Thanks for the vid!
@redragon12297 ай бұрын
Cool video. I want to point out that although the ~x2 boost in your example does not look that impressive, actually, excluding rendering and other processes, Jobs can be HUNDREDS of times faster than the same single-threaded calculations. In this example the difference is not so significant because, I think, most of the performance hit is the rendering. Also, as @naolshow pointed out: this can be further optimized.
@AliHosseiniDev7 ай бұрын
Oh boi that was a nice explanation.
@dawid6211Ай бұрын
As far as i know, it is a bad practice to call Schedule() and Complete() on the same frame
@rrainix6 ай бұрын
How are you instaniating 15 thousand enemies so fast?
@lightbug61034 ай бұрын
Why are you using that _isDone flag? Regarding the MonoBehaviour code, there are small things that can be changed in order to improve performance: 1. Using a list of enemy transforms instead of GOs, so you don't need to access the transform for the 50k enemies. 2. Grabbing the player's position before entering the loop instead of calling "_playerTransform.position" every time. 3. Using Tansform's "SetPositionAndRotation" instead of ".position" and ".rotation". 4. The following operation "direction * dt * moveSpeed" can be rearranged to improve performance like this: "dt * moveSpeed * direction" or just "direction * (dt * moveSpeed)" 5. I know Time.deltaTime is not a big deal, but I usually cache that as well. I'm not saying this is gonna beat Jobs, but it could make a difference nonetheless.
@user-uk9er5vw4c6 ай бұрын
nice content, thanks!
@privatdetektivenkant59757 ай бұрын
Give me more!!!!!
@PhiLudo7 ай бұрын
cool stuff
@정동우-n2x7 ай бұрын
I love it
@Coco-gg5vp7 ай бұрын
First
@GostGostcic7 ай бұрын
this video is so bad, he could make this code 10x faster with jobs but he made so many mistakes in the video lol
@OIndieGabo7 ай бұрын
This comment means nothing if you are not pointing out how the solution would actually be improved. There is no harm on pointing mistakes out and explaining them so everybody can grow on it. What you did here is just offensive. And if this is was your intention it becomes clear why we should not listen to what you are saying and just ignore you in the future.
@GostGostcic7 ай бұрын
@@OIndieGabo [ReadOnly] works only on native containers not the normal variables, boid Transforms should have null parent (this is extremely important) and updated only with TransformAccess.SetLocalPositionAndRotation(...), then he should show profiler because this is not the bottleneck (because can handle 100k+ updates per frame easily), he is doing something else wrong. i could go on... but the point is, dont watch this, he is missing the point of the JOBS and what they do.
@ehabelbwab17836 ай бұрын
@@OIndieGabo Agree
@urirat375021 күн бұрын
How? im learning job system but if you just comment without pointing out the solution it means nothing.
@GostGostcic21 күн бұрын
@@urirat3750 i cant fucking teach you in a youtube comment. i would advise you dont just copy paste code. TEST IT out, see how fast it is and WHAT makes it fast. definitely learn to look at generated assembly code, you have tools (viewer) for that in Unity already.
@frankrenzulli43546 ай бұрын
I CAN'T FKING HEAR YOU, TURN UP YOUR VOICE PLS :(((((