Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by GotoFinal · Jul 21, 2019 at 01:54 PM · multithreading

ECS and job system, what is actually possible and how it works in detail?,How ECS and job system actually work? Internals & possibilities & limitations

I'm looking for some materials that would actually explain how I can utilize job systems with ECS, as every page just states that "jobs are multithreaded and safe" with no real information about how it works, why it is thread safe and limitations of it.

Ad I would want to know how I can integrate ECS with job system, can you create systems that works as a job? so multiple system can operate on components from multiple threads? If so, how is thread safety guaranteed or what needs to be done to make it safe? And if not, then how jobs can be used in typical game with ECS. Or maybe jobs are only useful for longer and more advanced operations, like transforming some data in the background and then using the result in main thread again? - so useless for typical systems.

Would be great to also read more about internals of ECS/job system, to know how actually such data is stored in memory etc.,I'm reading about ECS & jobs and after countless articles I still did not find more information than: It is safe and multithreaded because we say so. Without even explanation what can be processed in other threads etc.

So my question is how ECS and job system can work together and what are the limitations, in perfect system I would imagine that I only need to create few systems that operate on selected components and each system can run in different thread as long as they modify different components. Is anything like that possible with ECS & Jobs? If yes - how it works, how unity know what can be running next to each other and what not. If not - then what exactly is possible, can I use jobs to modify components from another thread, or this is still limited to main one? And if I can modify them, then how thread safety is guaranteed (or not)?

I'm just looking for something that would explain both systems in detail, not just "it's better and works".

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by PincerGame · Dec 09, 2020 at 09:03 AM

Hello @GotoFinal, yes you can use ECS + Job System in Unity. ECS helps you to optimize how the CPU can quickly access data from the memory because the GameObjects are converted into an entity, these entities are well structured and organized in your computer's memory and the Job system takes an advantage of parallel processing by the use of multiple cores of your processors hence it boost your game performance by a greater percentage.

Here is a sample code of how ECS and Job System works.

 [GenerateAuthoringComponent] 
 struct Velocity : IComponentData
 {
   public float4 value; 
 }
 
 class ApplyVelocitySystem : JobComponentSystem
 {
     
 
      protected override JobHandle OnUpdate(JobHandle inputDeps)
      {
        float detltatime = Time.deltaTime;
        return entities.ForEach((ref Translation translation, in Velocity velocity ) =>
        {
            translation.value+=velocity.value*Time.deltaTime;
        }).Shedule(inputDeps)
 
     }
 
 }







Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

177 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Limitations of multithreading and jobs system 1 Answer

How do I use WorldToViewportPoint() and ViewportToWorldPoint() on separate thread? 2 Answers

Job System usage on Moving Different Transform in Different Speeds 0 Answers

Monitor.Enter and Monitor.TryEnter will suspend the program when the game run for a long time. ps:version Unity5.4.3f,Use IL2cpp. 0 Answers

Seeking feedback on my ECS/Jobs design before I start investing the time to code it 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges