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 /
avatar image
2
Question by JohanHoltby · Feb 17, 2013 at 08:46 PM · optimizationprofilerlagsspikes

Why do I have sporadic spikes in the profiler?

Hi! I have a problem with peaks in the profiler of my procedural generated World CPU and GPU. It's a lot of different code pieces witch spikes but some in particular. I show some screenshots below.

The game consist of about 4000 chunks all as separate game objects under a map game object which are loaded in using state machines and a threadpool.

Previous I did have a periodical spikes about every 20 - 30 frame by RenderTexture.SetActive. I did restart the editor and it's all gone now and I can not reproduce but will still mention it so you know.

Each screenshots represent one of the problematic spike types(from that code pice). I did previously also have problem with garbage collect but since i did start to reuse chunks that problem is gone.

The start function for Chunk looks as follows:

 // Use this for initialization
     void Start () {
         _dirty=true;
         materialList= chunkGrid.GetMaterialList();//(MaterialList)GameObject.Find("materialList").GetComponent("MaterialList");
         
         if(meshData ==null){
             meshData = new MeshData(materialList.materialList.Count);
         }
         if(meshNoneCollideData==null){
             meshNoneCollideData = new MeshData(materialList.materialList.Count);
         }
         
     }

alt text

alt text

alt text

alt text

alt text

alt text

EDIT: I did get the error described above again after some work time in the editor! alt text

Best regards /Johan

Comment
Add comment · Show 7
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 Paulo-Henrique025 · Feb 17, 2013 at 09:35 PM 0
Share

Try posting this question on the forum also, as it deserves attention and discussion.

avatar image JohanHoltby · Feb 17, 2013 at 10:21 PM 1
Share

The post is now also in the forum and is redirected to this thread.

avatar image JohanHoltby · Feb 18, 2013 at 12:17 AM 0
Share

I did dig in even deeper in the Chunk.start() code and did find that all of the process power is consumed by self of one object. How strange since it's almost no work to do. alt text

avatar image Benproductions1 · Feb 18, 2013 at 03:10 AM 0
Share

Bump, this needs attention

avatar image JohanHoltby · Feb 23, 2013 at 12:01 PM 0
Share

I have boiled it down to this code.

 using UnityEngine;
 using System.Collections;
 using System.Threading;
 
 public class Spikes : $$anonymous$$onoBehaviour {
     private $$anonymous$$eshFilter _filter;
     private bool _threadDone = true;
     private bool firstTime=true;
     // Use this for initialization
     void Start () {
         
     }
     
     
     
     // Update is called once per frame
     void Update () {
         if(firstTime){
             firstTime=false;
             _filter = GetComponent<$$anonymous$$eshFilter>();
         }
         
         if(_threadDone){
             Profiler.BeginSample("Update1");
             Vector3[] vertices=_filter.shared$$anonymous$$esh.vertices;
             Profiler.EndSample();
             Profiler.BeginSample("Update2");
             _threadDone=false;
             Profiler.EndSample();
             Profiler.BeginSample("Update3");
             ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), vertices);
             //ThreadPool.QueueUserWorkItem(DoWork, vertices);
             Profiler.EndSample();
         }
     }
     
     private void DoWork(object o){
         Vector3 sum = new Vector3();
         for (int i = 0; i<1000;i++){
             foreach( Vector3 v in (Vector3[])o){
                 sum = v+sum;
             }
         }
         _threadDone= true;
     }
 }
 

Add it to a capsule and duplicate the capsule 3 times so you have a total of 4 capsules and the spikes will appear. I have a quad core. Any Ideas? / Johan

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

12 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

Related Questions

Spikes for Render.Prepare 1 Answer

large sudden profiler spike 0 Answers

Garbage Collection (StackTraceUtility) - Profiler Spikes 1 Answer

What is "mesh count"? 0 Answers

Physics.Simulate taking a long time 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