Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm-ep] Can't have both runtime and EventSource event providers in the same session #69568

Open
Tracked by #69268
lambdageek opened this issue May 19, 2022 · 2 comments
Labels
arch-wasm WebAssembly architecture area-Tracing-mono enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@lambdageek
Copy link
Member

lambdageek commented May 19, 2022

Depends on #69567

Specifying both an EventSource and one of the runtime providers (e.g. "Microsoft-Windows-DotNETRuntime") on the same session only captures runtime events and not the EventSource events

Repro:

modify the browser-eventpipe sample and change

        const options = MONO.diagnostics.SessionOptionsBuilder
            .Empty
            .setRundownEnabled(false)
            .addProvider({ name: 'WasmHello', level: MONO.diagnostics.EventLevel.Verbose, args: 'EventCounterIntervalSec=1' })
            .build();

to

        const options = MONO.diagnostics.SessionOptionsBuilder
            .DefaultProviders
            .setRundownEnabled(true)
            .addProvider({ name: 'WasmHello', level: MONO.diagnostics.EventLevel.Verbose, args: 'EventCounterIntervalSec=1' })
            .build();

and collect a trace. note that there are no EventCounters events in the resulting .nettrace file.

@lambdageek lambdageek mentioned this issue May 19, 2022
22 tasks
@ghost ghost added the untriaged New issue has not been triaged by the area owner label May 19, 2022
@lambdageek lambdageek changed the title Specifying both an EventSource and one of the runtime providers (e.g. <code class="notranslate">"Microsoft-Windows-DotNETRuntime"`) on the same session only captures runtime events and not the EventSource events [wasm-ep] Can't have both runtime and EventSource event providers in the same session May 19, 2022
@lambdageek lambdageek added this to the 7.0.0 milestone May 19, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 19, 2022
@lambdageek lambdageek self-assigned this May 19, 2022
@radical radical added the arch-wasm WebAssembly architecture label May 31, 2022
@ghost
Copy link

ghost commented May 31, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Depends on #69567

Specifying both an EventSource and one of the runtime providers (e.g. "Microsoft-Windows-DotNETRuntime") on the same session only captures runtime events and not the EventSource events

Repro:

modify the browser-eventpipe sample and change

        const options = MONO.diagnostics.SessionOptionsBuilder
            .Empty
            .setRundownEnabled(false)
            .addProvider({ name: 'WasmHello', level: MONO.diagnostics.EventLevel.Verbose, args: 'EventCounterIntervalSec=1' })
            .build();

to

        const options = MONO.diagnostics.SessionOptionsBuilder
            .DefaultProviders
            .setRundownEnabled(true)
            .addProvider({ name: 'WasmHello', level: MONO.diagnostics.EventLevel.Verbose, args: 'EventCounterIntervalSec=1' })
            .build();

and collect a trace. note that there are no EventCounters events in the resulting .nettrace file.

Author: lambdageek
Assignees: lambdageek
Labels:

arch-wasm, area-Tracing-mono

Milestone: 7.0.0

lambdageek added a commit that referenced this issue Jun 1, 2022
…sionOptions builder to TS (#69567)

1. Implements support for creating event counters in WebAssembly apps.
   **Important change** adds `Thread.IsInternalThreadStartSupported` and `Thread.InternalUnsafeStart()` to `System.Threading.Thread` that can be used by System.Private.CoreLib to start threads on a runtime where `Thread.IsThreadStartSupported` is false.
   This is used to create the event counters polling thread.
   This is in addition to the native runtime being able to create threads using `mono_thread_create_internal`
2. Coop thread suspend: STW calls `mono_threads_platform_stw_defer_initial_suspend` which postpones suspending a thread until the next GC suspend phase.  Doesn't do anything on most platforms.  On WASM, suspend the main browser thread after all the other threads are suspended. This helps prevent deadlocks where the main thread is suspended while another thread is doing a call that is proxied to the main thread and cannot complete.  By suspending the main thread last, we give it a chance to service the other threads' requests.
2. Adds a `MONO.diagnostics.SessionOptionsBuilder` class that can be used to create an `EventPipeSessionOptions` instance and populate the provider string for an event pipe session.
3. Updated the `browser-eventpipe` sample to create an EventSource and some counters.  The sample is now interactive so you have to click "Start Work" in a browser for things to happen.

There's an outstanding issue #69568 that will be investigated in a follow-up PR

* Add custom EventSource and counter

   - Added a method for coop GC to suspend the main browser thread in the second phase (so that other threads are less likely to deadlock if they delegate work to it)

   - Added an event provider builder

   - Added a Thread.InternalUnsafeStart() method and a IsInternalThreadStartSupported property.  This allows EventSource to start a thread to poll the counter values.

   - The sample with counters can now record counter values.  But not at the same time as the default configuration (runtime, runtime private, sample profiler).  Not sure if it's a wasm issue or a limitation of EventPipe.

* Change ProvidersConfigBuilder to SessionOptionsBuilder

   it creates an entire EventPipeSessionOptions object, not just the providers config

* checkout interactive demo

* Add docs; fix whitespace

* more whitespace fixes

* add default arg value to ThrowIfNoThreadStart

* fix build

* Review feedback
@lambdageek lambdageek removed their assignment Jul 5, 2022
@radical
Copy link
Member

radical commented Aug 12, 2022

@lambdageek I'm assuming this should be moved to 8.0 .

@radical radical modified the milestones: 7.0.0, 8.0.0 Aug 12, 2022
@lewing lewing modified the milestones: 8.0.0, 9.0.0 Jul 22, 2023
@mdh1418 mdh1418 added the enhancement Product code improvement that does NOT require public API changes/additions label Mar 12, 2024
@ilonatommy ilonatommy modified the milestones: 9.0.0, Future Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Tracing-mono enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

5 participants