Add AdaECS benchmark target - #109
SpectralDragon wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da7f6ec55b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| static var entitiesInsertCount = 0 | ||
| static var insertNewEntityCount = 0 | ||
| static var moveEntityToArchetypeCount = 0 | ||
| static var queryEntityLookupCount = 0 | ||
| static var querySetChunkCount = 0 |
There was a problem hiding this comment.
Synchronize global benchmark counters
DebugBenchmarkLogCounter stores mutable static Ints that are incremented from multiple runtime paths (Entities.insert, World.insertNewEntity / moveEntityToArchetype, and FilterQueryIterator.next) without any lock/atomic protection. Because these paths can run on different tasks/threads, this introduces a real data race on shared state that can yield undefined behavior (including crashes under race detection) in concurrent ECS workloads. Use ManagedAtomic, an actor, or lock-protected updates for these counters.
Useful? React with 👍 / 👎.
| DebugBenchmarkLogCounter.queryEntityLookupCount += 1 | ||
| if DebugBenchmarkLogCounter.queryEntityLookupCount % 25_000 == 0 { |
There was a problem hiding this comment.
Gate benchmark instrumentation out of hot ECS loops
This benchmark counter/logging code runs on every entity iteration regardless of whether logging is enabled, because the CURSOR_DEBUG_LOG_PATH guard is only inside DebugBenchmarkLog.write. The unconditional increment/modulo checks in query iteration and world mutation paths add extra branch/arithmetic overhead to production ECS hot paths, which can both skew benchmark numbers and regress normal runtime performance. Wrap these blocks behind a compile-time benchmark flag or a fast early runtime guard.
Useful? React with 👍 / 👎.
Summary
Package.swiftwith the Benchmark dependency and plugin for the new targetTesting