The kernel under WebAssembly: 1.26 MB Brotli over the bare runtime, and 0.2 s to the first Simplify
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 48/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp, wasm
- Ambito
- documentation, performance
Direzione di ricerca
The change is in the WebAssembly section of the trimming document (§3), specifically the entry listing "the payload under Blazor WebAssembly" under Not measured. Read that section first, then the probe in the collapsed details block: trimmed.csproj (with the ProjectReference to Sources/AngouriMath/AngouriMath.csproj), Program.cs, and wwwroot/main.js. Done means the entry is replaced by a claim whose figures match the payload tables, and the probe can be rebuilt to reproduce them.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What you ran: three minimal Microsoft.NET.Sdk.WebAssembly apps on master 17cd9da (.NET SDK 10.0.402, dotnet publish -c Release, which here is PublishTrimmed=true, TrimMode=full, no AOT; InvariantGlobalization), differing only in the kernel:
- baseline: no AngouriMath; the export returns its argument.
- trimmed: a project reference to the kernel, pinned to net10.0 as §3 says (
SetTargetFramework="TargetFramework=net10.0"), and one[JSExport]that parses a string and callsSimplify. - whole: the same, plus
<TrimmerRootAssembly Include="AngouriMath" />, so every member of the kernel is kept.
What it did:
Payload, counting the files dotnet.js loads (the compressed columns are the publish output's .br and .gz siblings):
| files | raw | Brotli | gzip | |
|---|---|---|---|---|
| baseline | 7 | 4,441,302 B | 1,399,500 B | 1,722,759 B |
| trimmed | 22 | 8,837,785 B | 2,657,073 B | 3,300,554 B |
| whole | 25 | 9,421,934 B | 2,807,807 B | 3,491,046 B |
The kernel adds 1,257,573 B Brotli trimmed, 1,408,307 B whole. Of the 15 files it adds, AngouriMath.wasm is 828,707 B Brotli (3,128,089 B raw); the rest are its four package dependencies (Antlr4.Runtime.Standard, GenericTensor, HonkSharp, Numbers) and ten framework assemblies, the largest System.Linq.Expressions at 359,489 B raw. None of the three publishes gives a trim warning, as IsAotCompatible promises.
Time, in Chromium on a Ryzen 7 9800X3D, served from 127.0.0.1 with Cache-Control: no-store so that every load fetches every file; the first visit and four reloads each, in ms:
| runtime ready | first Simplify |
second Simplify |
first answer, from navigation | |
|---|---|---|---|---|
| baseline | 42–77 | — | — | 147, then 69–81 |
| trimmed | 68–96 | 193–257 | 105–135 | 406, then 288–319 |
| whole | 70–92 | 191–258 | 102–134 | 415, then 286–316 |
"Runtime ready" is dotnet.create() plus getAssemblyExports, from the start of the page's script. The first call is sin(x)^2 + cos(x)^2 → 1, the second (x^2 - 1) / (x - 1) → x + 1 provided not x - 1 = 0. So, locally, loading the kernel costs about 25 ms over the bare runtime, the first Simplify about 0.2 s and the next about 0.12 s, in the interpreter (AOT not measured). Keeping the kernel whole costs 150,734 B Brotli and no measurable time.
Over a network the bytes are the cost: at 10 Mbit/s, the kernel's 1,257,573 B are about 1.0 s of transfer (arithmetic, not measured). That bears on the question left open in #1692.
Through the name localhost (the server bound 127.0.0.1 only) the same trimmed page took 2.0 s on this machine instead of 0.3 s; the tables are from the address.
For the table already in §3: master's net10.0 AngouriMath.dll is 3,633,664 B, against 1,184,256 B for the 2.3.0 package measured there. The WebAssembly trimmer keeps 3,128,320 B of it for parse + Simplify (86.1%) and 3,617,792 B rooted, so the section's finding that parsing reaches nearly everything holds, more strongly than before.
What it should have done: §3 lists "the payload under Blazor WebAssembly" under Not measured, and therefore not claimed. With these numbers that entry can become a claim, for instance:
Under WebAssembly (
Microsoft.NET.Sdk.WebAssembly, .NET 10, trimmed, no AOT) the kernel adds 1.26 MB Brotli to a 1.40 MB bare runtime, in 15 files of whichAngouriMath.wasmis 0.83 MB, and the firstSimplifytakes about 0.2 s in the interpreter. Rooting the kernel whole adds 0.15 MB.
This was measured without Blazor. Blazor's own assemblies grow the baseline, and some of them are ones the kernel also uses, so the kernel's increment should be no larger there.
The probe apps
trimmed.csproj (baseline: no ProjectReference, no DefineConstants; whole: add <TrimmerRootAssembly Include="AngouriMath" />):
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<InvariantGlobalization>true</InvariantGlobalization>
<DefineConstants>$(DefineConstants);ANGOURI</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AngouriMath\Sources\AngouriMath\AngouriMath.csproj" SetTargetFramework="TargetFramework=net10.0" />
</ItemGroup>
</Project>
Program.cs:
using System.Runtime.InteropServices.JavaScript;
return;
public static partial class Probe
{
[JSExport]
public static string Run(string s) =>
#if ANGOURI
((AngouriMath.Entity)s).Simplify().ToString();
#else
s;
#endif
}
wwwroot/main.js, loaded as a module by a one-line index.html:
import { dotnet } from './_framework/dotnet.js';
const t0 = performance.now();
const runtime = await dotnet.create();
const exports = await runtime.getAssemblyExports(runtime.getConfig().mainAssemblyName);
const t1 = performance.now();
const first = exports.Probe.Run('sin(x)^2 + cos(x)^2');
const t2 = performance.now();
const second = exports.Probe.Run('(x^2 - 1) / (x - 1)');
const t3 = performance.now();
window.probe = { runtimeReady: t1 - t0, firstCall: t2 - t1, secondCall: t3 - t2, sinceNavigation: t2, first, second };
- Lingua principale
- C#
- Stelle
- 831
- Fork
- 79
- Merge medio
- 1h 12m
- PR unite (30g)
- 518
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ASC-Community/AngouriMath
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ASC-Community/AngouriMath#2220 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Opinions wanted
Difficoltà 4/5 Più di una settimana Idoneità per principianti 15/100
ASC-Community/AngouriMath#2319 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
ASC-Community/AngouriMath#2298 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ASC-Community/AngouriMath#2293 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ASC-Community/AngouriMath#2292 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ASC-Community/AngouriMath
Issue simili
-
effort:S P3 refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nightscout/nocturne#3243 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
dasher-project/Dasher-Windows#84 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
libnativeapi/nativeapi#21 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 3 giorni
-
enhancement P3 performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
thomhurst/TUnit#7380 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno