Skip to content

Flag ClosureEvents unit listeners per event id - #526

Closed
Frotty wants to merge 1 commit into
masterfrom
perf/unit-listeners-per-event
Closed

Frotty wants to merge 1 commit into
masterfrom
perf/unit-listeners-per-event

Conversation

@Frotty

@Frotty Frotty commented Nov 15, 2026

Copy link
Copy Markdown
Member

Change

EventListener.hasUnitListeners is now one flag per event id instead of one global flag.

Before, the first unit listener of any event switched on the unit lookup for every delivery of every event: GetTriggerUnit(), peekIndex(), getIndex() and an array read before the global listeners. That applies even for events that have no unit listener at all. Now only deliveries of an event that has unit listeners do the lookup. The flag still never resets, so it cannot fall out of step with the chains. Delivery order and which listeners run are unchanged.

Castle Fight has a single production unit listener, a structure ISSUED_ORDER listener that tracks the Parasite autocast toggle. Today that one listener makes every damage delivery pay the lookup, about 1.2 us per hit by the earlier measurement of this skip. With this change only order deliveries pay it.

Tests

  • ClosureEventsTests.aUnitListenerOfOneEventLeavesTheOtherEventsUnflagged: a unit listener of EVENT_PLAYER_LEAVE flags that event only. A dispatch of the chat-filter event to the same unit runs no unit listener.
  • StdlibIngameDamageTests (in-game 24): a unit listener on ISSUED_ORDER hears a real stop order on its unit and not on another unit, and the damage listeners still hear their hits.
  • grill typecheck --quiet passed. grill test --quiet passed 772/772.

Not yet verified in game

The in-game test 24 and the Castle Fight e2e have not run yet: Warcraft is in use on this machine. Map integration is tracked in Castle Fight PR 502, which points its stdlib dependency at this branch. That PR still owes building-catalog, spell-capability, spell-effect-diag, train-queue and sync-system.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T08:34:11.396262Z b9cb959 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty Frotty closed this Nov 15, 2026
@Frotty
Frotty deleted the perf/unit-listeners-per-event branch November 15, 2026 08:34
@Frotty

Frotty commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Superseded by the PR from the renamed branch perf-unit-listeners-per-event (Grill cannot read branch names with a slash).

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