Skip to content

Add automated release-build startup benchmarking #98280

Description

@mountiny

Background

Sentry spans give useful timing data, but release builds strip normal console logging, release behavior differs from development builds, and Android and iOS need different tooling to launch apps and collect logs.

Problem

Startup performance work is currently evaluated with ad hoc measurements that vary by developer, platform, device, and build. Results are therefore hard to reproduce or compare, which makes it difficult to tell whether a change improves typical and tail startup times or introduces a regression.

Solution

Add opt-in structured logging for selected Sentry spans plus a reusable Android/iOS benchmark script that:

  • Runs repeated process or true-cold startups.
  • Collects span durations automatically.
  • Records raw samples.
  • Reports Average, P50, P75, P90, P95, and P99.
  • Shares device tooling with future PGO and flow benchmarks.
  • Allows configuring the number of runs, device, app bundle, and similar options.

How the draft implements this

  • Developers list the exact span names to measure in the git-ignored root .env via EXPO_PUBLIC_BENCHMARK_SENTRY_SPANS.
  • Successful, non-canceled allowlisted spans emit a flat machine-readable [EXPENSIFY_BENCHMARK] JSON event. It uses console.warn because lower console levels are stripped from release bundles, and since the app's Sentry console integration forwards only errors, these lines create no Sentry events and no network traffic.
  • scripts/benchmarkAppStartup.ts runs under Bun against an Android device or a physical iOS device, supporting --span, --device, process and true-cold modes, configurable run counts, timeouts and app identifiers, CSV output, and P50/P75/P90/P95/P99 statistics. It prints its full resolved configuration before running.
  • Shared Android adb and iOS xcrun devicectl behavior lives in scripts/lib/nativeAppBenchmark.ts, so the benchmark workflow can be reused by PGO tooling without duplicating device operations or statistics.
  • contributingGuides/BENCHMARKING.md documents release configuration, local benchmark commands, true-cold behavior, and PGO integration.

The timestamp clock-domain correctness change is deliberately out of scope and will follow in a separate PR.

Draft PR

#98144

Slack discussion

https://expensify.slack.com/archives/C05LX9D6E07/p1786379259283529

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status
CRITICAL

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions