I’m really struggling getting closer to other ECS frameworks like Apecs, Bevy, or Flecs. I totally accept Haskell may bring some overhead, especially when mimicking the imperative style of a Rust or C++ ECS, but I feel like my current results have to include some low-hanging fruit… I’d absolutely love any help making this ECS faster!
I’ve been able to get queries for 10,000 entities (with two components) down to about 700us on my machine, where the previous immutable IntMap solution was about 100us. Bevy is still blowing this out of the water at about 8us
I’m afraid Vector (Maybe a) is doomed to be slow. For performance you want to replace Maybe a with (Bool, a), so that you have a bit vector and then Vector a, potentially unboxed if a allows it.
Do you mean MVector?
You don’t mention what operations you use, but with a Vector modifications will be slow, unsurprisingly, because it needs to copy all the elements into a new Vector.
You can look at my code here for inspiration (or simply copy it):
I think my code should be reasonably fast. Keep in mind that the Storable version is simply the best for performance. You will never beat it with a boxed approach.