I’m experimenting with using Entities in my game which uses rollback netcode. As a part of the netcode requirements, I need to serialize the game simulation world every game tick for rollback. I’m trying out SerializeUtility.SerializeWorld with a custom in-memory BinaryWriter to do this, but it seems to allocate ~5KB of garbage every frame, even in release/production mode:
The GC seems to arise from fetching custom attributes for the serialized types. Is it not possible to cache this information to avoid GC?
This isn’t a strict blocker, but this does have a large accumulative effect on the game since it’s being called every game tick.
Tangentially related: a World with three archetypes, all of which with a single entity serializes to a buffer of 48KB. If done every frame, that’s 2.8MB per second sans delta compression. Seems like the entire 16KB of each chunk is being serialized instead of just the valid components. This also poses another issue in that the chunk may contain uninitialized memory, which will cause hash mismatches when rolling forward states in rollback netcode.