Diagnose and optimize OneKey iOS startup and Wallet Home performance using timing metrics, call counts, profiling, and regression baselines.
64
76%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.skillshare/skills/1k-perf-optimizer/SKILL.mdSystematic workflow for diagnosing and fixing performance issues in the OneKey mobile app using the perf-ci infrastructure and performance-server tooling.
This skill provides a structured iterative approach to:
Key Metrics:
tokensStartMs: Time when Home tokens refresh starts (lower is better)tokensSpanMs: Duration of Home tokens refresh (lower is better)functionCallCount: Total function calls during session (lower is better)Success Criteria:
Ask user to choose a baseline session or help them select one:
# List recent sessions with key metrics
cat ~/perf-sessions/sessions.overview.jsonl | \
jq -r '[.sessionId, .createdAt, .marks["Home:refresh:done:tokens"]] | @tsv' | \
tail -20User can specify:
Extract baseline metrics from the session:
# Get detailed analysis
node development/performance-server/cli/derive-session.js <baseline-sessionId> \
--pretty \
--output /tmp/perf-baseline-derived.jsonRead baseline metrics from ~/perf-sessions/<sessionId>/mark.log:
# Extract tokensStartMs (timestamp of Home:refresh:start:tokens)
grep "Home:refresh:start:tokens" ~/perf-sessions/<sessionId>/mark.log | jq '.timestamp'
# Extract tokensSpanMs (done - start)
grep "Home:refresh:done:tokens" ~/perf-sessions/<sessionId>/mark.log | jq '.timestamp'
# Count function calls
wc -l < ~/perf-sessions/<sessionId>/function_call.logCreate baseline metrics JSON for comparison:
echo '{"tokensStartMs": <start>, "tokensSpanMs": <span>, "functionCallCount": <count>}' > /tmp/baseline-metrics.jsonCreate session document at development/output/perf-optimization-<timestamp>.md using the template from references/template.md. Fill in:
Maximum iterations: 10
For each iteration (run in a sub-agent):
The perf script automatically runs 3 times and aggregates results:
node development/perf-ci/run-ios-perf-detox-release.jsOutput location: development/perf-ci/output/<jobId>/
report.json - Contains aggregated results in agg fielddetox/runs.json - Contains individual run sessionIdsExtract current metrics from report.json:
# Read aggregated metrics directly
cat development/perf-ci/output/<jobId>/report.json | jq '{
tokensStartMs: .agg.tokensStartMs,
tokensSpanMs: .agg.tokensSpanMs,
functionCallCount: .agg.functionCallCount
}' > /tmp/current-metrics.jsonFor deeper analysis, run derive-session on individual sessions:
# Get sessionIds from the run
SESSIONS=$(cat development/perf-ci/output/<jobId>/detox/runs.json | jq -r '.runs[].sessionId')
# Analyze each session
for sid in $SESSIONS; do
node development/performance-server/cli/derive-session.js $sid \
--pretty \
--output /tmp/perf-derived-$sid.json
doneFocus on these sections in the derived output:
Identify top 1-3 bottlenecks that are:
Compare current metrics to baseline:
# Quick comparison
cat /tmp/baseline-metrics.json
cat /tmp/current-metrics.json
# Calculate deltas manually or use script in skill directoryDecision tree:
If current metrics show improvement over baseline:
If no improvement yet:
If iteration count reaches 10:
Based on analysis, make ONE targeted change per iteration:
Change types:
Guidelines:
Adding perfMarks:
Use the performance utilities in packages/shared/src/performance/:
import { perfMark } from '@onekeyhq/shared/src/performance/perfMark';
// Add mark at a specific point
perfMark('MyComponent:operation:start');
// ... operation ...
perfMark('MyComponent:operation:done');Naming convention: <Component>:<action>:<phase> (e.g., Home:refresh:start:tokens)
If adding perfMarks for investigation:
Update the session document with:
If any iterations resulted in MINOR_IMPROVEMENT:
git checkout -b perf/minor-<description>
git add <changed-files>
git commit -m "perf: <description>
Reduces function call count by X% while maintaining time metrics.
Reason: <brief explanation>
"
git checkout <original-branch>
git restore .Document the branch name in the session document.
Fill in the Summary section:
Perf Infrastructure:
development/perf-ci/run-ios-perf-detox-release.js - Main perf runnerdevelopment/perf-ci/output/<jobId>/ - Job output directorydevelopment/performance-server/cli/derive-session.js - Session analyzer~/perf-sessions/ - Session data storage (default)~/perf-sessions/sessions.overview.jsonl - Session indexThresholds:
development/perf-ci/thresholds/ios.release.json - Release mode thresholdsPerformance Utilities:
packages/shared/src/performance/perfMark.ts - Performance marking utilityd71e6b7
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.