Repository navigation
Avoid repeated selector walks and live UIA pattern probes - #450
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
:nth, and deduplication; later clauses reuse the same query-local snapshots instead of repeating provider calls. A unit test counts provider fetches across five clauses, including a child combinator and:nth.Motivation and measurements
sfmtool #647 reports that a GitHub-hosted Windows UIA tree walk took about 18.6 seconds; avoiding most accessibility walks cut its UI test from hundreds of seconds. sfmtool #653 reports a direct UIA walk of 52 nodes taking about 35 ms locally, supporting a large host/runner effect. This PR removes two xa11y costs that we can isolate locally, while the hosted-runner gap still needs an A/B run on that runner.
On this Windows machine, with the same 69-node AccessKit fixture and four warm runs:
The final tree output was identical across all 76 CLI lines before and after pattern caching, including actions and states. A separate direct UIA probe on 69 nodes found six live pattern acquisitions cost 40–62 ms, versus 9–11 ms when those patterns were prefetched; the number of supported patterns stayed at 37.
Validation
cargo clippy --workspace --all-targets -- -D warnings— passed.cargo test -p xa11y-windows— 81 passed.scripts/run_integ_tests_windows.ps1 selector_group_— 6 passed.SetForegroundWindowwas denied by the foreground lock,SendInputreturned error 5, and no process was reported foreground. Action, selector, value, and state tests passed.cargo xtask test-integreports that the command is unsupported on Windows; the Windows integration script above is the repository's runnable equivalent.cargo xtask checkpassed the Rust, JS, formatting, and parity checks, but could not finish its Python checks because this host Python lackspipandpytest.The deterministic provider-fetch assertion guards against another clause-count multiplier without a timing threshold that would be flaky on shared CI runners. The hosted Windows slowdown itself remains unreplicated locally and should be measured in CI before claiming an end-to-end fix for that environment.