feat(ecs): parallel system execution with rayon thread pool#155
Merged
Conversation
Rayon will be used for parallel ECS system dispatch during the SIMULATE phase. Added as a workspace dependency and wired into basalt-ecs and basalt-server.
Add dependency graph scheduler and parallel dispatch for the SIMULATE phase. Non-conflicting systems run concurrently via rayon; conflicting systems are serialized into sequential groups. Key components: - schedule.rs: greedy graph coloring from SystemAccess declarations, with GroupCache precomputed at startup (LCM-based cycle, O(1) lookup) - parallel.rs: ParallelSystemContext using store partitioning — write-stores as exclusive ownership, read-stores as shared refs - ecs.rs: run_phase_parallel with fast path for single-system groups, zero per-tick allocation via Vec<Option<SystemDescriptor>> storage Spawn/despawn during parallel execution is deferred and applied between groups. The SystemContext trait and all plugin APIs are unchanged.
Initialize the rayon global thread pool at server startup with a configurable thread count (system_threads in [server.performance]). Add missing component access declarations on core systems (lifetime, pickup_delay) so the parallel scheduler can compute correct groups.
Three nightly benchmarks for regression detection: - fast path (single system, zero overhead baseline) - 3 non-conflicting systems (rayon parallel dispatch) - 2 conflicting systems (sequential fallback in separate groups)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
system_threadsin[server.performance])Vec<Option<SystemDescriptor>>storage and cache take/put-back patternCloses #123
Test plan
-D warnings)cargo +nightly bench -p basalt-ecsto establish baseline for parallel_fast_path, parallel_3_non_conflicting, parallel_2_conflicting