You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One performance issue on the horizon is the use of reflection in the default property extractor. Reflection in C# is pretty slow. In our case there's evidence that using FieldInfo as is currently done in the MappedClassField implementation is around sixty times slower than direct assignment [1].
Some steps should be taken to make sure that this is actually a problem:
Performance testing with lots of mapped properties exposed in libmapper
Running some flamegraphs to see where any problems actually lie
Potential performance improvement paths
Runtime Code Generation
Use DynamicMethod to generate getters/setters at runtime.
Pros:
Works for any Component type thrown at us, and is definitely faster than just reflection.
Potential issues are platforms where runtime code generation isn't possible or is very slow, such as iOS
Compile-time Code Generators
Use the Roslyn generators system to automatically create concrete classes implementing IMappedProperty. This is probably the fastest implementation possible
Initial experiments with generating code via c#'s DynamicMethod seem to yield a ~5x performance increase on the synchronous part of UnityMapper. Will probably want to test on lower-end hardware.
One performance issue on the horizon is the use of reflection in the default property extractor. Reflection in C# is pretty slow. In our case there's evidence that using
FieldInfo
as is currently done in theMappedClassField
implementation is around sixty times slower than direct assignment [1].Some steps should be taken to make sure that this is actually a problem:
Potential performance improvement paths
Runtime Code Generation
Use DynamicMethod to generate getters/setters at runtime.
Pros:
Potential issues are platforms where runtime code generation isn't possible or is very slow, such as iOS
Compile-time Code Generators
Use the Roslyn generators system to automatically create concrete classes implementing IMappedProperty. This is probably the fastest implementation possible
References
[1]: https://medium.com/@veyseler.cs.ist/performance-test-for-setting-a-field-in-c-with-reflection-3e2e41d8a2ab
The text was updated successfully, but these errors were encountered: