Commit 72c2acc
perf: reduce networkbehaviourilpp type resolution time (#3227)
User submitted PR: #3224
## Measurement
With `minimalproject`, I used the following code for measurement.
```diff
diff --git a/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs b/com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs
index 7e95fea..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.
---------
Co-authored-by: ruccho <noboroo2000@yahoo.co.jp>1 parent 6f26efa commit 72c2acc
File tree
1 file changed
+60
-24
lines changed- com.unity.netcode.gameobjects/Editor/CodeGen
1 file changed
+60
-24
lines changedLines changed: 60 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
| 966 | + | |
| 967 | + | |
966 | 968 | | |
967 | 969 | | |
968 | 970 | | |
969 | 971 | | |
970 | 972 | | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
971 | 1011 | | |
972 | 1012 | | |
973 | 1013 | | |
974 | 1014 | | |
975 | | - | |
| 1015 | + | |
| 1016 | + | |
976 | 1017 | | |
977 | 1018 | | |
| 1019 | + | |
978 | 1020 | | |
979 | 1021 | | |
980 | 1022 | | |
| |||
983 | 1025 | | |
984 | 1026 | | |
985 | 1027 | | |
986 | | - | |
987 | | - | |
988 | | - | |
| 1028 | + | |
989 | 1029 | | |
990 | 1030 | | |
991 | 1031 | | |
992 | | - | |
| 1032 | + | |
993 | 1033 | | |
994 | 1034 | | |
995 | 1035 | | |
| |||
1789 | 1829 | | |
1790 | 1830 | | |
1791 | 1831 | | |
1792 | | - | |
| 1832 | + | |
1793 | 1833 | | |
1794 | | - | |
| 1834 | + | |
| 1835 | + | |
1795 | 1836 | | |
1796 | | - | |
1797 | | - | |
1798 | | - | |
1799 | | - | |
1800 | | - | |
1801 | | - | |
1802 | | - | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
1803 | 1840 | | |
1804 | | - | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
1805 | 1846 | | |
1806 | | - | |
1807 | | - | |
1808 | | - | |
1809 | | - | |
1810 | | - | |
1811 | | - | |
1812 | | - | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
1813 | 1850 | | |
1814 | 1851 | | |
1815 | 1852 | | |
| |||
2025 | 2062 | | |
2026 | 2063 | | |
2027 | 2064 | | |
2028 | | - | |
2029 | | - | |
| 2065 | + | |
2030 | 2066 | | |
2031 | 2067 | | |
2032 | 2068 | | |
| |||
0 commit comments