Skip to content

Improvements to snapshot library

Adam Reichold requested to merge make-snapshot-great-again into master

This was initially aimed at making the snapshot library faster by loading most entities completely in bulk but it turned out that the time for restoring a world is not spent in the actual restore but mostly in recomputing the R* tree indices, e.g. at scale factor 10 computing that index for the hoverfly clutches takes 84.5s whereas the complete world restorating takes 85s. However, this still does improvement deserialization performance and more importantly it significantly simplifies the snapshot library making it more readable even though by no means safer (actually the opposite as field access on partially initialized structures is an open issue driving Rust's raw references RFC).

Considering the main performance problem here, I changed the hoverfly cluchtes to be treated in aggregate, i.e. instead of modelling 100 cluchtes for a single egg with a 3cm displacement agains a 50cm sensing distance, I just track a single clutching site and the number of eggs layed there limited to the same count as the individual sites before. This significantly reduces memory usage but more importantly it significantly reduces initialization time, e.g. restoring the world at scale factor 10 now takes 2.5s instead of 85s, which makes sampling campaigns feasible without resorting to fork.

Edited by Adam Reichold

Merge request reports