[Browser][coreCLR] Enable EventPipe for CoreCLR#128745
Open
pavelsavara wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables CoreCLR EventPipe diagnostics for single-threaded Browser WASM by adjusting feature flags, generated eventing code, runtime EventPipe threading abstractions, GC diagnostics behavior, browser native relink behavior, and tracing tests.
Changes:
- Enables CoreCLR perf tracing/EventPipe paths for WASM and adapts generated eventing code to avoid LTTng/XplatEventLogger on Browser/WASI.
- Adds single-threaded EventPipe runtime stubs/queueing behavior and defers Browser GC collection requests through the diagnostic server job queue.
- Updates WASM/browser tracing tests to avoid out-of-process diagnostics dependencies and define browser-specific test constants.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/mono/browser/build/BrowserWasmApp.CoreCLR.targets |
Forces native relink when diagnostics are enabled for CoreCLR browser apps. |
src/libraries/System.Diagnostics.Tracing/tests/System.Diagnostics.Tracing.Tests.csproj |
Adjusts browser/android target detection and excludes EventPipeListener/package dependencies on browser. |
src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEvent.cs |
Guards EventPipeListener usage out of browser builds. |
src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWrite.cs |
Guards EventPipeListener usage out of browser builds. |
src/coreclr/vm/wks/CMakeLists.txt |
Propagates single-threaded perf tracing define to workstation GC VM objects. |
src/coreclr/vm/wasm/entrypoints.h |
Declares the browser diagnostic server job queue entrypoint for native CoreCLR code. |
src/coreclr/vm/wasm/callhelpers-reverse.cpp |
Adds reverse thunk support for EventPipeEventProvider.Callback. |
src/coreclr/vm/wasm/callhelpers-interp-to-managed.cpp |
Adds interpreter-to-managed thunk signatures needed by EventPipe event callbacks. |
src/coreclr/vm/gcenv.ee.cpp |
Allows GC heap walking for EventPipe builds without profiler support. |
src/coreclr/vm/eventtrace.cpp |
Adds Browser/WASI EventPipe-only provider contexts and excludes XplatEventLogger initialization. |
src/coreclr/vm/eventtrace_gcheap.cpp |
Defers browser diagnostic ForceGC requests through the event-loop job queue. |
src/coreclr/vm/eventtrace_bulktype.cpp |
Avoids firing Xplat bulk statics events on Browser/WASI while keeping EventPipe emission. |
src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h |
Adds single-threaded wait-event/thread/job behavior for CoreCLR EventPipe. |
src/coreclr/vm/eventing/eventpipe/CMakeLists.txt |
Defines perf tracing symbols for EventPipe object targets and propagates single-threaded mode. |
src/coreclr/vm/eventing/CMakeLists.txt |
Makes eventing header dependencies conditional and preserves EventPipe subdirectory inclusion. |
src/coreclr/scripts/genEventPipe.py |
Emits nullptr provider callbacks when CoreCLR EventTrace is unavailable. |
src/coreclr/scripts/genEventing.py |
Generates Browser/WASI-safe EventPipe-only eventing structures and guards Xplat event emission. |
src/coreclr/interpreter/CMakeLists.txt |
Propagates single-threaded perf tracing define to interpreter objects. |
src/coreclr/inc/eventtracebase.h |
Defines Browser/WASI EventPipe-only tracing macros and excludes XplatEventLogger classes. |
src/coreclr/clrfeatures.cmake |
Enables EventTrace for browser and perf tracing when single-threaded perf tracing is requested. |
src/coreclr/clrdefinitions.cmake |
Defines FEATURE_PERFTRACING without requiring FEATURE_EVENT_TRACE and adds cross-component dummy headers target. |
src/coreclr/clr.featuredefines.props |
Removes the WASM managed FeaturePerfTracing=false override. |
This was referenced May 29, 2026
Open
This was referenced May 29, 2026
maraf
approved these changes
May 29, 2026
Member
maraf
left a comment
There was a problem hiding this comment.
Parts I'm familiar with looks good to me 👍
jkotas
reviewed
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR enables the EventPipe diagnostics infrastructure for CoreCLR running on single-threaded Browser WASM.
It will probably increase size of the .wasm file.
It is split from #126324 for smaller code review.
Remaining parts are the CPU sampling instrumentation and unit tests.
Changes
Feature enablement
FeaturePerfTracing=falseoverride for WASM inclr.featuredefines.props. Previously EventPipe was disabled for CoreCLR on WASM pending single-threaded implementation.clrfeatures.cmaketo enableFEATURE_PERFTRACINGwhenFEATURE_PERFTRACING_DISABLE_THREADSis set (not just whenFEATURE_EVENT_TRACEis set).clrdefinitions.cmaketo defineFEATURE_PERFTRACINGin theelseif(FEATURE_PERFTRACING)case (EventPipe without full ETW event tracing).Single-threaded EventPipe runtime (
ep-rt-coreclr.h)PERFTRACING_DISABLE_THREADS— usesINVALID_HANDLE_VALUEas an "allocated" sentinel.ep_rt_thread_createstub that hitsEP_UNREACHABLE.ep_rt_queue_jobimplementation forHOST_BROWSER— invokes the job callback inline and reschedules viaSystemJS_DiagnosticServerQueueJobif the job returns "not done".ep_rt_thread_sleepa no-op underPERFTRACING_DISABLE_THREADS.PERFTRACING_DISABLE_THREADScompile definition toeventpipe_objs,eventpipe_gen_objs,cee_wks_core, andclrinterpreter_objectstargets.Eventing / ETW adaptations for Browser
HOST_BROWSER/HOST_WASIin generated eventing code (genEventing.py) and runtime (eventtrace.cpp).DOTNET_TRACE_CONTEXTstruct for Browser/WASI (EventPipe-only, no LTTng context).ETW_EVENT_ENABLED/ETW_TRACING_ENABLEDmacros to avoid referencing LTTng on Browser/WASI (eventtracebase.h).nullptrcallback toCreateProviderwhenFEATURE_EVENT_TRACEis not defined (genEventPipe.py).EventPipeEventProvider.Callbackreverse-call helper for managed provider callbacks (callhelpers-reverse.cpp).callhelpers-interp-to-managed.cpp).GC diagnostics deferral
ForceGC(triggered by the GCHeapCollect keyword) cannot run synchronously during the provider callback. Deferred to the next event loop turn viaSystemJS_DiagnosticServerQueueJob(eventtrace_gcheap.cpp).GC profiling fix
DiagGCEndto callGCProfileWalkHeapwhenFEATURE_EVENT_TRACEis defined (not onlyGC_PROFILING), enabling GC heap walk events on platforms without profiling support (gcenv.ee.cpp).Build integration
BrowserWasmApp.CoreCLR.targets: auto-enable native relink (WasmBuildNative=true) whenEnableDiagnostics=true.Test adjustments
EventPipeListenertest harness and TraceEvent/DiagnosticsClient NuGet packages from the browser test build (these require out-of-process diagnostics, not available in-browser).EventPipeListenerusage inTestsWrite.cs/TestsWriteEvent.cswith#if !TARGET_BROWSER.TARGET_BROWSERdefine andWASM0066warning suppression to the test project.