agents/skills/latency-instrumentation/SKILL.md
This skill guides the agent through surgically injecting TRACE_EVENT macros
into Chromium C++ files to break down uninstrumented main-thread blocking gaps
("black boxes") and verifying the changes via an automated compilation loop.
This skill is strictly for data collection and instrumentation. You MUST NOT make any performance optimization or refactoring changes (such as caching, background-thread offloading, or logic restructuring). Your sole purpose is to add instrumentation to help the Trace Analyzer drill down into untraced gaps.
Before executing this skill, you must have:
target_method: The fully qualified C++ method name (e.g.
LocationIconView::Update).category: The trace category (e.g., "omnibox", "navigation").instructions: Step-by-step C++ trace injection instructions (e.g.,
identifying loops or blocks to wrap).parent_session_id: The unique session ID.git cl format immediately
after editing.git reset --hard HEAD to cleanly restore the last
successful iteration's checkpoint.Use the codesearch tool to find the .cc and .h files declaring the
target_method. Example:
lang:cpp "LocationIconView::Update"
If remote search yields zero results (common for unsubmitted local edits), run local ripgrep:
rg -n --type cpp "LocationIconView::Update"
Read the files using view_file.
Analyze the C++ source file to find the exact start and end lines of the
target_method. Take care to match namespace scope, class qualifiers, and
specific overloads.
{
TRACE_EVENT0("category", "ParentMethodName::SubBlockName");
// original code block
}
#include "base/trace_event/trace_event.h" is present at the top
of the C++ file. If missing, inject it programmatically inside the include
section.sed or cat << 'EOF'.git cl format <modified_files> via run_command to format the code.You are allowed up to 3 total compilation attempts to resolve any syntax, missing include, or structural errors:
autoninja to compile:
autoninja -C out/Default chrome
git add <modified_files> (add files manually, avoid wildcards).git commit -m "feat(e2e-nla): Instrument [target_method]" to
checkpoint your progress.stderr output.autoninja.git reset --hard HEAD to revert all uncommitted modifications back to the
last successful checkpoint (preserving previous successful iterations), and
report failure.Report back with a JSON payload matching this structure:
{
"status": "SUCCESS" | "FAILED",
"modified_files": ["chrome/browser/...cc"],
"compile_output": "Compiler logs or error details"
}