Skip to content

perf(creatures): scan pet and combat candidates only when used - #429

Merged
Mathih13 merged 1 commit into
mainfrom
perf/creature-tick-candidates
Sep 4, 2026
Merged

Mathih13 merged 1 commit into
mainfrom
perf/creature-tick-candidates

Conversation

@Mathih13

@Mathih13 Mathih13 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Creature candidate discovery scanned every WorldEntity on each movement tick and looked up EventAI state for each row. Characters now seed discovery through an entry index, and active objects come from an EventAI-state index. The remaining scan for pets and combat flags runs only on the slower sense cadence, when those lists are consumed.

The Character type-bit check, instance scope, default pets, combined combat flags and active objects outside Character AOI retain their existing behavior. This addresses the creature-scan finding in the performance and correctness report.

Verified with 1,470 Module tests in an isolated build, 233 focused cycle tests, a Wasm check and offline preflight. A private baseline-to-change plain publish created only the two indexes and preserved a distinctive existing row. The row shapes stay unchanged. The reduction concerns candidate discovery; no realm capacity improvement is claimed from this test.

Implemented by GPT-5.6 Sol through Codex, reviewed by GPT-6 through Codex.

Summary by CodeRabbit

  • Performance

    • Improved creature activity detection by using targeted indexes and cadence-aware processing.
    • Limited combat and pet candidate collection to appropriate firing intervals and scopes.
  • Bug Fixes

    • Improved discovery of player characters and active objects during creature updates.
  • Data Updates

    • Added indexed lookup support for world entities and creature AI states.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 394fd978-a089-4d01-92ed-3c4da474920f

📥 Commits

Reviewing files that changed from the base of the PR and between a447495 and 554ffbb.

📒 Files selected for processing (8)
  • module/src/creatures/cycle/ctx.rs
  • module/src/creatures/cycle/harness.rs
  • module/src/creatures/cycle/mod.rs
  • module/src/creatures/eventai/mobility.rs
  • module/src/creatures/eventai/mod.rs
  • module/src/creatures/eventai/tables.rs
  • module/src/creatures/tick/mod.rs
  • module/src/world.rs
💤 Files with no reviewable changes (1)
  • module/src/creatures/eventai/mobility.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The creature cycle now passes sense cadence into active-creature collection. The collection logic gates candidate scans and uses indexed lookups for players and active objects.

Changes

Creature sweep updates

Layer / File(s) Summary
Propagate sense cadence
module/src/creatures/cycle/mod.rs, module/src/creatures/cycle/ctx.rs, module/src/creatures/cycle/harness.rs
awake_creatures accepts the sense flag. run_cycle and both world implementations forward it to active-creature collection.
Use indexed creature discovery
module/src/creatures/tick/mod.rs, module/src/world.rs, module/src/creatures/eventai/tables.rs, module/src/creatures/eventai/mobility.rs, module/src/creatures/eventai/mod.rs
Candidate scans run on sense firings. Player discovery uses by_entry, and active-object discovery uses by_active_object. The obsolete helper and re-export are removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 554ff

Creature candidate discovery now uses indexes and sense cadence while retaining the documented filtering behavior. No current merge-blocking risk is identified.

Sequence Diagram(s)

sequenceDiagram
  participant run_cycle
  participant CreatureWorld
  participant active_cell_creatures
  participant WorldEntity
  participant game_creature_ai_state
  run_cycle->>CreatureWorld: awake_creatures(scope, tick.sense)
  CreatureWorld->>active_cell_creatures: collect active creatures
  active_cell_creatures->>WorldEntity: query entry index for entry 0
  active_cell_creatures->>game_creature_ai_state: query by_active_object index
  active_cell_creatures-->>CreatureWorld: return TickSweep
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: limiting pet and combat candidate scans to when they are used.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/creature-tick-candidates

Comment @coderabbitai help to get the list of available commands.

@Mathih13
Mathih13 force-pushed the perf/creature-tick-candidates branch from 2b5df44 to 554ffbb Compare September 4, 2026 21:28
@Mathih13

Mathih13 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

@Mathih13

Mathih13 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@Mathih13
Mathih13 merged commit 46d532c into main Sep 4, 2026
6 checks passed
@Mathih13
Mathih13 deleted the perf/creature-tick-candidates branch October 11, 2026 18:21
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