apecs
Asyncronous Parallel Entity Component System
Why
apecs is an entity-component system written in Rust that supports traditional syncronous
systems as well as asyncronous systems that can evolve over time. This makes it great for
general applications, quick game prototypes, DIY engines and any simulation that has discrete
steps.
Goals
- productivity
- flexibility
- observability
- very well rounded performance, competitive with inspirational ECS libraries
- like
specs,bevy_ecs,hecs,legion,shipyard,planck_ecs
- like
Features
- syncronous systems with early exit and failure
use ; let mut world = default; world .with_system .unwrap; world.run; assert_eq!; - async systems, ie systems that end and/or change over time (for scenes, stories, etc)
- fetch resources from the world asyncronously
- resources are acquired without lifetimes
use ; async let mut world = default; world .with_resource .unwrap .with_async_system; world.run; assert_eq!; - support for async futures
use World; let mut world = default; world .with_async; world.run; - fetch data (system data) derive macros
use ; let mut world = default; world .with_resource .unwrap; let mut my_data: MyData = world.fetch.unwrap; *my_data.u32_number = 1; - system scheduling
- compatible systems are placed in parallel batches (a batch is a group of systems that can run in parallel, ie they don't have conflicting borrows)
- systems may depend on other systems running first
- barriers
use ; let mut world = default; world .with_system.unwrap .with_system_with_dependencies.unwrap .with_system.unwrap .with_system_barrier .with_system.unwrap; assert_eq!; world.tick; assert_eq!; world.tick; world.tick; assert!; - component storage
- optimized for space and iteration time as archetypes
- queries with "maybe" and "without" semantics
- queries can find a single entity without iteration or filtering
- add and modified time tracking
- parallel queries (inner parallelism)
use ; // Make a type for tracking changes ; // Entities and ArchetypeSet (which stores components) are default // resources let mut world = default; world .with_system.unwrap .with_system_with_dependencies.unwrap .with_system_with_dependencies.unwrap; assert_eq!; world.tick; // entities are created world.tick; // f32s are modified, u32s and strings are synced world.tick; // f32s are modified, u32s and strings are synced let q_bundle: = world.fetch.unwrap; assert_eq!; - outer parallelism (running systems in parallel)
- parallel system scheduling
- parallel execution of async futures
- plugins (groups of systems, resources and sub-plugins)
- configurable parallelism (can be automatic or a requested number of threads, including 1)
- fully compatible with wasm
Roadmap
- your ideas go here
Tests
I like firefox, but you can use different browsers for the wasm tests. For the most part they're there just to make sure apecs works on wasm.
Benchmarks
The apecs benchmarks measure itself against my favorite ECS libs:
specs, bevy, hecs, legion, shipyard and planck_ecs.
Caveats
apecs uses generic associated types. This means it can only be compiled with nightly.