Skip to content

Add AdaECS benchmark target - #109

Open
SpectralDragon wants to merge 2 commits into
mainfrom
adaecs-bevyecs
Open

SpectralDragon wants to merge 2 commits into
mainfrom
adaecs-bevyecs

Conversation

@SpectralDragon

Copy link
Copy Markdown
Contributor

Summary

  • add AdaECSBenchmarks target wired up to package-benchmark so the new benchmark binary builds with the existing world-query helpers
  • implement benchmark scenarios covering simple inserts, iteration, fragmented iteration, and add/remove cycles using AdaECS queries
  • extend Package.swift with the Benchmark dependency and plugin for the new target

Testing

  • Not run (not requested)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +11 to +15
static var entitiesInsertCount = 0
static var insertNewEntityCount = 0
static var moveEntityToArchetypeCount = 0
static var queryEntityLookupCount = 0
static var querySetChunkCount = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +333 to +334
DebugBenchmarkLogCounter.queryEntityLookupCount += 1
if DebugBenchmarkLogCounter.queryEntityLookupCount % 25_000 == 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant