-
Notifications
You must be signed in to change notification settings - Fork 15
Add .NET on WebAssembly workload #73
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
+37,582
−0
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dd055ee
Implement .NET benchmarks
maraf c11b328
Add JSON
maraf ba05a96
Deduplicate preloads
maraf 8cba497
Add JSON to in-depth.html
maraf 7735bfe
Combine all tests
maraf 0f265ab
Update in-depth.html
maraf ba35bc3
Reduce iterations
maraf 1f9bc2b
Further iteration reduction
maraf b719e8f
Make it work on cli without preloading
maraf 8ce2c23
Update to 9.0.7
maraf 5623e4c
Smaller scene size for interp
maraf a22b110
Merge remote-tracking branch 'upstream/main' into DotnetWasm
maraf 79df4d0
Use getBinary
maraf 51d90cc
Use getBinary
maraf 1ed0ee3
Remove WarmUp
maraf 67cc1bd
Smaller raytracer scene, more samples in bench tasks
maraf 97f97f1
hardwareConcurrency = 1
maraf 186b1f7
Emit symbols
maraf d4d74ce
Rebuild interp
maraf 2bdb75c
Mark core assemblies
maraf dc750e9
Monkey patch use of import.meta.url
maraf ded3bbd
.NET SDK info
maraf b0353a6
README
maraf 37e1621
Description of .NET build output
maraf a1d0702
chmod +x build.sh
maraf 7a39202
Exclude additional files from git
maraf 295ae1a
Prepend import.meta.url and copy symbols from obj
maraf 5aa9dad
Readme
maraf 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.binlog | ||
.dotnet | ||
.nuget | ||
bin | ||
obj | ||
blazor.boot.json | ||
web.config | ||
*.staticwebassets.endpoints.json |
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,30 @@ | ||
# .NET on WebAssembly | ||
|
||
Tests [.NET on WebAssembly](https://github.com/dotnet/runtime). This benchmark tests operations | ||
on .NET implementation of String, JSON serialization, specifics of .NET exceptions and computation | ||
of a 3D scene using Mono Interpreter & AOT. Source code: [.NET](wasm/dotnet) | ||
|
||
## Build instructions | ||
|
||
Download .NET SDK 9.0.3xx | ||
|
||
- [dotnet-sdk-win-x64.zip](https://aka.ms/dotnet/9.0.3xx/daily/dotnet-sdk-win-x64.zip) | ||
- [dotnet-sdk-linux-x64.tar.gz](https://aka.ms/dotnet/9.0.3xx/daily/dotnet-sdk-linux-x64.tar.gz) | ||
|
||
Run `build.sh` script. It will install `wasm-tools` workload & build the benchmark code twice (for Mono interpreter & AOT). | ||
|
||
To run the benchmark code on `jsc`, we are prepending `import.meta.url ??= ""` to `dotnet.js`. | ||
|
||
## Background on .NET / build output files | ||
|
||
Mono AOT works in a "mixed mode". It is not able to compile all code patterns and in various scenarios it falls back to interpreter. | ||
Because of that we are still loading managed dlls (all the other not-`dotnet.native.wasm` files). | ||
|
||
Structure of the build output | ||
|
||
- `dotnet.js` is entrypoint JavaScript with public API. | ||
- `dotnet.runtime.js` is internal implementation of JavaScript logic for .NET. | ||
- `dotnet.native.js` is emscripten module configured for .NET. | ||
- `dotnet.native.wasm` is unmanaged code (Mono runtime + AOT compiled code). | ||
- `System.*.wasm` is .NET BCL that has unused code trimmed away. | ||
- `dotnet.wasm` is the benchmark code. |
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 @@ | ||
globalThis.dotnetFlavor = "aot"; |
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,138 @@ | ||
class Benchmark { | ||
async init() { | ||
const config = { | ||
mainAssemblyName: "dotnet.dll", | ||
globalizationMode: "custom", | ||
assets: [ | ||
{ | ||
name: "dotnet.runtime.js", | ||
resolvedUrl: dotnetRuntimeUrl, | ||
moduleExports: await dynamicImport(dotnetRuntimeUrl), | ||
behavior: "js-module-runtime" | ||
}, | ||
{ | ||
name: "dotnet.native.js", | ||
resolvedUrl: dotnetNativeUrl, | ||
moduleExports: await dynamicImport(dotnetNativeUrl), | ||
behavior: "js-module-native" | ||
}, | ||
{ | ||
name: "dotnet.native.wasm", | ||
resolvedUrl: wasmBinaryUrl, | ||
buffer: await getBinary(wasmBinaryUrl), | ||
behavior: "dotnetwasm" | ||
}, | ||
{ | ||
name: "icudt_CJK.dat", | ||
resolvedUrl: icuCustomUrl, | ||
buffer: await getBinary(icuCustomUrl), | ||
behavior: "icu" | ||
}, | ||
{ | ||
name: "System.Collections.Concurrent.wasm", | ||
resolvedUrl: dllCollectionsConcurrentUrl, | ||
buffer: await getBinary(dllCollectionsConcurrentUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Collections.wasm", | ||
resolvedUrl: dllCollectionsUrl, | ||
buffer: await getBinary(dllCollectionsUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.ComponentModel.Primitives.wasm", | ||
resolvedUrl: dllComponentModelPrimitivesUrl, | ||
buffer: await getBinary(dllComponentModelPrimitivesUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.ComponentModel.TypeConverter.wasm", | ||
resolvedUrl: dllComponentModelTypeConverterUrl, | ||
buffer: await getBinary(dllComponentModelTypeConverterUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Drawing.Primitives.wasm", | ||
resolvedUrl: dllDrawingPrimitivesUrl, | ||
buffer: await getBinary(dllDrawingPrimitivesUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Drawing.wasm", | ||
resolvedUrl: dllDrawingUrl, | ||
buffer: await getBinary(dllDrawingUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.IO.Pipelines.wasm", | ||
resolvedUrl: dllIOPipelinesUrl, | ||
buffer: await getBinary(dllIOPipelinesUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Linq.wasm", | ||
resolvedUrl: dllLinqUrl, | ||
buffer: await getBinary(dllLinqUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Memory.wasm", | ||
resolvedUrl: dllMemoryUrl, | ||
buffer: await getBinary(dllMemoryUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.ObjectModel.wasm", | ||
resolvedUrl: dllObjectModelUrl, | ||
buffer: await getBinary(dllObjectModelUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Private.CoreLib.wasm", | ||
resolvedUrl: dllPrivateCorelibUrl, | ||
buffer: await getBinary(dllPrivateCorelibUrl), | ||
behavior: "assembly", | ||
isCore: true | ||
}, | ||
{ | ||
name: "System.Runtime.InteropServices.JavaScript.wasm", | ||
resolvedUrl: dllRuntimeInteropServicesJavaScriptUrl, | ||
buffer: await getBinary(dllRuntimeInteropServicesJavaScriptUrl), | ||
behavior: "assembly", | ||
isCore: true | ||
}, | ||
{ | ||
name: "System.Text.Encodings.Web.wasm", | ||
resolvedUrl: dllTextEncodingsWebUrl, | ||
buffer: await getBinary(dllTextEncodingsWebUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "System.Text.Json.wasm", | ||
resolvedUrl: dllTextJsonUrl, | ||
buffer: await getBinary(dllTextJsonUrl), | ||
behavior: "assembly" | ||
}, | ||
{ | ||
name: "dotnet.wasm", | ||
resolvedUrl: dllAppUrl, | ||
buffer: await getBinary(dllAppUrl), | ||
behavior: "assembly", | ||
isCore: true | ||
} | ||
] | ||
}; | ||
|
||
this.dotnet = (await dynamicImport(dotnetUrl)).dotnet; | ||
this.api = await this.dotnet.withModuleConfig({ locateFile: e => e }).withConfig(config).create(); | ||
maraf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.exports = await this.api.getAssemblyExports("dotnet.dll"); | ||
|
||
this.hardwareConcurrency = 1; | ||
this.sceneWidth = dotnetFlavor === "aot" ? 300 : 150; | ||
this.sceneHeight = dotnetFlavor === "aot" ? 200 : 100; | ||
} | ||
async runIteration() { | ||
await this.exports.Interop.RunIteration(this.sceneWidth, this.sceneHeight, this.hardwareConcurrency); | ||
} | ||
} |
Binary file added
BIN
+14.8 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.Collections.Concurrent.wasm
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.77 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.ComponentModel.Primitives.wasm
Binary file not shown.
Binary file added
BIN
+5.27 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.ComponentModel.TypeConverter.wasm
Binary file not shown.
Binary file added
BIN
+20.3 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.Drawing.Primitives.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+38.3 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.Runtime.InteropServices.JavaScript.wasm
Binary file not shown.
Binary file added
BIN
+28.8 KB
wasm/dotnet/build-aot/wwwroot/_framework/System.Text.Encodings.Web.wasm
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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.