You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript can now hand the server request bytes without a string crossing
the boundary: two pinned buffers are exposed once as MemoryViews through a
[JSImport], and a [JSExport] processes the input buffer through the same
byte-first entry point Kestrel uses. On the interpreter that is 53 us per
request against 58 us for the string [JSExport] and 64 us for a plain Blazor
invokeMethod add; a batch of 100 reaches 27k RPC/s.
dotnet publish -c Release turns on RunAOTCompilation (wasm-tools workload
needed; -p:Aot=false opts out); build and run stay on the interpreter. The
page reports whether it is AOT-compiled. The wasm-tools install needs an
elevated prompt on this machine, so the AOT numbers are still to be taken.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -284,7 +284,7 @@ The TCP client keeps 256 requests in flight per connection and refills from a pr
284
284
285
285
### WebAssembly: in the browser
286
286
287
-
The [WasmHost sample](samples/WasmHost/README.md) compares JSON-RPC through JS interop with plain Blazor interop for the same `add(1, 2)` under the .NET 10 interpreter in Chrome. A plain `DotNet.invokeMethod` add costs about 65 µs (Blazor's JSON marshalling), a JSON-RPC document through `[JSExport]`56 µs, a batch of 100 through `[JSExport]` 26k RPC/s, and a typed `[JSExport]` add 0.38 µs. The interpreter is the bottleneck; AOT is the lever.
287
+
The [WasmHost sample](samples/WasmHost/README.md) compares JSON-RPC through JS interop with plain Blazor interop for the same `add(1, 2)` under the .NET 10 interpreter in Chrome. A plain `DotNet.invokeMethod` add costs about 64 µs (the JSON marshalling Blazor does); a JSON-RPC document written as UTF-8 straight into WebAssembly memory and run through a `[JSExport]`costs 53 µs, a batch of 100 that way reaches 27k RPC/s, and a typed `[JSExport]` add takes 0.35 µs. The interpreter is the bottleneck; `dotnet publish`AOT-compiles the sample when the `wasm-tools` workload is installed.
Copy file name to clipboardExpand all lines: samples/WasmHost/README.md
+38-34Lines changed: 38 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,52 +34,56 @@ reach .NET here, and reports calls per second, microseconds per call, and RPCs p
34
34
| plain interop, `exports.JsonRpcInterop.AddExported(1,2)`| one `[JSExport]` method per operation (`System.Runtime.InteropServices.JavaScript`), which marshals each parameter directly with no JSON |
35
35
| JSON-RPC, `invokeMethod('WasmHost','Process',request)`| one `[JSInvokable]` entry point for every method: a request document in, the response document out |
36
36
| JSON-RPC, `invokeMethodAsync`| the same through the promise-returning call |
37
-
| JSON-RPC, `exports.JsonRpcInterop.ProcessExported(request)`| the same entry point as a `[JSExport]`|
38
-
| JSON-RPC, batch of 100 per call | both interop flavours with a 100-request batch document per call |
39
-
| JSON-RPC in a .NET loop |`ProcessMany` runs the request N times inside .NET: the server's own cost in this runtime, no interop |
37
+
| JSON-RPC, `exports.JsonRpcInterop.ProcessExported(request)`| the same entry point as a `[JSExport]`, strings marshalled by the runtime |
38
+
| JSON-RPC, `ProcessBytes`, UTF-8 buffers | JavaScript writes the request bytes into a pinned buffer in WebAssembly memory (a `MemoryView` handed over once at start-up), calls a `[JSExport]` with the length, and reads the response bytes back; no string crosses the boundary and the server runs its byte-first entry point, the one the Kestrel package uses |
39
+
| JSON-RPC, batch of 100 per call | the three interop flavours with a 100-request batch document per call |
40
+
| JSON-RPC in a .NET loop |`ProcessMany` runs the string request N times inside .NET: the cost of the server itself in this runtime, no interop |
40
41
41
-
Measured on an 8-core desktop in Chrome 152 with the .NET 10 interpreter (no `wasm-tools` workload, so no
42
-
AOT), 20,000 RPCs per row:
42
+
Measured on an 8-core desktop in Chrome 152 with the .NET 10 interpreter (`dotnet run`, no AOT), 20,000 RPCs
0 commit comments