Search Unity

Mysterious overhead in profile is annihilating

Discussion in 'Editor & General Support' started by djweinbaum, Mar 29, 2014.

  1. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Its taking half most of my frame, ONLY in standalone. I'm playing nearly fullscreen in editor, standing in the same location with the same settings, yet my standalone performance is much worse because of that red OVERHEAD. I found nothing about it in the docs. I read on some thread that its the the editor application, however that doesn't explain why its so much worse in standalone (if anything it should improve). My frame rate in standalone does NOT improve without the editor/profiler in the background. Anyone have any ideas?

    $MysteriousOverhead.png
     
    DylanYasen likes this.
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The amount of garbage being allocated here is jaw dropping. It should be just a small trickle from input at most. Do you still get overhead without using daikon forge?
     
  3. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I just tried deactivating all my df stuff and building. No luck. However, I didn't know this overhead was related to garbage, so I'm looking closer at scripts now.
     
  4. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    alrighty... so I made a new blank scene with a main camera and I'm at 97% overhead. I made a new project and the overhead in that one in a blank scene is 2%. There is obviously some component of unity I am not aware of. What on this earth could this thing be?
     
    Last edited: Mar 29, 2014
  5. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    So it's 97% in a blank scene in your main project, but 2% in a blank scene in a new project? Does the problem project have any plugin dll's in it? I think native dll's that make calls from the dll back into Unity show up as "Overhead" so it might be that. Maybe one of your plugins makes call backs during frame updates on the main camera, which is why it would show up even in a blank scene.
     
  6. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Well I after hours and hours and probably over 50 builds of trying different things, I've pin pointed it. It's enabling dx11 in the player settings. Enabling DX11 in a blank scene in a blank project, 98% of my frame goes to overhead (in the standalone player ONLY). The most frustrating part of all of this, is that this doesn't explain why my standalone performance is 30 fps while my editor performance is 60fps (REAL fps not the garbage statistics fps estimate, as in, the the HUDFPS script from the unity community scripts). What's more, why is overhead so high in standalone only when obviously both editor and standalone are in dx11. Even though my overhead drops from 60% to 15% when disabling dx11, my frame rate stays about the same. I'm going to keep at this, but please if anyone has any guesses it would help me greatly.
     
    Last edited: Mar 29, 2014
  7. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Still at this. I think I've gotten this extremely controlled. I made sure player and editor are the same settings, both running 1280x720, fixed camera position, I made them utterly identical in every way I know how. I run each alone, no other apps (I exit out of the editor when doing the player to be certain). I even tried running the player on a different machine with very similar specs to see if this is something about my machine or os install. The player runs just as bad on that machine.

    Bottom line: the Player gets a very steady 35 FPS, where the editor play mode gets a very steady 47. Again I'm talking about true FPS, not the prediction from the editor statistics. My statistics are showing a full 60 FPS. What's the deal!?! What variables am I missing? How can I get my standalone to perform as good as the editor (I'm willing to give up on the dream that the standalone should run BETTER, which theoretically aught to be the case).
     
  8. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    It could possibly be your graphics driver/software doing some extra work. For example on Nvidia cards in the Nvidia control panel, you can set defaults for all 3D apps and turn on things like full-screen anti-aliasing and ambient occlusion. Try changing it to the default "Let the 3D Application decide" and see if that helps. ATI has similar controls, I don't know the exact wording though.
     
  9. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Yeah I'm on AMD and it has the Catalyst control center. I've messed with the settings on there, to no avail. I'd think any setting that was making unity run slower would also effect the editor performance but perhaps not.
     
  10. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Are you running the standalone version full-screen? Sometimes graphic drivers do different things when in full screen mode than in windowed mode; that might explain the difference. I'm kind of just throwing out ideas though ;). There shouldn't be any real change in overhead just from turning on DX11, and "Overhead" usually means it's something outside of Unity's direct calls that is causing the slowdown, that's why I'm suspicious that it's a video card driver thing.
     
  11. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Kind of a long shot, but are these two systems laptops with the same card? Sometimes the power settings make it fail to recognize when a 3D app starts and they stay in low power mode. You could try going to Windows control panel -> Power Settings -> change it to "High Performance Mode", and see if that makes a difference.
     
  12. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Well, I tried windowed and fullscreen. The performance is worse than the editor in both, and both show the overhead (although it doesn't seem like the overhead is what's killing my framerate, despite it being 60% in dx11). Both machines are desktops. One with an ati 6950 and one with a 7870. I did windowed 1280x720 to match what I'm doing in the editor. I do appreciate the ideas. I'm totally at a loss of what to do. I'll try anything. I'm starting to think its a bug.
     
  13. DylanYasen

    DylanYasen

    Joined:
    Oct 9, 2013
    Posts:
    50
    it's been a while.
    Well, so how did it go?
     
  14. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I just kinda gave up on it and continued to work on my game. I'm not sure what the discrepancy between the player and the editor is now, but my performance is acceptable in both so I'm not worrying about it at the moment. My frame rate got a lot better when I gave up on static batching in preference of writing a cluster combining system.
     
  15. DylanYasen

    DylanYasen

    Joined:
    Oct 9, 2013
    Posts:
    50
    I thank you for sharing your experience.
    I just can't fully understand what's going on in Profiler.
    At the top of the list, is WaitForTagetFps 70% . I don't know if this would effect anything.
    Then from my graph, I notice a big part of it, is categorized as "other".

    Ah, I need to really learn how to use this stuff. Actually I need to know how to see things in profiler.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You should not be worried about percent of total. Even if you're profiling a completely empty scene, total will still add up to 100%. You should be worried about Time ms and GC Alloc.
     
    DylanYasen likes this.
  17. DylanYasen

    DylanYasen

    Joined:
    Oct 9, 2013
    Posts:
    50
    I see. Thank you.
     
  18. DylanYasen

    DylanYasen

    Joined:
    Oct 9, 2013
    Posts:
    50
    Hi brother. Just a quick question.

    I have this thing so called WaitForTargetFPS top in this list most of the time
    Time showing 13.91ms. other factors are not even 0.5ms. After some searching, I got to know it's about Vsync.
    But that's all I know,
    I wonder should I be worried about it? is it a problem?

    I'm trying really hard on optimization. Because I got this very weird problem, like a short freeze, when I try to test game on my android phone. no matter big or small. Every 4 or 5 seconds, screen freezes a little bit.
    Could you give me some direction on this?

    I thank you in advance.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    It's not a problem. It means your frame rate is very high and its having to pause to wait for VSync which tops out around 60fps usually before continuing. If anything, it's a sign that your scripts are not taking much processing power. Disable VSync and you'll probably see your frame rate shoot up into the hundreds.

    Periodic pauses are almost always due to garbage collection. Run the profiler and sort by GC alloc. If you have more than a few bytes of GC alloc every frame, you're building garbage and it must release that memory every so often which usually causes a pause, especially on mobile platforms. You will have to weed out as many allocations as possible to prevent this. The profiler is the tool for this.
     
  20. DylanYasen

    DylanYasen

    Joined:
    Oct 9, 2013
    Posts:
    50
    Thank you brother. That was very helpful