agents/skills/analyzing-sql-traces/references/cognitive_principles.md
This document defines the core reasoning principles used by the SQL Trace Analyzer Agent (SQL-TAA) to identify, evaluate, and prioritize performance bottlenecks in Chromium traces. These rules ensure the agent applies deep architectural judgment rather than relying on naive duration sorting.
We do not ignore a method simply because its "self-time" is zero or
near-zero. If a high-level method (e.g., RevertAll, Navigate) has a
significant total duration (e.g., $> 20\text{ ms}$ or $> 10%$ of the focus
slice), we must treat its entire subtree as a Unified Performance Flow.
When analyzing a Flow, the agent must look for three types of inefficiencies:
While relative overhead ($V_{ro} = \text{dur}(Slice) / \text{dur}(Root)$) is useful for ranking, absolute UI-thread blocking time is what directly impacts the user experience.
CrBrowserMain), it MUST be
flagged as a bottleneck and a Tracer Gap (Partial/Absolute Black Box).OmniboxViewViews::SetWindowTextAndCaretPosIn the OpenMatch trace, this method appears as:
* [ 18.983 ms ( 7.3%) | self: 12.719 ms ( 4.9%)] OmniboxViewViews::SetWindowTextAndCaretPos
12.72 ms on the UI thread. This is a massive silent block that blocks
the UI thread for almost a full frame.GAP_INSTRUMENTATION.The agent must evaluate the semantic intent of a method name against its actual cost (self-time or leaf duration).
UpdateIcon, GetPrefs, RecordMetrics, DidStartLoading,
IsReady, NotifyObservers), but it takes $> 1.0\text{ ms}$ (Release) or $>
2.0\text{ ms}$ (Developer/Debug builds):
Redundancy must be analyzed at two different tiers of the architecture:
KeyedServiceFactory::GetServiceForContext called
1,196 times, taking 23.7 ms cumulatively).RevertAll called 3 times globally,
costing 111.5 ms).When analyzing user journeys containing multiple occurrences of the focus entrypoint slice, the agent must evaluate latency using both aggregated and single-instance perspectives:
RenderProcessHostImpl::Init taking 12ms but called only 1 time across 8
navigations).ShouldSwapBrowsingInstancesForNavigation
called 8 times, taking 1.7ms average per call, totaling 13.5ms cumulative).When profiling user journeys and performance regressions, the primary goal is to optimize browser application logic rather than debugging or modifying the system's scheduling infrastructure (e.g., ThreadPool scheduling, Mojo IPC internals, Tracing overhead).
Generic scheduling and waiting slices often dominate duration deltas in reports, creating noise. The agent must apply the following guidelines to focus on browser logic:
In the first run, ignore generic infrastructure slices representing scheduling, waiting, or tracing mechanics:
WorkerThread active, ThreadPool_RunTask,
ThreadController active, ThreadControllerImpl::RunTask.Receive mojo::..., Closed mojo endpoint,
FusePipes, Connector::Accept.StartupTracingController::Start,
perfetto::..., TracingControllerImpl::....ScopedBlockingCall, WaitableEvent::Wait,
ScopedAllowBaseSyncPrimitives....If you must work on an infrastructure bottleneck, perform a careful validation (e.g. comparing the bottleneck's presence vs. absence across multiple individual runs) to confirm whether the block is a stable cause of the regression or merely statistical noise.
Direct your primary investigation to application logic under these key categories:
In the final analysis report, all infrastructure-related findings or recommendations MUST be presented as Optional/Secondary. Focus the primary recommendations on browser application logic.