Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Transform optimizations in 5.6 beta?

Discussion in '5.6 Beta' started by ccsander, Dec 14, 2016.

  1. ccsander

    ccsander

    Joined:
    May 17, 2013
    Posts:
    44
    In this video from Unite, Joachim described optimizations to the transform and support for multi-threading. Just wondering if this is in current beta as some of the slides in the video show 5.6 as target.



    edit: when I pasted this I tried to include timestamp, but it got scrubbed. To see what I'm talking about, jump to timestamp 8:05.

    If not in current beta, is there a timeline for this release? I'm eagerly awaiting this optimization/feature!

    Thanks!
    ccs
     
    Last edited: Dec 14, 2016
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    According to this blog-post, the multi-threaded job system is targeted for Unity 2017, which is going to have its first beta release available in April 2017.
     
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,656
    Yeah, there's two separate things involved here:

    * Optimisations to the way we work with Transforms inside the native code part of Unity - I believe these changes are in 5.6 already.
    * The C# multithreaded job system stuff - this is not coming in 5.6.
     
  4. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Are you sure I'm not seeing the kind of boost I would expect in Cube Mark if this was implemented?


    Unity 5.5f3 DX12

    vs

    Unity 5.6b1 DX12


    Although a bit of a boost with Instancing Shaders*



    *Note: the default instancing shader does not have bump and normal mapping.
     
  5. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,656
    Yes.
     
  6. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Cool in the demo they showed fish swimming with and without the feature, is there a setting for it?
     
  7. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,656
    No, the transform optimizations are on for everybody.

    EDIT: Or did you mean a setting for turning on the fish? We didn't think building that into Unity would be a good idea, but you could try placing a fishtank in front of your computer screen and Unity should still work just fine.
     
    yc960, AlanMattano, ccsander and 2 others like this.
  8. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    So... is there any chance all this transform work will fix the random x,y,z coords when creating a new GameObject in the Hierarchy? I doubt that's high on anyone's priority list but it's always struck me as a weird sort of bug that seems like it ought to be a quick fix.
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I actually thought that was unity attempting to intelligently create an object in front of the camera, but truth is, it's quite a rubbish thing that comes off buggy.
     
    StaffanEk likes this.
  10. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    No need to be facetious.

    OK I'll see if I can throw together a test/benchmark for it just to see how much of a difference it makes, but it appears to have little impact in my simple cube mark benchmark.

    I presume it needs instanced shaders for maximum effect?
     
  11. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Quick test:

    10k Cubes
    5.5.0f3 DX11 Editor
    Standard 19 fps 40 batches
    Instanced 20 fps 65 batches?

    5.6.0f3 DX11 Editor
    Standard 21 fps 41 batches
    Instanced 24 fps 67 batches

    20k Cubes
    5.5.0f3 DX11 Editor
    Standard 9 fps 40 batches
    Instanced 11 fps 65 batches?

    5.6.0f3 DX11 Editor
    Standard 10 fps 41 batches
    Instanced 11 fps 67 batches

    Definitely a minor improvement in performance between 5.5 and 5.6 but not the leap that was shown in the fish demo?

    My test code (source below) just generates a lot of cubes stores them in a list and moves them twice per update.

    Only tested in the editor as wasn't this how the fish demo was shown all in editor.

    How do we get the same FPS boost as seen in the demo?
    Could Unity release the demo?
    How much of an impact does different hardware have on the Transform optimisations e.g. CPU

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class TransTest : MonoBehaviour {
    6.  
    7.     public GameObject prefab;
    8.  
    9.     public int cubeCount;
    10.  
    11.     private List<Transform> cubes;
    12.  
    13.     public float radius;
    14.  
    15.     public float speedScale = 10f;
    16.  
    17.     void Start () {
    18.  
    19.         cubes = new List<Transform>(cubeCount);
    20.  
    21.         for (int i = 0; i < cubeCount; i++)
    22.         {
    23.             cubes.Add((Instantiate(prefab, Random.insideUnitSphere * radius, Quaternion.identity) as GameObject).transform);
    24.         }
    25.     }
    26.    
    27.    
    28.     void Update () {
    29.         float dt = Time.deltaTime;
    30.  
    31.         foreach(Transform c in cubes)
    32.         {
    33.             c.Translate(Random.insideUnitSphere * dt * speedScale);
    34.             c.Translate(Random.insideUnitSphere * dt * speedScale);
    35.         }
    36.     }
    37. }
    38.  

    Note used the inbuilt FPS counter as was hoping for more of a boost;
     
  12. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    295
    As Superpig already told you, it's a separate thing. The multi-threaded job system (the C# API fish demo was using) is not coming in 5.6. Transform optimizations are already in.
     
  13. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    The transform optimisations should provide a good performance boost on transform operations (graph below)

     
  14. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    Will these internal methods get exposed? Or its in those already ^

    see at 44:18
     
  15. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194

    Top profiler is 5.6 (B) which you can see in the above profile screenshots is faster with 24ms vs 28ms.


    It's harder to tell in the deep profile as the 5.6 (B) profilers "Self ms" skews the results more than the 5.5 (A) profiler.
     
    Last edited: Dec 20, 2016
  16. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Indeed, I think the Unity devs simply can't grasp the concept of unpredictability = rubbish.
     
  17. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194


    If I'm reading this graph right then any transform heavy (e.g. 10k mesh renderer) games should see an improvement in performance of around 12ms (8ms in 5.6 vs 20 ms in 5.4).

    Now is this relevant to the optimisations in 5.6, or only when the multi-threading is applied in 2017.x?

    And what impact should we expect from the transform optimisations in 5.6?
     
  18. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Rewatched the video and it sounds like there are 3 separate optimisations:
    1. Native Rendering across all threads [x3] (example in talk PS4)
    2. Transform Optimisations on get/set pos + bounding volumes [x2](example XBox)
    3. Multi-threaded job code [x?](example Fish Boids Demo PC/Mac in Editor)
    Op3 is due in 2017.

    Op2 is in 5.6?

    What about Op1?
     
    AlanMattano likes this.
  19. ccsander

    ccsander

    Joined:
    May 17, 2013
    Posts:
    44
    If I understand it correctly, one of the performance optimizations on the transforms has to do with delaying the push of update down the hierarchy of child transforms when doing transform sets. This is going to mostly help with larger stacks of transforms, like animated models. Single transform objects won't really benefit from this part. Based on that slider, however, it does appear that simple single-transform objects with no children should also see a boost.

    Anyway I'm glad to hear these optimizations are in. I'm going to attempt to do some benchmarking myself. I will post my results.

    ccs
     
    mh114 likes this.
  20. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455



    is the new transform component in unity 5.6 ? I didnt see it in the release notes
     
  21. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    It's been a while since I checked but I think the big performance optimisations have been pushed back to Unity 2017, which should appear next after 5.6.
     
  22. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    im not talking about the big stuff like multithreading ,
    1. Transform Optimisations on get/set pos + bounding volumes [x2](example XBox)
    this has already confirmed to be in one the betas already

    i know threading isnt until unity 6
     
  23. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    There is no Unity 6, just 2017.
     
  24. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    What's new in 5.6 is the Transform.SetPositionAndRotation method, not sure about the other things.
     
  25. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    is thiss faster than , transform.position and transform.rotation?
     
  26. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    As far as I know, that's the reason why they added it.

    I believe this change originates from an Unite Talk that the INSIDE creators held. He is talking about SetPositionAndRotation (which existed internally already, but not exposed to C#) at 44:10, watch youtube video here.
     
  27. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    thanks:)
    thanks :)
     
    Peter77 likes this.
  28. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    It there a way to transform with double precicion?