System.Guid
A CoreLib type served from the framework’s IL: its row of the per-library table of ADR 0023 (columns explained there, under “Measurements”).
| Library (switch) | Correctness (samples from IL) | Binary size, IL / shadow | Compile cpu, IL / shadow | Speed, IL / shadow (time) | Lines removed on a flip | Decision | NativeAOT on the same host, csharpc / NativeAOT (tools/il-first/measure-aot.sh: stripped size; compile cpu; run, median of 7) |
|---|---|---|---|---|---|---|---|
System.Guid (src/Csharpc/upstream-types/System.Guid.txt, CoreLib: the slicer route; #416) |
70 samples that use Guid, generic math conversions or value types through their interfaces byte-identical to real .NET at -O0, -O2 and via IL (390, 1294, 663 and 1253 JSON, 1309), and Guid samples on wasm32; new 1339 (UTF-8 formatting and parsing, big-endian bytes, Version/Variant, CreateVersion7’s layout, comparison operators, the exact FormatException texts, interface dispatch on a boxed Guid, HashSet/List/Comparer use). On main 1339 does not compile (Guid.Parse(ReadOnlySpan<byte>) was missing). Found on the way, fixed in general: an interface call on a value type devirtualized to the first public overload of the same arity (a slice struct implements IEquatable<its own Guid>, so ((IEquatable<Guid>)g).Equals(g) reached Equals(object) with an unboxed Guid: invalid IR); value is IComparable<T> / IEquatable<T> with T = Guid was false (decided on the slice’s own interface list, now also on the real types, in both front-ends); int.CreateTruncating<char> (char’s INumberBase conversions are hosted from CoreLib IL like the integers’). |
guid_throughput (UTF-16 parse variant, which the shadow compiles) 154 216 to 289 688 B (1.88x: Guid’s IL reaches CoreLib’s generic number parsing and NumberFormatInfo; these become shared code when number formatting flips, #426) |
4.5-5.0 to 7.5-7.6 s | median of 7, two rounds: 1 154-1 170 to 1 062-1 120 ms (0.94x: faster) | 1 068 (corelib/Guid.cs); 8 added (UpstreamSupport.GetCryptographicallySecureRandomBytes) |
Flipped (#416). Security: NewGuid/CreateVersion7 draw from Interop.GetCryptographicallySecureRandomBytes, which the slicer’s csharpc profile maps to UpstreamSupport.GetCryptographicallySecureRandomBytes, the runtime’s csrt_os_random (getentropy; RtlGenRandom through rand_s on Windows; WASI random_get). That is the CSPRNG string hashing is seeded from, and a failure stops the program as CoreCLR fails fast. Parsing and formatting are the framework’s code, with its length and character checks. The vector paths take the scalar fallback where csharpc reports Ssse3/Vector128 as not accelerated. |
guid_throughput (with UTF-8 parsing): 297 832 / 1 572 512 B; compile cpu 8.4-9.0 / 14.5-16.7 s; run 1 133-1 179 / 1 164-1 356 ms (0.84-1.01x) |