Skip to content

[browser] remove MT event pipe #111152

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 7 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/design/mono/jiterpreter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ To set runtime options when using the .NET runtime directly, use the `withRuntim
const runtime = await dotnet
.withRuntimeOptions(["--jiterpreter-stats-enabled"])
```
When using Blazor, you can use the Msbuild property `BlazorWebAssemblyJiterpreter` as a convenient shorthand to configure whether the Jiterpreter is enabled. You can also use `BlazorWebAssemblyRuntimeOptions` to set specific options directly. At present, the Jiterpreter only functions in Blazor applications that have been published. When running with debugging enabled, it will be inactive.

Or disable jiterp with

```javascript
const runtime = await dotnet
.withRuntimeOptions(["--no-jiterpreter-traces-enabled"])
```
When using Blazor (or `Microsoft.NET.Sdk.WebAssembly`), you can use the Msbuild property `BlazorWebAssemblyJiterpreter` as a convenient shorthand to configure whether the Jiterpreter is enabled. You can also use `BlazorWebAssemblyRuntimeOptions` to set specific options directly. At present, the Jiterpreter only functions in Blazor applications that have been published. When running with debugging enabled, it will be inactive.

## Trace lifecycle
The trace compiler operates in multiple phases, starting first during code generation for "tiered" (optimized) interpreter methods and then finishing during actual execution of interpreted code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Threading.WebAssembly.Threading\ref\System.Threading.WebAssembly.Threading.csproj;
$(LibrariesProjectRoot)System.Threading.Thread.WebAssembly.Threading\ref\System.Threading.Thread.WebAssembly.Threading.csproj;
$(LibrariesProjectRoot)System.Threading.ThreadPool.WebAssembly.Threading\ref\System.Threading.ThreadPool.WebAssembly.Threading.csproj;
$(LibrariesProjectRoot)System.Diagnostics.Tracing.WebAssembly.PerfTracing\ref\System.Diagnostics.Tracing.WebAssembly.PerfTracing.csproj"
$(LibrariesProjectRoot)System.Threading.ThreadPool.WebAssembly.Threading\ref\System.Threading.ThreadPool.WebAssembly.Threading.csproj"
Pack="true"
PrivateAssets="all"
Private="true"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

namespace System.Diagnostics.Tracing
{
#if !FEATURE_WASM_PERFTRACING
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
#endif
public abstract partial class DiagnosticCounter : System.IDisposable
{
internal DiagnosticCounter() { }
Expand All @@ -16,36 +14,28 @@ internal DiagnosticCounter() { }
public void AddMetadata(string key, string? value) { }
public void Dispose() { }
}
#if !FEATURE_WASM_PERFTRACING
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
#endif
public partial class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public PollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> metricProvider) { }
public override string ToString() { throw null; }
}
#if !FEATURE_WASM_PERFTRACING
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
#endif
public partial class IncrementingEventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingEventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
public void Increment(double increment = 1) { }
public override string ToString() { throw null; }
}
#if !FEATURE_WASM_PERFTRACING
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
#endif
public partial class IncrementingPollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public IncrementingPollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> totalValueProvider) { }
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
public override string ToString() { throw null; }
}
#if !FEATURE_WASM_PERFTRACING
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
#endif
public partial class EventCounter : System.Diagnostics.Tracing.DiagnosticCounter
{
public EventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<FeatureWasmPerfTracing>false</FeatureWasmPerfTracing>
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Diagnostics.Tracing.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
<UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
</PropertyGroup>

<PropertyGroup Condition="'$(WasmEnableThreads)' == 'true'">
<!-- when wasm threading is enabled the implementation in CoreLib won't have the UnsupportedOSAttribute for browser,
but this contract still does since we only expose the wasm threading through System.Diagnostics.Tracing.WebAssembly.PerfTracing
so we need to baseline the ApiCompat errors related to that -->
<CompatibilitySuppressionFilePath>$(MSBuildThisFileDirectory)CompatibilitySuppressions.Tracing.xml</CompatibilitySuppressionFilePath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(CoreLibProject)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
<NoWarn>$(NoWarn);0809;0618;CS8614;CS3015</NoWarn>
<StrongNameKeyId>SilverlightPlatform</StrongNameKeyId>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<FeatureWasmPerfTracing Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmPerfTracing>
<FeatureWasmManagedThreads Condition="'$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
<DefineConstants>$(DefineConstants);BUILDING_CORELIB_REFERENCE</DefineConstants>
<!-- Disable binplacing since the System.Private.CoreLib reference assembly is internal to our build and shouldn't be exposed anywhere -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
namespace System.Diagnostics.Tracing
{
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
internal sealed class CounterGroup
{
Expand Down Expand Up @@ -171,7 +169,7 @@ private void EnableTimer(float pollingIntervalInSeconds)
IsBackground = true,
Name = ".NET Counter Poller"
};
s_pollingThread.InternalUnsafeStart();
s_pollingThread.Start();
}

if (!s_counterGroupEnabledList!.Contains(this))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ namespace System.Diagnostics.Tracing
/// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter.
/// </summary>
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
public abstract class DiagnosticCounter : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace System.Diagnostics.Tracing
/// which shows tests, which are also useful in seeing actual use.
/// </summary>
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
public partial class EventCounter : DiagnosticCounter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ private void CommitDispatchConfiguration()

private void StartDispatchTask(ulong sessionID, DateTime syncTimeUtc, long syncTimeQPC, long timeQPCFrequency)
{
if (OperatingSystem.IsBrowser() || OperatingSystem.IsWasi())
{
throw new PlatformNotSupportedException();
}

Debug.Assert(Monitor.IsEntered(m_dispatchControlLock));
Debug.Assert(sessionID != 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ namespace System.Diagnostics.Tracing
/// the counter value.
/// </summary>
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
public partial class IncrementingEventCounter : DiagnosticCounter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace System.Diagnostics.Tracing
/// its own metric periodically.
/// </summary>
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
public partial class IncrementingPollingCounter : DiagnosticCounter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ namespace System.Diagnostics.Tracing
/// every time.
/// </summary>
#if !ES_BUILD_STANDALONE
#if !FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatform("browser")]
#endif
#endif
public partial class PollingCounter : DiagnosticCounter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ public static void Free(NativeOverlapped* nativeOverlappedPtr)
_pNativeOverlapped = pNativeOverlapped;

#if FEATURE_PERFTRACING
#if !((TARGET_BROWSER || TARGET_WASI) && !FEATURE_WASM_MANAGED_THREADS)
if (NativeRuntimeEventSource.Log.IsEnabled())
NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped);
#endif
#endif

NativeOverlapped* pRet = pNativeOverlapped;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,19 @@ public Thread(ParameterizedThreadStart start, int maxStackSize)
}

#if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_MANAGED_THREADS
[UnsupportedOSPlatformGuard("wasi")]
[UnsupportedOSPlatformGuard("browser")]
[UnsupportedOSPlatformGuard("wasi")]
internal static bool IsThreadStartSupported => true;
internal static bool IsInternalThreadStartSupported => true;
#elif FEATURE_WASM_PERFTRACING
[UnsupportedOSPlatformGuard("wasi")]
[UnsupportedOSPlatformGuard("browser")]
[UnsupportedOSPlatformGuard("wasi")]
internal static bool IsThreadStartSupported => false;
internal static bool IsInternalThreadStartSupported => true;
#else
[UnsupportedOSPlatformGuard("wasi")]
[UnsupportedOSPlatformGuard("browser")]
[UnsupportedOSPlatformGuard("wasi")]
internal static bool IsThreadStartSupported => false;
internal static bool IsInternalThreadStartSupported => false;
#endif

internal static void ThrowIfNoThreadStart(bool internalThread = false)
internal static void ThrowIfNoThreadStart()
{
if (IsThreadStartSupported)
return;
if (IsInternalThreadStartSupported && internalThread)
return;
throw new PlatformNotSupportedException();
}

Expand Down Expand Up @@ -209,12 +197,12 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false)
#endif
public void UnsafeStart(object? parameter) => Start(parameter, captureContext: false);

private void Start(object? parameter, bool captureContext, bool internalThread = false)
private void Start(object? parameter, bool captureContext)
{
#if TARGET_WASI
if (OperatingSystem.IsWasi()) throw new PlatformNotSupportedException(); // TODO remove with https://github.com/dotnet/runtime/pull/107185
#endif
ThrowIfNoThreadStart(internalThread);
ThrowIfNoThreadStart();

StartHelper? startHelper = _startHelper;

Expand Down Expand Up @@ -255,11 +243,9 @@ private void Start(object? parameter, bool captureContext, bool internalThread =
#endif
public void UnsafeStart() => Start(captureContext: false);

internal void InternalUnsafeStart() => Start(captureContext: false, internalThread: true);

private void Start(bool captureContext, bool internalThread = false)
private void Start(bool captureContext)
{
ThrowIfNoThreadStart(internalThread);
ThrowIfNoThreadStart();
StartHelper? startHelper = _startHelper;

// In the case of a null startHelper (second call to start on same thread)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,16 @@

<FeatureMono>true</FeatureMono>
<FeatureWasmManagedThreads Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
<FeatureWasmPerfTracing Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and ('$(WasmEnableThreads)' == 'true')">true</FeatureWasmPerfTracing>
<FeaturePortableTimer Condition="('$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true') or '$(FeatureWasmManagedThreads)' == 'true'">true</FeaturePortableTimer>
<FeaturePortableThreadPool Condition="('$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true') or '$(FeatureWasmManagedThreads)' == 'true'">true</FeaturePortableThreadPool>
<FeaturePerfTracing Condition="('$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true') or '$(FeatureWasmPerftracing)' == 'true'">true</FeaturePerfTracing>
<FeaturePerfTracing Condition="('$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true')">true</FeaturePerfTracing>
<FeatureObjCMarshal Condition="'$(TargetsOSX)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">true</FeatureObjCMarshal>
</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
<DefineConstants Condition="'$(FeatureObjCMarshal)' == 'true'">$(DefineConstants);FEATURE_OBJCMARSHAL</DefineConstants>
<DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
</PropertyGroup>

<!-- ILLinker settings -->
Expand Down
10 changes: 2 additions & 8 deletions src/mono/browser/browser.proj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
<PythonCmd Condition="'$(HostOS)' == 'windows'">python</PythonCmd>
</PropertyGroup>

<PropertyGroup>
<MonoDiagnosticsMock Condition="'$(MonoDiagnosticsMock)' == '' and '$(Configuration)' == 'Release'">false</MonoDiagnosticsMock>
<MonoDiagnosticsMock Condition="'$(MonoDiagnosticsMock)' == '' and '$(Configuration)' == 'Debug'">true</MonoDiagnosticsMock>
</PropertyGroup>

<PropertyGroup>
<ICULibDir Condition="'$(WasmEnableThreads)' != 'true'">$([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib'))</ICULibDir>
<ICULibDir Condition="'$(WasmEnableThreads)' == 'true'">$([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib'))</ICULibDir>
Expand All @@ -32,6 +27,7 @@
<EmccMaximumHeapSize Condition="'$(EmccMaximumHeapSize)' == ''">2147483648</EmccMaximumHeapSize>
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == '' and '$(WasmEnableThreads)' == 'true'">true</WasmEnableJsInteropByValue>
<WasmEnableJsInteropByValue Condition="'$(WasmEnableJsInteropByValue)' == ''">false</WasmEnableJsInteropByValue>
<FeaturePerfTracing Condition="'$(FeaturePerfTracing)' == ''">false</FeaturePerfTracing>
<FilterSystemTimeZones Condition="'$(FilterSystemTimeZones)' == ''">false</FilterSystemTimeZones>
<EmccCmd>emcc</EmccCmd>
<WasmObjDir>$(ArtifactsObjDir)wasm</WasmObjDir>
Expand Down Expand Up @@ -548,10 +544,9 @@

<ItemGroup>
<_RollupInputs Include="$(BrowserProjectRoot)runtime/**/*.ts"
Exclude="$(BrowserProjectRoot)runtime/dotnet.d.ts;$(BrowserProjectRoot)runtime/diagnostics-mock.d.ts;$(BrowserProjectRoot)runtime/node_modules/**/*.ts" />
Exclude="$(BrowserProjectRoot)runtime/dotnet.d.ts;$(BrowserProjectRoot)runtime/node_modules/**/*.ts" />
<_RollupInputs Include="$(BrowserProjectRoot)runtime/**/tsconfig.*"
Exclude="$(BrowserProjectRoot)runtime/node_modules/**/tsconfig.*" />
<_RollupInputs Include="$(BrowserProjectRoot)runtime/workers/**/*.js"/>
<_RollupInputs Include="$(BrowserProjectRoot)runtimetypes/*.d.ts"/>
<_RollupInputs Include="$(BrowserProjectRoot)runtime/*.json"/>
<_RollupInputs Include="$(BrowserProjectRoot)runtime/*.js"/>
Expand All @@ -577,7 +572,6 @@
<_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" />
<_MonoRollupEnvironmentVariable Include="ENABLE_JS_INTEROP_BY_VALUE:1" Condition="'$(WasmEnableJsInteropByValue)' == 'true'" />
<_MonoRollupEnvironmentVariable Include="ENABLE_JS_INTEROP_BY_VALUE:0" Condition="'$(WasmEnableJsInteropByValue)' != 'true'" />
<_MonoRollupEnvironmentVariable Include="MonoDiagnosticsMock:$(MonoDiagnosticsMock)" />
<_MonoRollupEnvironmentVariable Include="ContinuousIntegrationBuild:$(ContinuousIntegrationBuild)" />
</ItemGroup>

Expand Down
Loading
Loading