Search Unity

Reduce performance

Discussion in 'Getting Started' started by erlichguy, Feb 2, 2020.

  1. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    Hey guys,
    New to unity so sorry if it’s a noob question.
    I’ve started developing with unity on a 2015 MacBook Pro. I know it’s quite old but it’s serving me quite well.
    Now, in editor mode, things are relatively smooth regarding performance but in play mode the laptop is pretty struggling with high cpu usage and annoying fan noise making it impossible to play the game for more than a few minutes.

    My question is, is it possible to reduce performance of the game in some way (rendering, resolution,...) during me development stage?
    Later, if I reach some point where I want to release the game, I’ll raise all the stuff back. It’s just for the development phase.

    thank you
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    Game dev often requires using decent hardware.

    But you may have other issues with your application, which you are not aware of.
    I suggest you look and learn using profiler. Then look into bottlenecks, what cost you most of CPU / GPU / Memory. Then optimize accordignly.

    Other than that, use low quality textures and run on small resolution (resize gameplay screen).
    But I doubt, that will solve your main problem here. Worth a shot however.
     
  3. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    I immediately see the CPU jumping even on a simple scene with 5 items so bottlenecks are not the issue here.
    It looks like the laptop is indeed underpowered for unity development.
    I’ll try resizing the gameplay screen. Hadn’t considered that.
    Thank you
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I work from a 2014 MBP, and have zero issues running fairly complex scenes, so I don't think that alone is your issue.

    Screen Shot 2020-02-02 at 11.31.13 PM.png

    Do you have code running, maybe something that's looping and doing complex stuff inside of Update functions?
     
  5. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11

    This is just a new scene with 2 3d cubes and no scripts at all.
    The CPU is hovering around 80-90%
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    If you are using Unity 2019.x, it has known performance issues.
    Try 2018.x, or 2020.x (still alpha).
     
  7. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity by default will attempt to hit the highest frame rate your hardware will allow. That often results in either 100% utilization of the CPU or the GPU, whichever one bottlenecks you first. You can try forcing a lower frame rate though. Also reducing quality settings, reducing camera view distance, reducing the complexity of the scene, etc, etc, etc.

    I'd first check the profiler, see what FPS it says you're getting. Then try capping it lower with targetFrameRate.

    https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html
    Also read what that link says about vSyncCount.

    Note that Apple laptops are notorious for having insufficient cooling, where you quickly get reduced performance under sustained high load from thermal throttling. They do better with short bursts of high load, but games aren't that way. Just a design choice Apple went with, as it makes the laptop otherwise thinner and sleeker for the same specs on paper and most users won't notice the limitations.
     
    Schneider21 and erlichguy like this.
  8. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    Thank you @Joe-Censored
    Reducing framerate did the trick. I saw it was around 60fps and set it in script to 30. Now process cpu is around 60%.
     
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd probably wrap that in an #if UNITY_EDITOR preprocessor directive then. So whenever you run in the editor you get the low frame rate cap, but whenever you test the build it is uncapped automatically (or whatever is the default value for targetFrameRate on your target platform).

    Code (csharp):
    1. #if UNITY_EDITOR
    2.     Application.targetFrameRate = 30;
    3.     Debug.Log("Using Editor performance cap for my own sanity");
    4. #endif
    https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
     
    wlwl2 likes this.
  10. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    Thank you for that tip, but actually, I haven't yet felt any difference when running in 30fps.
    Assuming my game is not that fast-paced, where would I feel this reduced FPS? Why not run with this in build as well?
     
  11. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Depends on the game. Also, people who pay good money for a higher end gaming machine are usually annoyed by games which arbitrarily limit frame rate. You can look up videos discussing the advantages of higher FPS in games, why high refresh monitors are growing in popularity, etc. Too big a topic to give justice in a forum post.
     
    Ryiah likes this.
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
    This, and it's only made worse by the fact that there are groups of people that will single out your game and make it known that it comes with a limit on frame rate. Just as one example I've linked the Framerate Police group which is one of the Top 10 curators on the Steam store meaning they get quite a bit of attention.

    Furthermore, like the Kotaku article points out, when a curator with a large presence adds your game to their list that game will list that curator on their store page. In the article one developer tried to remove the curator from their store page, and the fans of the curator spammed negative comments all over their game forum. They quickly added it back.

    https://steamcommunity.com/groups/frameratepolice
    https://kotaku.com/the-story-behind-steam-s-framerate-police-1732590111
     
    Last edited: Feb 8, 2020
    Joe-Censored and iamthwee like this.
  13. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    Wow. I see your point.
    I guess I'll limit it in the editor for now :)
    Thanks guys for all your help!
     
  14. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you feel strongly about this, you can add the frame rate limit to your game's options menu.
     
    Ryiah likes this.
  15. erlichguy

    erlichguy

    Joined:
    Feb 4, 2019
    Posts:
    11
    Good idea. Thanks guys!