-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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] Minimal diagnostic tracing configuration and sample #69158
Merged
Merged
Changes from 15 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 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 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 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 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 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 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 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 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 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,65 @@ | ||
// 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) | ||
{ | ||
Console.WriteLine ("Hello, World!"); | ||
kg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private static int iterations; | ||
private static CancellationTokenSource cts; | ||
|
||
public static CancellationToken GetCancellationToken() | ||
{ | ||
if (cts == null) { | ||
cts = new CancellationTokenSource (); | ||
} | ||
return cts.Token; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static async Task<int> StartAsyncWork() | ||
{ | ||
CancellationToken ct = GetCancellationToken(); | ||
int a; | ||
int b; | ||
const int N = 30; | ||
const int expected = 832040; | ||
while (true) | ||
{ | ||
a = 0; b = 1; | ||
for (int i = 1; i < N; i++) | ||
{ | ||
int tmp = a + b; | ||
a = b; | ||
b = tmp; | ||
await Task.Delay(1).ConfigureAwait(false); | ||
} | ||
if (ct.IsCancellationRequested) | ||
break; | ||
iterations++; | ||
} | ||
return b == expected ? 42 : 0; | ||
} | ||
|
||
public static void StopWork() | ||
{ | ||
cts.Cancel(); | ||
} | ||
|
||
public static string GetIterationsDone() | ||
{ | ||
return iterations.ToString(); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
This file contains 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,43 @@ | ||
<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 error about the call to Thread.Start from a browser-wasm project --> | ||
<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.Threading.Thread.WebAssembly.Threading\ref\System.Threading.Thread.WebAssembly.Threading.csproj" IncludeAssets="compile" PrivateAssets="none" ExcludeAssets="runtime" Private="false" /> | ||
<ProjectReference Include="$(LibrariesProjectRoot)\System.Threading.ThreadPool.WebAssembly.Threading\ref\System.Threading.ThreadPool.WebAssembly.Threading.csproj" IncludeAssets="compile" PrivateAssets="none" ExcludeAssets="runtime" Private="false" /> | ||
<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 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> | ||
Answer to the Ultimate Question of Life, the Universe, and Everything is : <span id="out"></span> | ||
kg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the message to mention that this only applies to wasm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. also clarified that runtime internal managed threads will be allowed (I need them to support the EventPipe counter sampling thread).