Commit 6c41aba
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 6b8f88b commit 6c41aba
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 | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
| 988 | + | |
| 989 | + | |
988 | 990 | | |
989 | 991 | | |
990 | 992 | | |
991 | 993 | | |
992 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
993 | 1033 | | |
994 | 1034 | | |
995 | 1035 | | |
996 | 1036 | | |
997 | | - | |
| 1037 | + | |
| 1038 | + | |
998 | 1039 | | |
999 | 1040 | | |
| 1041 | + | |
1000 | 1042 | | |
1001 | 1043 | | |
1002 | 1044 | | |
| |||
1005 | 1047 | | |
1006 | 1048 | | |
1007 | 1049 | | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
| 1050 | + | |
1011 | 1051 | | |
1012 | 1052 | | |
1013 | 1053 | | |
1014 | | - | |
| 1054 | + | |
1015 | 1055 | | |
1016 | 1056 | | |
1017 | 1057 | | |
| |||
1861 | 1901 | | |
1862 | 1902 | | |
1863 | 1903 | | |
1864 | | - | |
| 1904 | + | |
1865 | 1905 | | |
1866 | | - | |
| 1906 | + | |
| 1907 | + | |
1867 | 1908 | | |
1868 | | - | |
1869 | | - | |
1870 | | - | |
1871 | | - | |
1872 | | - | |
1873 | | - | |
1874 | | - | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
1875 | 1912 | | |
1876 | | - | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
1877 | 1918 | | |
1878 | | - | |
1879 | | - | |
1880 | | - | |
1881 | | - | |
1882 | | - | |
1883 | | - | |
1884 | | - | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
1885 | 1922 | | |
1886 | 1923 | | |
1887 | 1924 | | |
| |||
2097 | 2134 | | |
2098 | 2135 | | |
2099 | 2136 | | |
2100 | | - | |
2101 | | - | |
| 2137 | + | |
2102 | 2138 | | |
2103 | 2139 | | |
2104 | 2140 | | |
| |||
0 commit comments