Skip to content

PoC: log Tier-B visibility cache hit rate#15

Closed
Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
masterfrom
poc/log-tier-b-cache-hits
Closed

PoC: log Tier-B visibility cache hit rate#15
Elton Carreiro (EltonCarreiro) wants to merge 1 commit into
masterfrom
poc/log-tier-b-cache-hits

Conversation

@EltonCarreiro
Copy link
Copy Markdown

Summary

Pure-observability PR — adds logging to fb_hasVisibleDescendants so 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:

  • Tier A — read additionalAttributes[FB_XCAXAIsVisibleAttribute] (cached).
  • Tier Bfb_hasVisibleDescendants walks _allDescendants and short-circuits to YES if any of them has a cached-visible entry.
  • Tier C — synchronous AX-framework IPC. The expensive one.

The hypothesis is that Tier B almost never fires in the standard /source path 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> and FBLogger.h imports.

    • Wraps fb_hasVisibleDescendants with process-wide _Atomic NSUInteger counters for calls and hits.

    • Every 50 calls, emits one log line:

      [VisCache] Tier-B stats: calls=… hits=… (XX.X%) lastWalked=… lastResult=YES/NO
      
  • 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 /source path 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

  1. Build/install on a runner.
  2. Tail Appium/WDA logs.
  3. Issue a few GET /source calls against a representative app/screen.
  4. Grep for [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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant