Accelerating our Android apps with Baseline Profiles
Meta generates Android Baseline Profiles from production class-load and method-usage data to trigger ART install-time AOT compilation and app image creation, improving startup, scroll and navigation metrics by 3% to 40% across its apps. Cloud Profiles fell short because they help only later users in a rollout, give developers no control, are skewed toward early startup (ART treats startup as done after five seconds), and work only through Google Play. Meta samples class loads through a custom ClassLoader at a very low rate, adds method-cluster telemetry, keeps entries that appear above a frequency threshold, and feeds a human-readable profile to profgen. The inclusion threshold started at 80–90% of traces to limit code-size and memory-pressure costs, since compiled code is about 10x larger than dex. It has since dropped to 20%, and profiles now hold tens of thousands of entries.
Related posts
- Android profiling now uses Perfetto via ProfilingManager
Sentry mediumAdeptSentry Android SDK 8.51.0 switches profiling on Android 15+ (API 35+) from in-process Debug.startMethodTracing to Perfetto-based stack sampling via the system ProfilingManager API, while older devices fall back to the legacy profiler. Running out of process avoids an ART tracer crash triggered by native threads that exit without detaching, shifts most CPU and memory overhead into a system process, and yields more representative profiles. Android rate-limits profiling requests, so even a 1.0 session sample rate won't capture every session; an adb device_config flag disables the limit for local testing, and a new enableLegacyProfiling option can be set to false to avoid the legacy tracer entirely.
- The Sentry Android SDK is now 20-30% faster!
Sentry mediumAdeptSentry's Android SDK init time dropped 20-30% between versions 8.43.0 and 8.54.0, alongside reduced memory allocation, fixed leaks and up to 10% less background CPU. The team found bottlenecks with Perfetto traces and validated over 40 changes with Android Macrobenchmark on a clock-locked Pixel 3. Highlighted changes: the Gradle plugin writes manifest options and class-availability checks into bytecode at build time, avoiding manifest parsing and reflection (6.5% gain); a custom DSN parser replaces java.net.URI (6ms down to 1µs); and one-off threads move to shared executor pools, saving 3MB of heap from ART's 1MB thread stacks. Upgrading to SDK 8.54.0+ and Gradle plugin 6.20.0+ is enough to get the gains.
- Strobelight: A profiling service built on open source technology
Meta Engineering mediumAdeptStrobelight is Meta's fleet-wide profiling orchestrator, running 42 profilers (mostly eBPF-based, plus ad-hoc bpftrace scripts) on every production host with safeguards against PMU counter conflicts, concurrency limits and queuing. Default continuous profiling uses dynamic sampling that retunes run probability daily per service to hit target sample counts, with sample weights normalizing data for cross-host and cross-service comparison. LBR data feeds Meta's FDO pipeline (CSSPGO and BOLT), cutting CPU cycles up to 20% for top services, and one efficiency win alone saved an estimated 15,000 servers annually. Stack Schemas and thread-local Strobemeta enrich stacks with tags and request metadata, while a centralized symbolization service built on DWARF, gsym and blazesym avoids on-host debug-info parsing, relying on frame pointers in all user-space binaries.
- How we wrote a Python profiler
Datadog Engineering mediumAdeptDatadog built an always-on statistical profiler for Python because deterministic profilers like cProfile can add 2-3x overhead, too much for production. The design borrows from JDK Flight Recorder and splits into recorder, collectors, exporter and scheduler. A Cython-based stack collector samples every thread's stack 100 times per second and lowers its polling rate under heavy load to cap overhead. Memory and lock collectors add allocation and lock-contention data, and profiles are aggregated into compact pprof (protobuf) files uploaded every minute through the Datadog Agent.
- An open source compositional deadlock detector for Android Java
Meta Engineering hardMasterMeta built a compositional static analyzer, now part of the open source Infer framework, that detects deadlocks in Android Java code without running it. Using abstract interpretation, it summarizes each method once in terms of "critical pairs": which lock it acquires while already holding a given set of locks, plus whether it runs on the main or a background thread. To scale to codebases with hundreds of millions of lines, it analyzes only the methods in a revision's modified files, then uses a heuristic to find outside methods that could deadlock with them. Deployed in CI on every commit to Meta's Android apps, it has led to over 200 fixes at about a 54% fix rate, and the analysis is proven sound and complete for an abstract language with non-deterministic control.