PoC: log Tier-B visibility cache hit rate#15
Closed
Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
Closed
PoC: log Tier-B visibility cache hit rate#15Elton 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 Tier B short-circuit actually fires on production / staging traffic. No behaviour change, just a log line.Context
fb_isVisible(XCUIElement+FBIsVisible.m:47) is a three-tier cascade:additionalAttributes[FB_XCAXAIsVisibleAttribute](cached).fb_hasVisibleDescendantswalks_allDescendantsand short-circuits to YES if any of them has a cached-visible entry.The hypothesis is that Tier B 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:Adds
<stdatomic.h>andFBLogger.himports.Wraps
fb_hasVisibleDescendantswith process-wide_Atomic NSUIntegercounters forcallsandhits.Every 50 calls, emits one log line:
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 (no warming): hit rate near 0% — confirming Tier B 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] Tier-B stats: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.
🤖 Generated with Claude Code