SpacetimeDB
SpacetimeDB copied to clipboard
Avoid reflection when constructing row in bsatn deserialization
Description of Changes
Avoids paying new T()'s (potential) cost of reflection on each row decode.
API and ABI breaking changes
None
Expected complexity level and risk
1
Testing
- [ ] Unity profile
I'd like to check if this actually monomorphizes in Unity
From deep profiling Blackholio, this does not seem to result in monomorphization.
I found https://andrewlock.net/benchmarking-4-reflection-methods-for-calling-a-constructor-in-dotnet/ which shows that activator.createinstance is still quite fast -- 40ns, versus 10ns for new(). I think this may be a case of the unity deep profiler blowing up execution times. But I'm not completely confident about that.
A bot test showed no improvement. Closing this in favor of the following codegen approach https://github.com/clockworklabs/SpacetimeDB/pull/2725.