TeamAtomECS / AtomECS

Cold atom simulation code
GNU General Public License v3.0
46 stars 11 forks source link

Max number of entities #70

Closed minghuaw closed 2 years ago

minghuaw commented 2 years ago

There is a known issue related to specs, and it is caused by one of its dependencies, hibitset. This restricts the maximum number of entities to usize^4 (ie. 32^4 for 32-bit systems or 64^4 for 64-bit systems). I don't think there really is an easy solution other than writing a PR for hibitset. However, I am just wondering if you happened to have some workaround in the occasions where there is a large number of atoms? Plus, is there some kind of plan to overcome this in the future?

ElliotB256 commented 2 years ago

The long term plan is to move away from specs which is no longer actively developed. The likely candidates are either legion (which has the best performance for our tasks) or bevy (which has a larger community). We raised an issue on bevy for their poor parallel fine-grained task performance (it's anywhere between 2-10 times slower than legion, shipyard, hecs, etc) and they are working on fixing it, so hopefully come bevy 0.6 we will be able to move to that and benefit from the large community.

(Legion is fast but uses rayon, which leads to messy stack traces and is a nightmare for profiling, so im interested to see if bevy can reach parity without using that)

What simulations are you doing which use 1m entities? Maybe there's a way to simplify that to reduce the number of particles?

minghuaw commented 2 years ago

I was only experimenting with different number of atoms and max_theta and encountered this index out of bound error.

minghuaw commented 2 years ago

(Just throwing random ideas) Would you think there is someway to allow user switchable "ECS backend" by defining some of the common ECS behaviors required by atomecs in a trait, and implement this trait for different ECS crates? I haven't done enough research to see whether this is possible.

ElliotB256 commented 2 years ago

Probably not, there are quite a few differences between ECS such as bevy/legion and specs. For instance, in bevy components are just rust structs, they do not need to implement a trait or define a storage type. Systems are created straight from functions, rather than as a struct with an update method.

ElliotB256 commented 2 years ago

I marked it as wontfix just because the issue will be redundant once we change ECS, see #3.

@minghuaw if you are interested in seeing some of these other ECS packages, I was writing a small demo/game in bevy to explore the syntax, see https://github.com/ElliotB256/bevy_combat