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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

A interesting discussion about mono pef in our discord

Discussion in 'General Discussion' started by MDADigital, Sep 9, 2020.

  1. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
  2. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    So basicly what above means is that when dealing with floats (like vector3) in the domain code we actually are working with doubles.
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    Hasnt this always been the known case though?

    Its one of the reasons DOTS is so great, because a float3 is actually a float3 and not some other data type masquerading as a float

    If this is something worrying to you I really suggest looking into DOTS, I have been recently and it has come leaps and bounds in terms of usability.

    Its still not production ready for a long time but I think its at a point where its worth starting to learn it so everyone is ready to jump ship when it matures and has decent tooling to make more game types viable
     
    Ryiah likes this.
  4. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    We will move some systems to it when it's production ready.

    But it's plain bad that any operation on float first needs that double conversion.
     
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    Is it confirmed to be all floats though? I was under the impression it was only certain structs and certain functions in the API that do this, not all of them - but I am not honestly 100% on that and its been a very long time since I read up on this.
     
  6. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    All operations on float, quaternion * vector3 resulted in over 300 operations and many convertions from and to double
     
  7. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,877
    Okay that does not sound right at all, it would be interesting to hear from someone on unity development/technical team regarding what/why this is? Im not really sure who would be best to tag in regarding that though
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Last edited: Sep 10, 2020
    MadeFromPolygons likes this.
  9. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Might as well move straight to .NET 5 :D
     
  10. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
  11. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    390
    I consider this a humbling testament to the power of the modern processor (grin)
     
  12. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Wait there is more
    Screenshot_20200910-214520.jpg
     
  13. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    390
    lol, like I said it is amazing that this lack of performance doesn't cripple everything. I was staggered to find out that from my understanding unity didnt have any kind of SIMD acceleration under the hood before mathematics / burst came along. CPU's have come a long way since my ZX Spectrum :)
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Unity does use SIMD in the C++ code, just not in C#. It was added around the 5.0 period from what I can recall.
     
  15. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    This is also pretty cool,. Net clr is a little bit faster than pure cpp

    Screenshot_20200910-231130.jpg
     
    MadeFromPolygons likes this.
  16. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,514
    It goes to show that the vast majority of code that most people write doesn't actually need to be fast. And where code does need to be fast, it's often not bottlenecked by the things people expect. A 500% increase in float operation performance would most likely not get anywhere near a 500% increase in overall code performance in the vast majority of cases.

    So, while looking at relative speed tests for operations like this is indeed informative and generally good to know, what actually matters on a day-to-day basis are quite different questions: "Is it fast enough?" and "Where are the slowest parts I can control?"

    Knowing that using some other tool I don't have access to would make something 5 times faster doesn't help me answer either of those. If / when Unity addresses it everyone's life will be a bit easier when it comes to doing performance related stuff, but it's not worth my energy if I need something done today. I need to figure out what I can do with what I've got for it to make a difference.

    Another thing to consider is that while the instructions are indeed slower, and that becomes a big deal when you're doing 100 million iterations to test the difference, it that may still not be the bottleneck in real-world code. Here's one example. That's no excuse for a compiler being arbitrarily inefficient, though. There are cases when we need to do lots of float operations in a row, and those cases should be supported properly.
     
  17. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    IL2CPP kinda sidestepped the problem. Currently the only platform where Mono is used is PC, where CPUs usually have vastly better single core performance than phones and consoles.

    Back when people often released Mono games on consoles it was probably one of the reasons behind the epidemic of terribly performing ports of Unity-made for PS4 games, like Firewatch, Broforce, and others.
     
    jamespaterson likes this.
  18. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Anders states exactly the same thing

    upload_2020-9-11_10-28-56.png

    But since all arithmetic functions in Unitys mono version are fubar I have a hard time seing it wont affect performance. After all most 3d games do a few arithmetic calculations every frame even in the domain code.