Skip to content
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

perf: reduce networkbehaviourilpp type resolution time #3227

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

NoelStephensUnity
Copy link
Collaborator

User submitted PR: #3224

Measurement

With minimalproject, I used the following code for measurement.

diff --git a/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs b/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs
index 7e95fea9..39b4f991 100644
--- a/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs
+++ b/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs
@@ -77,6 +77,8 @@ namespace Unity.Netcode.Editor.CodeGen
 
             m_Diagnostics.Clear();
 
+            var sw = System.Diagnostics.Stopwatch.StartNew();
+
             // read
             var assemblyDefinition = CodeGenHelpers.AssemblyDefinitionFor(compiledAssembly, out m_AssemblyResolver);
             if (assemblyDefinition == null)
@@ -171,6 +173,8 @@ namespace Unity.Netcode.Editor.CodeGen
 
             assemblyDefinition.Write(pe, writerParameters);
 
+            m_Diagnostics.AddWarning($"ILPP has completed for {compiledAssembly.Name} in {sw.ElapsedMilliseconds} ms");
+
             return new ILPostProcessResult(new InMemoryAssembly(pe.ToArray(), pdb.ToArray()), m_Diagnostics);
         }
 

Before

(0,0): warning  - ILPP has completed for Unity.Netcode.Editor in 531 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.EditorTests in 604 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.Components in 363 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.TestHelpers.Runtime in 330 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.RuntimeTests in 735 ms

After

(0,0): warning  - ILPP has completed for Unity.Netcode.Editor in 79 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.EditorTests in 128 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.Components in 146 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.TestHelpers.Runtime in 117 ms
(0,0): warning  - ILPP has completed for Unity.Netcode.RuntimeTests in 537 ms

Changelog

  • Changed: Improved performance of NetworkBehaviour ILPostProcessor by omitting unnecessary type and assembly resolutions.

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants