bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.42k stars 3.5k forks source link

World Garbage Collection / Compaction #4781

Open james7132 opened 2 years ago

james7132 commented 2 years ago

What problem does this solve or what need does it fill?

Resources allocated to a World are currently never reclaimed (except Entity ID space`). This includes memory allocated in BlobVec / Column, empty archetypes, empty tables, etc. These unused resources may add extra work over time. Processes that scale with the number of archetypes, tables, or entities will grow slower as more varied gameplay situations are encountered.

What solution would you like?

Either a manual World::vacuum that uses exclusive access to reorder and collect unused memory and ID space, or some behind the scenes book-keeping that gradually collects unused resources.

What alternative(s) have you considered?

mockersf commented 2 years ago

It would be nice to have metrics (possibly as diagnostics) on usage (memory, number of archetypes, ...) before trying to clean up

james7132 commented 2 years ago

On this note, #4832 was opened to automatically clean up event storage.