Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Native dll process runs 2x slower in Unity than parallel or other engine, how do we achieve parity?

Discussion in 'Windows' started by PoseAI, Jul 28, 2023.

  1. PoseAI

    PoseAI

    Joined:
    Aug 19, 2021
    Posts:
    5
    PLEASE IGNORE THIS THREAD (I deleted description because it was a red herring and won't be useful to any future readers)
    The issue was not with Unity but rather how we were <mis>configuring our DLL only in the Unity loader.

    Performance parity with other engines/apps is as close as we would expect without tighter thread integration.
     
    Last edited: Aug 8, 2023
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,498
    The only thing I can think of that'd affect it is if your threads get paused by the garbage collector (which could happen if you call into C# from them). Other than that, have you tried profiling it? Unity doesn't really do anything with native threads running their own code.
     
  3. PoseAI

    PoseAI

    Joined:
    Aug 19, 2021
    Posts:
    5
    Thanks for your reply. We ran a scenario where we have no calls back to Unity: we have our DLL instead send localhost udp packets to python instead of unity. so in Unity we only configure the dll parameters and then launch the internal loop.

    We were hoping there was some issue "obvious to a Unity engine specialist" that we could focus on!

    So if nobody else chimes in soon with a big reveal we will embark on some deeper profiling. Its somewhat tricky given way the DLL and its dependencies are built. As our framework (and customer use case) is multiplatform, we will also investigate if ios/android are operating as expected as perhaps that may help isolate the potential causes.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,498
  5. PoseAI

    PoseAI

    Joined:
    Aug 19, 2021
    Posts:
    5
  6. PoseAI

    PoseAI

    Joined:
    Aug 19, 2021
    Posts:
    5
    We did some more testing and our equivalent plugin in iOS works fine from within Unity at least (ie same performance as when running from standalone app). However, on further reflection, so much of the iOS plugin is quite different due to hardware that it doesn't really shed much light on the windows issue, but at least it doesn't add another one!