System.ObjectModel
A library or 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; instructions) |
|---|---|---|---|---|---|---|---|
System.ObjectModel + System.Collections.NonGeneric (System.ObjectModel,System.Collections.NonGeneric) |
5 of 5 samples byte-identical to real .NET in the A/B (1104 CollectionBase, 255, 610 ObservableCollection, 991, the throughput program); after the flip also at -O0 and -O2 with the TLS/X509 collection samples (1100, 1101, 1270, 1005), which derive from the real CollectionBase. Security: ObservableCollection’s reentrancy guard, CollectionBase’s OnValidate/OnInsert hooks and index checks are the framework’s code now; checked by the exception-text and hook-order samples above (1104, 610) |
2.21x over the 5 samples (2 627 against 1 188 KB): a CollectionBase program 251 to 707 KB, an ObservableCollection one 253 to 824 KB, because the framework’s SR resource lookups (argument-exception texts) reach ResourceManager and the culture machinery (about 300 KB; a follow-up for every IL library, #272); programs that use neither are unchanged (tests/size +400 B for async) |
1.75x (68 against 39 CPU s) | 0.70x on the throughput program (median of 5: 841 against 1 194 ms) | 580 (corelib/ObservableCollection.cs 396 and CollectionBase.cs 184) + the PropertyChanged/ChangingEventArgs shadows |
Flipped (#271), ObjectModel and NonGeneric only. Delegate.HasSingleTarget (internal; ObservableCollection tests its handler with it) is served by the runtime (csrt_delegate_has_single_target), the corelib’s X509 certificate collections derive from the real CollectionBase (and the framework-IL choice always takes System.Collections.NonGeneric, since the program does not name the base class). System.Collections and System.Collections.Concurrent followed (#275, rows below). |
observable_throughput: 612 864 / 1 375 352 B; compile cpu 16.1 / 15.0 s; run 921 / 790 ms (1.16x); 16.45 G / 17.26 G instructions |