-
Notifications
You must be signed in to change notification settings - Fork 361
[FR] High GC Allocation in Editor - Cache ExecutionEnvironment Cmdlineargs #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue does not seem to follow the issue template. Make sure you provide all the required information. |
Hi @snorrsi, In order to ensure that your editor has the latest updates and bug fixes, could you try updating to the latest version (Unity 2021.1.0)? If the issue persists after doing this, I'd like you to provide a minimal, reproducible example of your project so that the cause of your issue can be identified. Thanks. |
Hi @paulinon , Thanks for quick reply. The same issue is happening with Unity 2021.1.0f1 every frame. |
Hi @snorrsi, It would be great if you provide the steps you've taken before experiencing this issue along with the minimal repro I asked previously. This way, I can have a better understanding of this behavior |
Hi @paulinon , No problem. My apologies, didn't really think the project was needed since I basicly didn't change anything except adding EDM4U. I have now uploaded the project to GitHub. I explained the steps taken in the readme file for the project. |
Hi @snorrsi, So far, I have not been able to reproduce the issue you're facing, but I haven't used the same Unity editor version you used. Also, I have not been able to update my editor due to some issue on my end. While I try to fix that, could you try using an LTS version of Unity (such as 2020.3.0) and see if the issue persists? If so, it would be great if you can provide another minimal repro that uses an LTS version. |
Hi @paulinon , I have updated the repository to Unity 2020.3.1f1 version. The issue still exists. 2020.3.1f1 example project now at https://github.com/snorrsi/edm4u_gc_alloc According to the GC Alloc logs it seems that EDM4U most favourite property is ExecuteMethodEnabled in source/ExecutionEnvironment.cs line 39 Possible fix with caching
Example GC Alloc log from 2020.3.1 Metadata: Callstack: |
Hi @snorrsi, According to my replication, there's a GC allocation of 3.2kB, none of them show any origin. I see that you've indicated that this occurs for both Mac and Windows operating systems. With that, could you provide recent screenshots of the profiler for both operating systems so we can narrow down what's causing this behavior? |
Hi @paulinon , you have to make sure to select Call Stacks on the top right side of the Profiler window before you record. |
There are some gains to be made here by caching these command line argument flags as you point out. I'll label this as a feature request and alter this ticket's name to describe more about what the engineering efforts are. Thanks for the report! |
@DellaBitta @chkuang-g any change this will actually be fixed anytime soon? |
Hey @chkuang-g , see that you had the last commit to these files I mentioned 2 years ago. It's bit annoying to see upto 19KB of totally uneeded GC Alloc in Editor for every frame. |
@arcv haha, yeah don't understand why they didn't take this seriously.. but hey, I created a simple branch and pull for this issue. Maybe that will wake them up |
This has to be merged in. @paulinon is the jar resolver maintained anymore or has Google sunset Unity support? The editor is constantly allocating memory which makes long-running automated test running inside editor slow down over time etc. Of course you can't read the command line every frame, read it once like this pull request does. Merge it in now please. |
Hey folks, thanks for bringing this up to my attention, especially with the PR @snorrsi, @Tommigun1980! This does sound like a reasonable change that we should have in our resolver. Let me bring this up to our engineers and see if we can get this merged soon. |
Thanks so much, hugely appreciated! 💯 |
Just a couple of more minor things related to this;
|
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
During Editor profiling it's clear that same functions in EDM4U are run multiple time which are causing high GC Alloc due to string ToLower function.
Due to string conversion the GC Alloc is 10kb or so each frame or at least very often.
Can't this data be cached as the UnityEngine.Environment.CommandLine surely does not change often?
source/VersionHandlerImpl/src/ExecutionEnvironment.cs#L32
source/VersionHandlerImpl/src/ExecutionEnvironment.cs
31 | public static bool InBatchMode {
32 | get { return Environment.CommandLine.ToLower().Contains("-batchmode"); }
… |
38 | public static bool ExecuteMethodEnabled {
39 | get { return Environment.CommandLine.ToLower().Contains("-executemethod"); }
40 | }
source/VersionHandlerImpl/src/Logger.cs#L52
source/VersionHandlerImpl/src/Logger.cs
50 | internal static bool DebugLoggingEnabled {
51 | get {
52 | return Environment.CommandLine.ToLower().Contains("-gvh_log_debug");
52 | }
Please answer the following, if applicable:
What's the issue repro rate? 100%
What happened? How can we make the problem occur?
During Editor profiling it's clear that same functions in EDM4U are run multiple time which are causing high GC Alloc due to string ToLower function.
Run a project in Unity Editor with Call Stacks (GC Alloc) profiling and look at origination of GC Allocation in Editor.
Attached is callstack and image from the Unity Profiling. All of the 5.8kb GC Alloc is related to this issue.
edm4u_gc_alloc_callstack.txt
The text was updated successfully, but these errors were encountered: