Skip to content

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.

@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review March 6, 2025 15:01
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner March 6, 2025 15:01
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) March 14, 2025 00:20
@NoelStephensUnity NoelStephensUnity merged commit 72c2acc into develop Mar 14, 2025
40 checks passed
@NoelStephensUnity NoelStephensUnity deleted the perf/reduce-networkbehaviourilpp-type-resolution-time branch March 14, 2025 03:02
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.

4 participants