Skip to content

Performance: Testing - Buy/Sell/Swap trade scenarios and profiling - #2507

Open
JohnathanWhite wants to merge 1 commit into
bitpay:developfrom
JohnathanWhite:perf/trade-harness
Open

JohnathanWhite wants to merge 1 commit into
bitpay:developfrom
JohnathanWhite:perf/trade-harness

Conversation

@JohnathanWhite

Copy link
Copy Markdown
Collaborator

Summary

The trade-flow half of the performance harness, on top of the perf framework merged in #2475. Tooling only — no app behaviour changes. The product-code optimisations these scenarios measure are in #2506.

What's here

  • Scenarios — perf/scenarios/trade_{buy,sell,swap}.yaml. Maestro flows that open Buy, Sell and Swap, choose coins and amounts, and let quotes load. They are read-only: nothing is confirmed, signed or submitted, and the flows never tap a provider's checkout.
  • Flow profiler — perf/loop/flowprofile.sh: a JS-CPU profile of a single flow.
  • Findings — perf/loop/FINDINGS-trade.md: root causes, baselines, the two REJECT→override calls (memory mode, CPU-as-a-rate), and parked follow-ups.
  • Loop/collector — perf/{cli,collector,config,compare,drivers/android,iterate}: per-scenario accepted runs, per-screen transition comparisons, coin-list and quote spans, and the process-memory mode recorded per run.
  • src/perf/PerfMonitor.ts — adds spanStart/spanEnd for sub-screen timing (currently unused by shipped screens; instrumentation can be wired in separately).
  • Android — PerfMarks/MainApplication: non-perf builds compile against the new startJsProfiler(context); perf marks for the profiler.

Notes

  • Based on develop after Android: perf - misc updates #2475 merged, so it stands alone.
  • PerfMonitor's new span API has no consumers in this PR by design — the Buy/Sell/Swap screens aren't instrumented here, keeping this PR tooling-only.

Jira: RN-3106

Adds the trade-flow half of the performance harness on top of the perf
framework from bitpay#2475: Maestro scenarios that drive Buy, Sell and Swap
read-only (quotes load, nothing is confirmed, signed or submitted),
per-scenario accepted runs and per-screen transition comparisons, a
JS-CPU flow profiler, the process-memory mode recorded per run, and the
trade findings.

- perf/scenarios/trade_{buy,sell,swap}.yaml - the three flows.
- perf/loop/flowprofile.sh - JS CPU profile of a flow.
- perf/loop/FINDINGS-trade.md - root causes, baselines, parked items.
- perf/{cli,collector,config,compare,drivers/android,iterate} - per-scenario
  runs, coin-list and quote spans, memory-mode recording.
- src/perf/PerfMonitor.ts - spanStart/spanEnd for sub-screen timing.
- Android PerfMarks/MainApplication - non-perf builds compile against the
  new startJsProfiler(context); perf marks for the profiler.

Jira: RN-3106
@JohnathanWhite JohnathanWhite changed the title perf harness: Buy/Sell/Swap trade scenarios and profiling Performance: Testing - Buy/Sell/Swap trade scenarios and profiling Nov 5, 2026

@cmgustavo cmgustavo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooling-only change; CI is green and nothing here is reachable from production builds. One item inline (receiver registration on Android 14+). Minor, unverified: readMemoryMb matches ^\s*Unknown:\s*(\d+). In dumpsys meminfo I'd expect "Unknown" as a table row without a colon and "Private Other" in the App Summary, so on some devices unknown_mb_start may come back null and the memory-mode check would silently not work. Worth confirming against raw output from the test phone.

}
}
}
context.registerReceiver(receiver, IntentFilter("com.bitpay.wallet.PERF_JS_PROFILE"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerReceiver(receiver, filter) without a flag throws SecurityException on Android 14+ for non-system actions (targetSdk is 36). It's called from Application.onCreate outside the try/catch, so a BP_PERF_PROFILE=1 build would crash on launch on API 34+ (it works on the Android 11 test phone). Also, adb shell am broadcast needs the receiver to be exported. Suggest context.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED) and moving the registration inside the try/catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants