-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm-ep] Minimal diagnostic tracing configuration and sample #69158
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
8166db7
add DISABLE_WASM_USER_THREADS mono cmake option
lambdageek a4dd0a8
Disable Thread.StartInternal icall if DISABLE_WASM_USER_THREADS
lambdageek 3f6af6f
add an eventpipe sample
lambdageek cc7162f
[wasm-ep] (browser-eventpipe sample) run loop for longer
lambdageek f269cee
[samples/wasm-eventpipe] make an async task sample
lambdageek 18f73b9
[wasm] Add MONO.diagnostics interface
lambdageek 75d33cb
if wasm threads are disabled, but perftracing is enabled, don't log
lambdageek 327502d
fix whitespace and nits
lambdageek fafeced
don't need try/finally in the sample anymore
lambdageek 252d06a
more whitespace
lambdageek 8b54aab
add start method to EventPipeSession interface
lambdageek e2e1b66
don't run wasm-eventpipe sample on CI lanes without perftracing
lambdageek ded3aeb
more whitespace
lambdageek 46c1a7c
fix eslint warnings, default rundown to true, allow callback for trac…
lambdageek c29915d
add EventPipeSession.getTraceBlob and EventPipeSession.getTraceDataURI
lambdageek 8287396
[browser-eventpipe sample] remove unnecessary ref assemblies
lambdageek a7bd41b
use toBase64StringImpl instead of btoa
lambdageek be8d199
use int64_t for event pipe session IDs
lambdageek 63190bd
use ep_char8_t for C decls of event pipe wasm exports
lambdageek 4c50aa6
fix debug output
lambdageek a67ecd4
fix endianness issue
lambdageek f0577f4
Use stack allocation for temporaries
lambdageek 99f2ddf
Use 32-bit EventPipe session ID on WASM
lambdageek cdf8909
Make the sample do more work in managed
lambdageek 9c70c5c
Move withStackAlloc to memory.ts
lambdageek 5af5b80
fix option description
lambdageek 8fcb319
simplify VFS .nettrace file naming
lambdageek a3d681c
Add overloads to memory.withStackAlloc to avoid creating closures
lambdageek 173081c
sample: explain why there's a 10s pause
lambdageek f07daea
move createEventPipeSession callback to a function
lambdageek 61dbd2f
Merge remote-tracking branch 'origin/main' into wasm-ep
lambdageek 886df1b
Merge branch 'main' into wasm-ep
lambdageek 19f9659
fix whitespace
lambdageek c16d22c
Use a tuple type for withStackAlloc
lambdageek dc1dbad
fix whitespace
lambdageek 82ba6c4
go back to explicit args for withStackAlloc insead of rest/spread
lambdageek aed3660
use unsigned 32-bit get/set in cuint64 get/set
lambdageek 0a7381d
cosmetic changes to sample
lambdageek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // | ||
|
|
||
| #ifndef _MONO_COMPONENT_EVENT_PIPE_WASM_H | ||
| #define _MONO_COMPONENT_EVENT_PIPE_WASM_H | ||
|
|
||
| #include <stdint.h> | ||
| #include <eventpipe/ep-ipc-pal-types-forward.h> | ||
| #include <eventpipe/ep-types-forward.h> | ||
| #include <glib.h> | ||
|
|
||
| #ifdef HOST_WASM | ||
|
|
||
| #include <emscripten.h> | ||
|
|
||
| G_BEGIN_DECLS | ||
|
|
||
| #if SIZEOF_VOID_P == 4 | ||
| /* EventPipeSessionID is 64 bits, which is awkward to work with in JS. | ||
| Fortunately the actual session IDs are derived from pointers which | ||
| are 32-bit on wasm32, so the top bits are zero. */ | ||
| typedef uint32_t MonoWasmEventPipeSessionID; | ||
| #else | ||
| #error "EventPipeSessionID is 64-bits, update the JS side to work with it" | ||
| #endif | ||
|
|
||
| EMSCRIPTEN_KEEPALIVE gboolean | ||
| mono_wasm_event_pipe_enable (const ep_char8_t *output_path, | ||
| uint32_t circular_buffer_size_in_mb, | ||
| const ep_char8_t *providers, | ||
| /* EventPipeSessionType session_type = EP_SESSION_TYPE_FILE, */ | ||
| /* EventPipieSerializationFormat format = EP_SERIALIZATION_FORMAT_NETTRACE_V4, */ | ||
| /* bool */ gboolean rundown_requested, | ||
| /* IpcStream stream = NULL, */ | ||
| /* EventPipeSessionSycnhronousCallback sync_callback = NULL, */ | ||
| /* void *callback_additional_data, */ | ||
| MonoWasmEventPipeSessionID *out_session_id); | ||
|
|
||
| EMSCRIPTEN_KEEPALIVE gboolean | ||
| mono_wasm_event_pipe_session_start_streaming (MonoWasmEventPipeSessionID session_id); | ||
|
|
||
| EMSCRIPTEN_KEEPALIVE gboolean | ||
| mono_wasm_event_pipe_session_disable (MonoWasmEventPipeSessionID session_id); | ||
|
|
||
| G_END_DECLS | ||
|
|
||
| #endif /* HOST_WASM */ | ||
|
|
||
|
|
||
| #endif /* _MONO_COMPONENT_EVENT_PIPE_WASM_H */ | ||
|
|
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| TOP=../../../../.. | ||
|
|
||
| include ../wasm.mk | ||
|
|
||
| ifneq ($(AOT),) | ||
| override MSBUILD_ARGS+=/p:RunAOTCompilation=true | ||
| endif | ||
|
|
||
| PROJECT_NAME=Wasm.Browser.EventPipe.Sample.csproj | ||
|
|
||
| run: run-browser |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
|
|
||
| namespace Sample | ||
| { | ||
| public class Test | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| // not called. See main.js for all the interesting bits | ||
| } | ||
|
|
||
| private static int iterations; | ||
| private static CancellationTokenSource cts; | ||
|
|
||
| public static CancellationToken GetCancellationToken() | ||
| { | ||
| if (cts == null) { | ||
| cts = new CancellationTokenSource (); | ||
| } | ||
| return cts.Token; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static long recursiveFib (int n) | ||
| { | ||
| if (n < 1) | ||
| return 0; | ||
| if (n == 1) | ||
| return 1; | ||
| return recursiveFib (n - 1) + recursiveFib (n - 2); | ||
| } | ||
|
|
||
| public static async Task<int> StartAsyncWork() | ||
| { | ||
| CancellationToken ct = GetCancellationToken(); | ||
| long b; | ||
| const int N = 35; | ||
| const long expected = 9227465; | ||
| while (true) | ||
| { | ||
| await Task.Delay(1).ConfigureAwait(false); | ||
| b = recursiveFib (N); | ||
| if (ct.IsCancellationRequested) | ||
| break; | ||
| iterations++; | ||
| } | ||
| return b == expected ? 42 : 0; | ||
| } | ||
|
|
||
| public static void StopWork() | ||
| { | ||
| cts.Cancel(); | ||
| } | ||
|
|
||
| public static string GetIterationsDone() | ||
| { | ||
| return iterations.ToString(); | ||
| } | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <WasmCopyAppZipToHelixTestDir Condition="'$(ArchiveTests)' == 'true'">true</WasmCopyAppZipToHelixTestDir> | ||
| <WasmMainJSPath>main.js</WasmMainJSPath> | ||
| <DebugSymbols>true</DebugSymbols> | ||
| <DebugType>embedded</DebugType> | ||
| <WasmDebugLevel>1</WasmDebugLevel> | ||
| <WasmEnableES6>false</WasmEnableES6> | ||
| <WasmBuildNative>true</WasmBuildNative> | ||
| <GenerateRunScriptForSample Condition="'$(ArchiveTests)' == 'true'">true</GenerateRunScriptForSample> | ||
| <RunScriptCommand>$(ExecXHarnessCmd) wasm test-browser --app=. --browser=Chrome $(XHarnessBrowserPathArg) --html-file=index.html --output-directory=$(XHarnessOutput) -- $(MSBuildProjectName).dll</RunScriptCommand> | ||
| <FeatureWasmPerfTracing>true</FeatureWasmPerfTracing> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <WasmExtraFilesToDeploy Include="index.html" /> | ||
| <WasmExtraConfig Condition="false" Include="environment_variables" Value=' | ||
| { | ||
| "MONO_LOG_LEVEL": "debug", | ||
| "MONO_LOG_MASK": "diagnostics" | ||
| }' /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_SampleProject>Wasm.Browser.CJS.Sample.csproj</_SampleProject> | ||
| </PropertyGroup> | ||
|
|
||
|
|
||
| <PropertyGroup> | ||
| <RunAnalyzers>true</RunAnalyzers> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- set the condition to false and you will get a CA1416 errors about calls to create DiagnosticCounter instances --> | ||
| <ItemGroup Condition="true"> | ||
| <!-- TODO: some .props file that automates this. Unfortunately just adding a ProjectReference to Microsoft.NET.WebAssembly.Threading.proj doesn't work - it ends up bundling the ref assemblies into the publish directory and breaking the app. --> | ||
| <!-- it's a reference assembly, but the project system doesn't know that - include it during compilation, but don't publish it --> | ||
| <ProjectReference Include="$(LibrariesProjectRoot)\System.Diagnostics.Tracing.WebAssembly.PerfTracing\ref\System.Diagnostics.Tracing.WebAssembly.PerfTracing.csproj" IncludeAssets="compile" PrivateAssets="none" ExcludeAssets="runtime" Private="false" /> | ||
| </ItemGroup> | ||
|
|
||
| <Target Name="RunSample" DependsOnTargets="RunSampleWithBrowser" /> | ||
| </Project> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <!DOCTYPE html> | ||
| <!-- Licensed to the .NET Foundation under one or more agreements. --> | ||
| <!-- The .NET Foundation licenses this file to you under the MIT license. --> | ||
| <html> | ||
|
|
||
| <head> | ||
| <title>Sample EventPipe profile session</title> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h3 id="header">Wasm Browser EventPipe profiling Sample</h3> | ||
| Computing Fib repeatedly: <span id="out"></span> | ||
| <script type="text/javascript" src="./dotnet.js"></script> | ||
| <script type="text/javascript" src="./dotnet.worker.js"></script> | ||
| <script type="text/javascript" src="./main.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.