PoC: log fb_hasVisibleDescendants hit rate#16
Draft
Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
Draft
PoC: log fb_hasVisibleDescendants hit rate#16Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
Conversation
Add observability to the fb_hasVisibleDescendants short-circuit by instrumenting cache hit/miss counters. Track calls and hits using atomic operations, logging statistics every 50 calls to measure cache effectiveness without impacting performance. Include last walk depth and result in logs to aid debugging on dense screens. No behavioral changes. Co-Authored-By: Claude <noreply@anthropic.com>
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
Pure-observability PR — adds logging to
fb_hasVisibleDescendantsso we can measure how often the descendant-cache shortcut actually fires on production / staging traffic. No behaviour change, just a log line.Supersedes #15 (closed when the branch was renamed off internal shorthand).
Context
fb_isVisible(XCUIElement+FBIsVisible.m) resolves visibility through three paths:additionalAttributes.fb_hasVisibleDescendants) that returns YES if any of the element's descendants is already cached as visible — skipping the expensive AX call.The hypothesis is that the descendant shortcut almost never fires in the standard
/sourcepath because nothing pre-populates the cache before XML generation runs. This PR confirms or refutes that hypothesis with hard data.Changes
WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m:<stdatomic.h>andFBLogger.himports.fb_hasVisibleDescendantswith process-wide_Atomic NSUIntegercounters for calls and hits.calls/hits/ hit rate / last-walk depth / last result.Counters are process-wide, not per-request — they accumulate over the lifetime of the runner. Comparing hit rate before/after a workload is a simple subtract.
What we expect to see
Baseline: hit rate near 0% — confirming the shortcut is dead code in the standard
/sourcepath because the cache is never pre-populated.If the rate turns out to be meaningfully > 0%, that's a surprise and worth investigating before we invest in pre-warming variants.
How to test
GET /sourcecalls against a representative app/screen.[VisCache]and read the hit rate.Why this as its own PR
Separated from #14 (visibility-cache pre-warming PoC) so it can land independently and give us data on master before we commit to the larger change. Safe to merge — no behaviour change, just logging.
Note on terminology
The code/comments shipped in this PR still carry some internal shorthand from the design discussion ("Tier B short-circuit",
[VisCache] Tier-B stats:log prefix). That phrasing isn't meaningful outside the design conversation and will be cleaned up before this lands; please mentally substitute "descendant-cache shortcut" wherever you see it.🤖 Generated with Claude Code