System.Collections.Generic.List
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.Collections.Generic.List<T> and its enumerator (src/Csharpc/upstream-types/, a CoreLib type: the first type-level flip) |
all 184 samples that use List<T> or CollectionsMarshal pass at -O2 with the shadow gone (CI runs the whole suite on five platforms); the framework’s own Insert/RemoveAt use Array.Copy where the shadow moved elements one by one |
1.00x to 1.05x: collections 140 856 to 143 400 B (+1.8 %), linq 164 552 to 170 424 (+3.6 %), a List sort program 131 056 to 137 664 (+5.0 %), a large List program 178 800 to 186 992 (+4.6 %), regex +4.4 %, hello/numbers/exceptions/typeinfo/async unchanged | 1.0x (3.5 to 3.6 s for a small program, 5.9 to 5.2 s for a large one: noise) | instructions, 1 M operations: Add 14.3 M to 19.0 M (+33 %, the framework’s Add calls the NoInlining AddWithResize, so size and version stay in memory: #259), RemoveAll +14 %, Sort +1 %, indexer, foreach, LINQ, IndexOf/Contains equal (after #258: Array.IndexOf uses the runtime’s vectorized search), Insert(0, x) 800 M to 40 M (20x faster) |
598 in corelib (List.cs 595: ListImpl, its enumerator and the old CollectionsMarshalImpl; LinqSpans loses its ListImpl fast path; 55 added: CollectionsMarshal over the framework’s List<T> through [UnsafeAccessor]), against 617 deleted and 183 added over src and tests |
Flipped: the first CoreLib type served from System.Private.CoreLib’s IL, shipped as a build product (CsharpcUpstream.dll and its map, cut by tools/il-first/slicer after every build of the compiler; Mono.Cecil is a build-time tool dependency only). The owner accepted the Add and RemoveAll costs and about +5 % size; #259 closes the Add gap in the compiler. |
list_throughput: 149 160 / 1 345 360 B; compile cpu 6.5 / 17.4 s; run 912 / 1 483 ms (0.61x); 6.05 G / 11.86 G instructions |