Skip to content

DummyRecycler: one pool for every angle, instant facing, configurable capacity - #529

Merged
Frotty merged 3 commits into
masterfrom
dummy-recycler-single-pool
Nov 16, 2026
Merged

Frotty merged 3 commits into
masterfrom
dummy-recycler-single-pool

Conversation

@Frotty

@Frotty Frotty commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Problem

DummyRecycler kept eight angle queues of six and served a get only from the queue nearest the requested angle. recycle refilled the smallest queue and removed the dummy once all were full. A map whose casts all ask for one angle (every caller in Castle Fight passes angle(0), as does DummyCaster.prepare) therefore had six usable dummies, while the other 42 stayed parked.

Measured in Castle Fight's late-game-bench (3v3, 600 lane units, ten 12 s windows, DummyPoolProbe): peak demand was 47 to 97 dummies out per window. The pool created 44 to 107 and removed 59 to 95 units per 10 game seconds, and the fewest parked dummies was 42 in every window.

Change

  • One pool serves every angle. get snaps the facing with BlzSetUnitFacingEx, so a checked-out dummy faces the requested angle at once. Before, setFacing started an animated turn from the bucket angle.
  • A boolean array keyed by unit index marks parked dummies, so isRecycled is one array read. Deindexing clears the slot, so a dummy removed while parked leaves no flag for the next unit on its index. createDummy indexes a dummy that entry did not index (a map whose shouldIndex refuses dummies, or the test runner); in game, entry has already indexed it. DummyRecycler now imports UnitIndexer.
  • @configurable DUMMY_RECYCLER_CAPACITY (128) is the most dummies kept parked, and DUMMY_RECYCLER_PRELOAD (48) is how many init creates, the same count as before. The pool grows to the capacity as dummies come back.
  • API: the public angleQueues array is replaced by pool and parkedCount(). Code that read angleQueues must switch; Castle Fight has two e2e readers and will port them with the lock bump. reset() gives tests a fresh pool.

Evidence

  • grill typecheck. grill test DummyTests.*: 5/5, including the new anyAngleIsServedFromOnePool.
  • In-game stdlib-ingame through the harness canary (wc3-e2e-harness 7261918, canary-stdlib.sh with this checkout), Warcraft III Reforged on this machine:
    • Lua, 004b0b2, 40490a3 and c84576f: PASS, 148 checks, 0 failed.
    • Jass, 004b0b2 and c84576f: 122 checks, 0 failed. The verdict reads FAIL only on caught-errors-4-expected-1, the minimal Jass adapter's caught-error count; the 2026-11-15 Jass run on master (7e7bfb7) shows the same.
    • Control, master 7e7bfb7 plus the new checks (Lua): 1 of 148 failed, and faces 180 degrees at once (233.2). The count check passes there because the canary's full queues have a 180-degree entry; pool exhaustion shows only under real load, which is the next item.
  • Castle Fight late-game-bench with this recycler swapped into its dependency for one run (Lua): creations dropped from 44 to 107 to 1 to 18 per 10 game seconds while the pool grew, then 1 (UnitEntryProbe's own dummy). Removals dropped from 59 to 95 to 1. Peak out was 30 to 82, and the fewest parked settled at 19 to 44. Castle Fight dummy-recycler-integrity runs on the lock bump.

The recycler kept eight angle queues of six and served a get only from the queue nearest the
requested angle, while recycle refilled the smallest queue. A map whose casts all ask for one
angle therefore had six usable dummies: in a Castle Fight late-game board, peaking at 97 dummies
out, the pool created 44 to 107 and removed 59 to 95 units per 10 game seconds while 42 dummies
stayed parked in the other queues.

One pool now serves every angle, and get snaps the facing with BlzSetUnitFacingEx. A set tracks
parked dummies, so isRecycled no longer scans every queue. DUMMY_RECYCLER_CAPACITY (128) and
DUMMY_RECYCLER_PRELOAD (48) are configurable. angleQueues is replaced by pool and parkedCount().
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 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-16T12:30:03.087589Z c84576f Manual request
ℹ️ 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.

@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: 004b0b2f5d

ℹ️ 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 thread wurst/dummy/DummyRecycler.wurst Resolved
HashSet keeps insertion order and shifts its tail on removal; ordered like the queue, it paid
that shift on every checkout. A Table-backed HashMap gives constant-time put, has and remove.
@Frotty

Frotty commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 40490a3950

ℹ️ 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".

A boolean array read replaces the hash lookup. Deindexing clears a slot, so a dummy removed while
parked leaves no flag for the next unit on its index, and createDummy indexes a dummy that entry
did not (a map whose shouldIndex refuses dummies, or the test runner).
@Frotty

Frotty commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: c84576fbb6

ℹ️ 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".

@Frotty
Frotty merged commit e2f93e2 into master Nov 16, 2026
2 checks passed
@Frotty
Frotty deleted the dummy-recycler-single-pool branch November 16, 2026 12:32
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