Skip to content

[FR] High GC Allocation in Editor - Cache ExecutionEnvironment Cmdlineargs #428

Open
@snorrsi

Description

@snorrsi

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.2.6 and 2021.1.0
  • External Dependency Manager version: 1.2.164
  • Source you installed EDM4U: Unity Package Manager
  • Features in External Dependency Manager in use: Android iOS, iOS Resolver
  • Plugins SDK in use: Firebase (none in 2021.1.0)
  • Platform you are using the Unity editor on: Mac and Windows

[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.

Screenshot 2021-03-24 at 11 45 41

edm4u_gc_alloc_callstack.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions