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

Is just me, or Debug Log has improved in performance?

Discussion in '2020.1 Beta' started by Antypodish, Oct 21, 2019.

  1. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    I have impression that Debug.log now prints to console much more efficiently.

    Is that indeed the case, as the result of general performance improvements of Unity 2020?
     
  2. Deleted User

    Deleted User

    Guest

    Never noticed that it was slow. Do you have examples where it was for you?
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    @APSchmidt I am not saying 2019 was slow. But I got impression 2020.1a is much faster. Like profiler produces less spikes, when printing many logs in a frame as example. Which is good thing.
    That was soon after I ported project to 2020.1a, with debugging logs enabled.

    Unfortunately I don't have anything reliably to compare against atm. So I understand if my words may be just sounding, like blowing in the wind.
     
  4. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    It was slow depending on how much you're printing.
    I sometimes have to enable tracing, and in loops the impact can be significant. But, as far as I remember, the bulk of the cost was always related to parsing/processing the actual StackTrace.
    I ended up creating a tool that patches Unity's StackTrace parsing utility because it was too slow.
    It also helps that I can cleanup the stack of useless wrappers and stuff, but I did it mostly because of performance.


    They've been doing some real work on performance in 2020, so maybe there were improvements, but the StackTrace parsing I don't think received much change lately (I track it, since changes might break my patching).
     
  5. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I think I actually noticed that too, with the profiler. Before, it had a very pronounced spike. Recently, I had a bit of trouble finding the spike to profile my internal logging system.
     
  6. Deleted User

    Deleted User

    Guest

    Of course... What's the limit number of characters that Debug.Log can print?
     
  7. My best guess is that they moved the Console onto the UIElements.
     
  8. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Oh, I mean how frequent you're printing, but the actual length of the log.
    In my tests, most cost was from Unity parsing the StackTrace. Lots of string operations and allocations.
     
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    In my case I just print lots of entries, but each individual debug.log is rather short, anything probably between 20-100 characters on average.

    Yep, I read about it recently, so that triggered my thoughts on this topic as well.

    Doe it means, most UI is now on UIElements? Or you just specifically referring to console?
     
  10. I am only guessing here, obviously. And I don't think most of it on UIElements. But it is important to note: I may be very wrong either way.
     
  11. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I don't think much of the UI is on UIElements yet.
    In the Profiler and in the UIElements debugger you can often see IMGUI containers, so they're still using IMGUI in most stuff, like before. Maybe they started with the heavier stuff first.
    In particular, they did massive improvements to their TreeViews, so a lot of stuff benefited from that (in particular, the Profiler is now so much faster. It's was a huge quality of life improvement).
     
  12. Deleted User

    Deleted User

    Guest

    Just for the fun of it I tried and the answer is 7,250 characters. :)

    End of off topic. ;)
     
  13. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Is my only guess, but I suspect, they moved another bit of something into DOTS. Hence improvement. But may be as well UI.

    Sorry for striking End of topic :)
    What happens after 7,250? it just cut out, or throws error? Asking, since your 'essay' ends with full stop.
     
  14. Deleted User

    Deleted User

    Guest

    No error message either in Visual Studio or Unity. The original text I had put within the " " was 7,620 characters long and Unity printed 7,250 of them and, yes, it's funny that it ends just after a full stop.
     
    Antypodish likes this.
  15. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    @APSchmidt I just generated 1000 words of 10 characters each, using
    https://www.random.org/strings/?num=1000&len=10&digits=on&unique=on&format=html&rnd=new
    @"
    1647460871
    8881392224
    4945706527
    ...
    8327470407"

    Debug.log printed apparently 936 lines (words) = 9360 characters.

    Edit:
    That actually makes me think, as previously Console allow you to prompt dialog, which you could display full text, in desired format (HEX, ASCII, BIN?). We couldn't print long text before in console. It was trimmed. But was available via that pupup dialog.
     
    Last edited: Oct 21, 2019
  16. Deleted User

    Deleted User

    Guest

    I just tried that and Unity printed all the lines! That makes 10,000 characters, why the difference with you? And why the difference with a block of text?

    For testing purposes, I added a full new batch of 10,000 random strings of 10 characters to the previous batch, total 2,000 lines of 10 characters and eventually got a "3301<message truncated>" message after printing. Full length: 16,319 characters (<message truncated> included) in 1,359 lines.

    I tried the same with print("") and got the same result. Interesting?
     
  17. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    I tried again, this time 2000 lines of 10 strings each
    Code (CSharp):
    1. Debug.log ( @"
    2. 1706493813
    3. 2667790748
    4. ...
    5. 0649978678
    6. 8873<message truncated>
    7. " );
    13540

    Which gives me 13540 characters, of 1354 words.

    In constant
    Code (CSharp):
    1. Debug.log ( @"
    2. Z5UaHSm3hj
    3. ET1JKL1gAP
    4. ...
    5. LrCdgtdyuq
    6. PzRp<message truncated>
    7. " );
    Which gives me 13568 characters, of 1357 words.

    For whats more interesting, in my first case scenario of
    Each time I run app, number of printed lines slightly vary.
     
  18. Deleted User

    Deleted User

    Guest

    Why are you getting less than me? I did the test with 2020.1.0a9.
     
  19. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    I use 2020.1.0a8
    Is that a9 vs a8 privilege? :D
    But honestly I don't know.

    The only thing is, I got other things going on at startup as well. Is not just empty project. So maybe that affects somehow? Pure guess. I would need run on empty project to compare. But I don't want to go that far with test of debug log / console for now :)
     
  20. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,135
    forestrf, Grizmu, Peter77 and 2 others like this.