[Draft] Add trimmable typemap OTEL instrumentation#11502
Conversation
Instrument trimmable typemap startup and lookup operations with ActivitySource and Meter events, add buffered startup span replay for pre-listener operations, and wire the HelloWorld sample to export typemap telemetry through an Aspire AppHost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instrument the existing TypeManager-based LLVM-IR typemap path so JNI-name lookup, uncached native lookup, activation, and proxy creation can be compared directly with trimmable typemap spans. Allow the Aspire sample to switch typemap implementations via HELLOWORLD_ANDROID_TYPEMAP. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Updated the draft PR to include LLVM-IR typemap OTEL coverage as well: |
Break down the LLVM-IR activation and peer creation paths into nested spans so simple startup has enough telemetry for comparison. Capture a 10x LLVM-IR launch summary in the local OTEL data report. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Added more detailed LLVM-IR OTEL spans after the first smoke run showed too few events. The LLVM path now breaks activation into nested spans ( |
Add paired median comparisons for trimmable and LLVM-IR typemap startup spans, showing that the trimmable JNIEnv initialization delta is explained by typemap data initialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Draft instrumentation PR for trimmable typemap startup and steady-state performance investigation.
This adds:
Microsoft.Android.Runtime.TrimmableTypeMapActivitySource+Meterinfrastructure.jnienv.initialize,typemap.data.initialize,typemap.initialize, and native registration.OnRegisterNatives.duration.usspan attributes so we can get microsecond precision instead of relying on Aspire's integer millisecond duration fields.samples/TypemapOtelAspireAppHost + launcher script that builds, installs, startssamples/HelloWorld, forwards OTLP/HTTP throughadb reverse, and passes the Aspire dashboard OTLP API key to the Android app.samples/TypemapOtelAspire/README.mdexplaining how to run and inspect the data with Aspire.Findings from local measurements
Tracked separately in #11501.
Local Aspire/OTEL runs showed trimmable typemap data initialization is roughly 2/3 of the
JNIEnvInit.Initializebudget:jnienv.initialize: 99,591 ustypemap.data.initialize: 62,103 usRelated follow-up: #11473 packages ReadyToRun trimmable typemap assemblies. We should rerun these measurements after #11473 lands because missing R2R packaging may inflate the typemap initialization cost.
How to use with Aspire
From
samples/TypemapOtelAspireafter a localmake all:Then inspect telemetry with:
If the dashboard browser UI shows a Blazor circuit error while the CLI still returns traces, clear browser site data/cache for the dashboard URL or open in a private window.
Validation
git diff --checkbash -n samples/TypemapOtelAspire/run-helloworld-android.shmake allHelloWorldbuild/install/start through the Aspire resource.aspire otel traces --format Jsonconfirmed spans including:jnienv.initializetypemap.data.initializetypemap.initializetypemap.register_native_methodstypemap.lookup.*typemap.lookup.*.uncachedtypemap.type_manager.*typemap.peer.createtypemap.on_register_natives