Skip to content

Commit

Permalink
chore: Adjust docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jan 9, 2025
1 parent 4d0f70e commit d1194cc
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 16 deletions.
71 changes: 71 additions & 0 deletions doc/features-profiled-aot-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
uid: Uno.Wasm.Bootstrap.ProfiledAOTValidation
---

# Troubleshooting Profiled AOT

The .NET WebAssembly AOT compiler uses the AOT profile to determine which methods to compile to WebAssembly. In some cases, which may change depending on the .NET SDK version, selected methods may not be AOT compiled silently and may fall back to the interpreter.

In such cases, the runtime performance of the app may become slower than expected.

The bootstrapper provides a way to log the methods that were not AOT compiled, by setting the following property:

```xml
<PropertyGroup>
<WasmShellAOTProfileValidation>true</WasmShellAOTProfileValidation>
</PropertyGroup>
```

## Assemblies filtering

Assemblies may be skipped entirely from the validation using the following property:

```xml
<PropertyGroup>
<WasmShellAOTProfileValidationExcludedAssemblies>$(WasmShellAOTProfileValidationExcludedAssemblies);System.*</WasmShellAOTProfileValidationExcludedAssemblies>
</PropertyGroup>
```

Entries in the `WasmShellAOTProfileValidationExcludedAssemblies` property are semi-colon separated regular expressions.

## Methods filtering

Specific methods may be skipped entirely from the validation using the following property:

```xml
<PropertyGroup>
<WasmShellAOTProfileValidationExcludedMethods>$(WasmShellAOTProfileValidationExcludedMethods);MyNamespace.MyType.MyMethod.*</WasmShellAOTProfileValidationExcludedMethods>
</PropertyGroup>
```

Entries in the `WasmShellAOTProfileValidationExcludedMethods` property are semi-colon separated regular expressions.

## Conditions when methods are not AOT compiled

### Methods with try/finally blocks

Methods with `try/finally` or `using()` blocks are not AOT compiled, because WebAssembly does not support the `finally` block in the same way as the .NET runtime. In this case, the .NET runtime switches to the interpreter.

To reduce the impact of the interpreter, while still keep the try/finally block, moving the code from the inside of the `try` block to another method will improve performance.

## Build Errors

### UNOW0001

The following error may be raised:

```
UNOW0001: Method XXX from YYY has not been AOTed, even if present in the AOT profile.
```

This error is raised when the AOT profile requested a method to be AOT compiled, but was not.

### UNOW0002

The following error may be raised:

```
UNOW0002: The method XXX from YYY is not present in the assembly.
```

This error generally means that there's a problem in the bootstrapper when matching methods from the compiled assemblies. If you find this specific error, please report it by opening an issue.
19 changes: 4 additions & 15 deletions doc/runtime-execution-modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ To create a profiled build:

- Build you application again

Note that the AOT profile is a snapshot of the current set of assemblies and methods in your application. If that set changes significantly, you'll need to re-create the AOT profile to get optimal results.
> [!NOTE]
> AOT profile is a snapshot of the current set of assemblies and methods in your application. If that set changes significantly, you'll need to re-create the AOT profile to get optimal results.
More information about [troubleshooting the Profiled AOT mode](xref:Uno.Wasm.Bootstrap.ProfiledAOTValidation) is available.

### AOT Profile method exclusion

Expand Down Expand Up @@ -151,20 +154,6 @@ At this time, it is only possible to exclude assemblies from being compiled to W

Adding assemblies to this list will exclude them from being compiled to WebAssembly.

### Troubleshooting Mixed AOT/Interpreter Mode

When using the Mixed AOT/Interpreter mode, it is possible that some methods may not be compiled to WebAssembly for a variety of reasons. This can cause performance issues, as the interpreter is slower than the AOT-generated code.

In order to determine which methods are still using the interpreter, you can use the following property:

```xml
<PropertyGroup>
<WasmShellPrintAOTSkippedMethods>true</WasmShellPrintAOTSkippedMethods>
</PropertyGroup>
```

The logs from the AOT compiler can be found in [binlogs generated](https://aka.platform.uno/msbuild-troubleshoot) from the build.

### Increasing the Initial Memory Size

When building with Mixed AOT/Interpreter modes, the initial memory may need to be adjusted in the project configuration if the following error message appears:
Expand Down
1 change: 0 additions & 1 deletion src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

<!-- We cannot change the runtime, let's not warn about it by default -->
<WasmShellAOTProfileValidationExcludedAssemblies>$(WasmShellAOTProfileValidationExcludedAssemblies);System.*</WasmShellAOTProfileValidationExcludedAssemblies>
<WasmShellAOTProfileValidationExcludedAssemblies>$(WasmShellAOTProfileValidationExcludedAssemblies);System2.*</WasmShellAOTProfileValidationExcludedAssemblies>
</PropertyGroup>

<!-- AOT Profiling support -->
Expand Down

0 comments on commit d1194cc

Please sign in to comment.