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
0
Question by JaredThomson · Nov 24, 2014 at 09:53 PM · physicsoptimizationprofilerunity 4.6

Unity deep profiling is drunk, I think

Hey all,

I'm trying to remove all my performance hiccups in my game right now so I've started my 30 day trial of Unity pro and am using the profiler. The results I've gotten have helped me get my average frame rate up by a huge amount, pointing me in the direction of some naughty things I've forgot that I did in code. However the 'hiccups' are entirely still there and the results I'm getting don't make sense to me.

alt text alt text

I can only upload two images for this question, but here are some imgur links if you want to see each of the non-repeating hiccups:

Physics.UpdateSkinnedCloth

Wait for target FPS

Physics.Simulate

GameView.GetMainGameViewRenderRect

I also made a video, but I'm not sure how useful that will be.

Youtube Video

Just by scrubbing through in the profiler, I see on most frames both my CPU and GPU times are below 4ms put together, but once in a while I spike at about 100-200ms on some random function I'm not calling. I've played through dozens of times and I get seemingly random internal unity calls popping up at about the same pace (about once per second).

For instance: I have zero cloth simulation in my game and Physics.UpdateSkinnedCloth pops up sometimes?

Any ideas on what this could be or what I can do? I can post code for you guys but I'm not sure how much help it will be since nothing is pointing directly to an area of code.

Edit 1

I've made my repo public in case looking at source helps: https://github.com/xoorath/Farlands

Some of the bigger scripts that are running on update or fixed update include:

Assets/First Person Drifter Controller/Scripts/FirstPersonDrifter.cs

Assets/gameplay/ChunkManager.cs

Assets/graphics/world/ChunkRenderer.cs

The main scene in the root of assets is pretty plain.

Thanks!

2014-11-24_16-30-26.png (112.8 kB)
2014-11-24_16-32-24.png (114.3 kB)
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 meat5000 ♦ · Nov 24, 2014 at 10:08 PM 0
Share

Got a character with a cape? It got a rigidbody?

If you don't require it, search for the SkinnedCloth component alongside the Skinned $$anonymous$$esh Renderer and if you find one, delete it.

avatar image JaredThomson · Nov 24, 2014 at 10:12 PM 0
Share

Nope, I've got a character with no mesh. It has a Character Controller component, and I've got a bunch of mesh collides in my scene (18 total, lots of verts - 73,000 verts total in the scene). No other physics entities.

Edit: if you're curious I can make my github repo public until solved. It's a pretty small code base, all things considered.

avatar image meat5000 ♦ · Nov 25, 2014 at 12:08 AM 0
Share

Sounds like a plan.

avatar image JaredThomson · Nov 25, 2014 at 02:09 AM 0
Share

@meat5000 I've updated with the repo url and a brief layout of assets.

avatar image meat5000 ♦ · Nov 25, 2014 at 12:46 PM 0
Share

Crashes my editor

BlockSelectItem.prefab and the $$anonymous$$ain scene file.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by JaredThomson · Nov 25, 2014 at 01:40 PM

I should have known... inexplicable weird stuff happening == threading issue.

I create 9 background threads for each voxel chunk in my game and they allocate and assign block values to a big matrix of cubes. Once done it calls back to the main unity thread where all the chunks are then sewn together for a big blob like linked list.

Anyways, the issue is that even though my threads weren't working on anything they were still running in the background - and since I'm a threading noob I probably forgot to do something important and/or messed something up pretty bad where my loop inside the thread was doing something bad.

@baste sort of tipped me off into the right direction by asking:

do you have a singlethreaded environment?

Which of course in my case is no. If anyone reads this and knows a good resource for safely calling back to the unity thread once done working in a background thread, that would be pretty great. I'll leave my repo open source for a while in case anyone wants to peak. The culprit file is:

ChunkRenderer_Worker.cs

And the fixing commit is:

Fixing the huge lag spikes caused by threadding.

^ note for future readers, these links may be unavailable. I do not intend to keep my project open source forever. The summary is that I had flipped a bool to false that I was using to keep the thread alive like if(alive){/*run thread*/} even though the body of that thread loop was doing nothing interesting, it was the culprit.

victory

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

28 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

Related Questions

Physics.simulate chews CPU but not using physics at all - Am I? 2 Answers

Unity Profiler - Physics optimization (FPS drop) 0 Answers

Physics.Simulate taking a long time 1 Answer

Physics Optimization. 0 Answers

Character Controller 2D physics or raycast ?? 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