Search Unity

Linux player uses 10 times more CPU than Windows player

Discussion in 'General Discussion' started by alonso_actionreaction, Oct 12, 2018.

  1. alonso_actionreaction

    alonso_actionreaction

    Joined:
    Mar 24, 2018
    Posts:
    7
    Hello. Our game is using Unity as a real-time backend solution, by running an instance of the game acting as dedicated server.

    We have made some tests of the performance of this solution by joining the server and creating 20 NPCs, and it seems that under the same conditions the performance drop is huge in Linux.

    Here is the CPU usage in Windows (Intel(R) Core(TM) i3-4330 CPU @ 3.50ghz)
    cpuwindows.png

    And here is the same server running in Linux (Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz)
    upload_2018-10-12_13-22-21.png

    The server is a headless version with all the graphics and UI stripped down. Looking at the profiler it displays a clear SetPass: 0. Both of them are running with Mono.

    Any ideas of the reason behind? Is Unity using a different Mono implementation on Linux? Are they compiled with different compilers or different optimization flags?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    elmar1028, angrypenguin and Martin_H like this.
  3. alonso_actionreaction

    alonso_actionreaction

    Joined:
    Mar 24, 2018
    Posts:
    7
    Thanks for the reply superpig. Is it possible to measure the frame time without using the profiler?
    And yes, I'm limiting the framerate to 15fps.
     
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Not easily. If you're trying to optimise your CPU usage then you should be using better profiling tools than Task Manager / top in any case :)
     
    angrypenguin likes this.
  5. alonso_actionreaction

    alonso_actionreaction

    Joined:
    Mar 24, 2018
    Posts:
    7
    Thanks for the advice. We are not looking to avoid the profiler because we don't like it, but rather because we are more interested in finding out the real CPU usage in a real-world scenario without all the profiler and debugging bloat.
    I don't mind if it's not easy to find out the frame time as long as it's possible. Do you have any good reference I could follow?
     
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Well, you can always use a standard native-application profiler - the Unity profiler can't be run against a release build because that engine build is missing the data collection hooks, but we still ship symbols, so you should be able to run a standard native profiler (like VS, VTune, etc) and get some idea of where the CPU is spending time.
     
  7. alonso_actionreaction

    alonso_actionreaction

    Joined:
    Mar 24, 2018
    Posts:
    7
    Thanks, I will get back with the results.
     
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Ummm..... The Linux "top" command gives a percentage of a single CPU core. So if you have an 8 core CPU you can actually have 8 applications reporting they are running at 100% at the same time. It is also common for a multithreaded application to report more than 100%.

    The Windows Task Manager though reports a percentage of overall CPU cycles. So on an 8 core CPU an application using 100% of a single core would be reported as using 12.5% instead of 100% as top would report.

    In your example, "top" was reporting your game was using 12% of a single core, and Windows was reporting your game was using 1.5% of all cpu cores. Since your Linux build was running on a CPU with 8 hyperthreads, you divide 12% by 8 to get approximately what Windows would report on that CPU (at least using the same methodology as the Task Manager uses). 12% / 8 = 1.5% So it doesn't look much different to me.
     
    Last edited: Oct 13, 2018
    Lurking-Ninja and Ryiah like this.
  9. alonso_actionreaction

    alonso_actionreaction

    Joined:
    Mar 24, 2018
    Posts:
    7
    This is very useful info. Thanks!