It is a common occurrence for developers to see WaitForJobGroupId in the profiler when running a JobComponentSystem-heavy game. This is usually worth it though since they also end up seeing a lot of blue in the worker threads. However, sometimes the worker threads are overburdened while the main thread has finished its job and is waiting for them to complete. This necessitates the need to offload work to the main thread.
Say my development process is to implement the physics and heavy lifting first. As a result nearly all the JobComponentSystems needed for the game are in place, and the profiler has a lot of blue in the worker threads and a lot of grey in the main thread. In this case would it be a good idea to code the rest of the non CPU-intensive game mechanics in ComponentSystems?
If the jobs aren’t being allocated when main thread is idle then that is a bug with the scheduler and you should post a reproducible bug report.
You should never use ComponentSystem over JobComponentSystem unless you have to do work that requires the main thread. Ideally you’d have 0 ComponentSystems in your application, though this is obviously not always feasible at least at the moment.
Ah I didn’t explain it that well. My scenario is when there are so much work done in JobComponentSystems that even after the main thread has finished scheduling all the jobs, it still has to wait for them to complete.
I think your explanation was fine and tertle’s response relevant. Read the linked thread or the thread linked at the end of the thread. It’s the same issue isn’t it? “main thread schedules lots of work then ends up waiting idle for it to complete, I’d like it to help in completing the scheduled jobs”. Same as your situation isn’t it?
Yes if you follow the link I posted and go to the similar topic you’ll see the result of improvements to the scheduler that are coming to reduce the main thread being idle.
If after the update is available you still have similar issues, make another reproducible bug report because the intended behavior is work is scheduled on main thread if it’s idle.
Ah, so the scheduler has improved to the point that it can schedule work to the main thread if all the other worker threads are busy and the main thread is idle?
According to Using ComponentSystem | Package Manager UI website one must consider if “the amount of work the system performs is less than the small overhead of creating and scheduling a Job”. Some of my systems activate only a few times per second to process a single entity each. Although you’re right in accounting for future scalability, I’m certain that my system will never reach that level of scale (hundreds of entities dozens of times per second). What are your thoughts?
If it costs more to schedule the job than it does to do the work with burst, don’t schedule the job. Only you can measure it to know what’s appropriate though.