Search Unity

Feedback Incremental GC feedback thread

Discussion in 'Experimental Scripting Previews' started by jonas-echterhoff, Nov 26, 2018.

  1. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    79
    We now have this deployed in production and it's working well. The issues we ran into & that I originally mentioned turned out to be unrelated, were instead related to UI onValueChanged events firing that previously didn't fire in object's state which was causing a stack overflow. I think the latest 2019.1x is actually catching it now even, instead of crashing. :)

    Customer reports are mostly positive regarding the speed/performance improvements from enabling the incremental GC; though we've been making optimizations as well, so is difficult to bifurcate and attribute the reports, but overall no complaints here.

    That said, is a win for sure and a good stride; next step, a more modern generational GC? A guy can hope! =D

    Out of curiosity, and IIRC from reading this thread originally, the incremental is only in builds? Will it be coming to the editor at some point in the future? Right now it's probably my #1 issue with Unity: editor runs at ~50% performance of builds. Which means that debugging user-submitted issues via their save games = extremely painful.

    Well, to clarify (and apologies for the slightly off-topic rant), really my #1 complaint with Unity is just performance in general. DOTS looks and seems great long-term, but it feels to be in varying states of beta / API change, and frankly it's still very unclear to me on what the best way [or IF there is even a workable/best way in Unity right now] to handle & render tons (100k+) of moving quads/2D within Unity -- and unfortunately we need something we can leverage much sooner than later.

    Anyways, not to be sour at all; Rome wasn't built in a day and each step forward by the respective teams is great, welcomed, and appreciated. Definitely a very good and tangible step forward. Ty! :)
     
    Last edited: Jun 16, 2019
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,633
    Thanks for the feedback!

    Editor support (and support for all other platforms, except for WebGL) is coming in 19.2.
     
  3. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    291
    Is it Editor support enabled in any of the 19.3 alphas?
     
  4. Gabrielmtn

    Gabrielmtn

    Joined:
    Jun 13, 2017
    Posts:
    2
    Jonas I'm not a unity dev, but a web dev who is nonetheless curious about spikes and stutters occurring in an ambition FPS unity game, Escape from Tarkov, which is under development, and doing a port from 2017 to 2018 soon.

    My suspicions are that it may relate to GC, or possibly asset handling as it relates to LOD, again, as a non Unity dev, and a non-team member I don't have a lot to go on.

    My question is simply this: Do you have any advice, or resources you'd recommend for Unity 2018 users relating to GC best practices, in lieu of using the incremental feature? Maybe advice on how Unity devs might diagnose the precise root of the issues?

    My goal is to start a thread in the game's subreddit where the early users can share notes and experiences to possibly support the dev's debugging of the issue, and I'd love to include any of your insight on GC spikes especially.
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,427
  6. Gabrielmtn

    Gabrielmtn

    Joined:
    Jun 13, 2017
    Posts:
    2
    I haven't, but I'll look into it. The reason I asked Jonas about ways one might hook into and improve 2018's GC functionality to bring it closer to 2019 is that I think that general advice would probably fall within the devs "what we've tried" list, while Jonas might be able to recommend patterns to mimic the performance 2019 gets.
     
  7. StefanStrategis

    StefanStrategis

    Joined:
    May 7, 2018
    Posts:
    1
    As our WebGL application is severely limited by GC from reading many large JSON files continuously, I was wondering if there is any update on WebGL support for the Incremental GC?
     
  8. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    310
    When I enabled incremental gc, I've got gc spikes from garbage created on other threads. In other words - this doesn't happen in 'normal' mode, and it seems like every thread is responsible for own garbage, but with incremental, garbage from all my threads are collected at main thread, so for such case it's step backward unfortunately.
     
  9. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    251
    In "normal" mode or incremental mode the GC is global. All threads allocate from a single heap and collections pause all threads. Please describe in more detail the issue you are hitting or file a bug with steps to reproduce it. Thanks!
     
  10. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    310
    If it's global then something in Unity is not working as it should for a very long time and consistenly, because I never have GC spikes if garbage objects are created on other than main threads. Very easy to test out, just create thread that will do a lot of garbage over long time, and observe profiler - nothing will show up in terms of gc. So until now I was sure every spawned thread manages 'own garbage', beacause that's what Unity behaviour suggest, and it's been like this since I remember.
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,096
    Could you post some code here how you make your threads? I'm guessing it's not in managed unity land?
     
  12. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    310
    It's buried a little under other API, but in the end it's normal C# new Thread(), so it's normal managed thread.
     
  13. snair692

    snair692

    Joined:
    Feb 2, 2016
    Posts:
    36
    I was playing around with the experimental Incremental GC and I started noticing hard crashes (in the built player, but not in the editor). It took me a few days to realize it was linked to my turning on of this feature.

    The feature itself seemed to work well for me (in the editor), but for whatever reason when I build the project (IL2CPP) these crashes begin.

    I am building a multiplayer game and using sockets which is multi-threaded code. In the headless authoritive server it establishes a connection immediately upon startup (like literally the first frame).

    I have been building the game for a couple of years but the hard crashes from memory errors just began in the built player a few days ago after turning on the incremental GC.

    It seems to produce a crash (At times) and not at others -- which is particularly interesting, although it seems to be about 80% of the time on the headless server. The DMP file and crash logs seemed particularly useless in establishing what exactly is causing it.

    I finally just disabled the Incremental GC and the memory allocation crashes in the built player disappeared. I wish I could provide you my project for testing but honestly the project is huge.

    I am currently using 2019.2.6f1
     
    Prodigga likes this.
  14. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    291
    Does 2020 have incremental GC enabled for the Editor?
     
  15. mirkojpn

    mirkojpn

    Joined:
    Mar 31, 2018
    Posts:
    113
    iàm currently on 2019.1 but i read on this coument that incremental garbage collection is working on ps4, switch etc.. from .2, are this correct

    https://docs.unity3d.com/Manual/UnderstandingAutomaticMemoryManagement.html

    exactly say this

    • Ability to disable garbage collection on Mono and IL2CPP scripting backends added in Unity 2018.3
    • Added exerimental Incremental Garbage Collection feature added in Unity 2019.1
    • Added support for Incremental Garbage Collection on additional platforms: PS4, XBox One, Nintendo Switch, and the Unity Editor. 2019.2
     
  16. mvaz_p

    mvaz_p

    Joined:
    Aug 22, 2018
    Posts:
    21
    We've tested the incremental GC in our new app version and the crash rates went crazy, specially on iOS.
    Pretty much every call stack was like this:

    Code (CSharp):
    1. 0   libsystem_kernel.dylib             0x00000001bcd55c94 __psynch_cvwait
    2. 1   tycoon                             0x00000001059344dc il2cpp::os::posix::PosixWaitObject::Wait(unsigned int, bool)
    3. 2   tycoon                             0x000000010594b4bc il2cpp::vm::Monitor::TryWait(Il2CppObject*, unsigned int)
    4. 3   tycoon                             0x0000000107054108 ManualResetEventSlim_Wait_mBBC47852C86E2A3D08FADAF3DE0588A2CE720B2F
    5. 4   tycoon                             0x0000000107065888 Task_WaitAllBlockingCore_m18DAF42FBD4D325F72C883D67DB9F387566F88CE
    6. 5   tycoon                             0x0000000107064d94 Task_WaitAll_m09EB068F881967FB91C8A221832F909BA3F1D00B
    7. 6   tycoon                             0x00000001070644a0 Task_WaitAll_m3D33138B9A02E2F739209DC77AF3441382C5B98F
    8. 7   tycoon                             0x00000001070643a8 Task_WaitAll_m7DEFF8B98DA926238FE40A54AA48FB0E3CAD1C47
    So we released a new version disabling incremental GC and the crashes seem to be gone.
    Using Unity 2019.2.12f1.
     
  17. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    218
    Is there a way to know how much garbage has been created in the current frame?
    Or better, is there a way to know how much garbage created since the last call to a function ('GetGarbageSinceLastCall()' for example)?

    Using the editor to profile isn't so useful because the editor has a devastating impact on performances.
    In addition, the editor itself generates garbage for some very standard things.
    And in addition, the editor will indicate some garbage generated in a method, under the form of 'GC.Alloc()'. But it's not that useful to know where in the method the garbage is generated.
    With a 'GetGarbageSinceLastCall()' method we could use dichotomy to find out the culprit.
     
    SugoiDev and Peter77 like this.
  18. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,427
    Having such method would be really useful!
     
unityunity