Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Klusimo · Nov 10, 2020 at 08:38 AM · performanceperformance optimizationforeachdots

How to cycle trough enormous amount of entities (DOTS)

Hello here, I have a script that generates entities around the player and then destroyes them if they are far away. More behaviours are on the way, but I cant use normal Entities.ForEach since i am working with several hundred thousands entities and that is per player and i am cycling trough them each frame!


As you could easily guess, using foreach... caused... certain effects that could be described as bellow freezing temperatures. So foreach is definitely off the list. I can lower the amount of entities, but its still too much.


So I am asking what should I use to cycle trought all these entities without freezing the device. Any other methods of increasing performance would also be appreciated. Many thanks :)

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
0

Answer by andrew-lukasik · Nov 10, 2020 at 09:41 AM

Short answer: don't.

Keep in mind that the essence of data oriented design is solving performace problems with clever data structure not clever algorithms.

In practice this means reasoning about you current task until you realize that you don't have to iterate over 5e5 entities at all. And this can be figured out in context of your specific task only.

Comment
Add comment · Show 6 · 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
avatar image Klusimo · Nov 10, 2020 at 04:01 PM 0
Share

I thought so. Any ideas/tips worth sharing? I thought about chunks (part of dots, not my chunks) but my research in that part of dots is close to zero. I´ll look, search and learn. Thanks :)

avatar image andrew-lukasik Klusimo · Nov 10, 2020 at 06:55 PM 0
Share

One option, when dealing with A LOT of entities, is to cluster them into separate worlds. It will square complexity of your program (entities exist into separate, well, worlds), which can be bad, but also will reduce cluster destruction to just world.Dispose() or destroying/moving elsewhere an array of Entity$$anonymous$$anager.GetAllEntities()

avatar image andrew-lukasik Klusimo · Nov 10, 2020 at 07:24 PM 0
Share

$$anonymous$$ake sure all the iterations are multi-threaded so retire ComponentSystem for SystemBase everywhere.

avatar image andrew-lukasik Klusimo · Nov 10, 2020 at 10:14 PM 0
Share

If your NativeList.Lenght>100k and you're calling Contains() on it >100k times - replace it with NativeHashSet

avatar image Klusimo andrew-lukasik · Nov 11, 2020 at 07:17 AM 0
Share

Thanks, ill look more into these concepts. One thing i realised is that instead of every tile (smallest part of the world) being an entity, I can make the chunk an actual entity that will keep all the data of the tiles/update them. If i would have chunk of 20x20 entities, that is already decrease of 400 times less entities. I have no idea how I didnt see any problem with per-frame iteration of 640 000 entities xD

Show more comments

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

233 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 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

GameView.GetMainGameViewTargetSize() problem 0 Answers

Profiler knurl ... 0 Answers

any physical/practical limit to number of lights in view? 0 Answers

Different pc performance problem 0 Answers

Low performance on Mobile build of 2D Platformer game. 1 Answer


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