Skip to content

Live reads: the bags family declines another family's question before reading the player - #3038

Closed
Berchia wants to merge 1 commit into
samwhosung:mainfrom
Berchia:perf/bags-decline-first
Closed

Berchia wants to merge 1 commit into
samwhosung:mainfrom
Berchia:perf/bags-decline-first

Conversation

@Berchia

@Berchia Berchia commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What changes

LiveReads::answer hands each live question to the families in order until one takes it. The bags family (BagLive) comes fourth. For every question, before it checked the question's type, it read:

  • the active player's store (Query::single),
  • the item-objects view (ViewStores::item_objects).

SelectionQuery and GroupRowsQuery are answered further down the list, by selection and roster. They pass through the bags family on every unit-token walk.

Bags::answer now returns false unless the question is one of the eight it answers. The check uses a new LiveAsk::is::<Q>(), which tests the question's type without answering it.

What stays the same

  • A bag or worn-slot question still reads the player and answers as it did.
  • With no player held, it still declines so a harness's copy answers.
  • Every other family's answer is unchanged.

No 1.12 behaviour changes: the getters read what they read before.

How to see it, before and after

Setup: a bags_cooldown_tests-style world with a SelfPlayer holding 16 backpack items, and eval_with_bags running UnitExists('target') 200,000 times. That asks SelectionQuery through the bags' reads. Dev profile, same machine:

per call
before 0.488 µs
after 0.369–0.383 µs

In the same world, GetContainerItemInfo(0, 1..16) still finds all 16 items.

Where it shows in play

The evidence is a Very Sleepy capture of a client built on benilla, 83 s late in a busy run, with names from a PDB of a nearby build:

  • ui_unit::field_events::fire → UiScript::unit_has_field_watchers / unit_tokens_of → live::ask → LiveReads::answer takes 9% of the main thread.
  • Bags::answer alone is 2.1% of the main thread: Query::single_inner, item_objects and their allocations.
  • Every one of those calls comes from a question the bags family does not answer.

Checks (Windows, without the client data)

  • rustfmt --check on both changed files: clean.
    • cargo fmt --all --check can't start on this machine because the workspace's command line exceeds Windows' length limit (os error 206).
  • cargo clippy -p benilla-ui -p benilla-app --all-targets -- -D warnings: clean.
    • The one warning printed comes from the wgpu-hal dependency (bind_cbv), not from benilla.
  • cargo test -p benilla-ui --lib: 3576 passed, 0 failed.
  • cargo test -p benilla-app --lib: 7764 passed, 0 failed.

@samwhosung

Copy link
Copy Markdown
Owner

Thanks. Your own #3041 overtook this one: a question now goes straight to the family that took its type, so the bags family is lent only for its own questions, and this check would add a second list of the bag questions that could drift from answer_held. Closing in favour of #3041.

@samwhosung samwhosung closed this Nov 22, 2026
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.

2 participants