- A Step Toward Realism
- Overview
- New Architecture Code Examples
- The Usual Type of Client-Side Code
- A Couple of Tweaks that Help Performance
- Collapsed Objects
- Statuses in One Single Byte
- Object Vector
- NonSerialized()
- Using "Dumb" Collections
- Another Struggle with Guids
- Oops, Maintainability Must Be Lost!
- And a Few Tweaks Not Applied Yet
- A New Test Application
- Results of the Throughput Tests
- Conclusion
NonSerialized()
There's another thingwhich isn't first and foremost a performance optimizationthat can help when it comes to reducing serialization size: to mark context-aware fields with <NonSerialized()>. For EntityBase, an example is the expander instance, which helps to expand a collapsed instance, implicitly or explicitly. I don't want that instance to travel over the network anyway, so it's just fine to mark it as <NonSerialized()>.
Another trick is to cache values in EntityBase that are marked as <NonSerialized()> (an example is the offsets I need to use for navigating in the object vector). Those values can be found by asking the subclasses, but because the EntityBase needs them very frequently, I cache them in the EntityBase and I only access them in EntityBase via private read-only properties. Once again, the fields in EntityBase are not serialized to save on serialization space. This is a tweak that probably can be used for many situations.