perf(runtime): reduce activation collection sorting allocations

Merged
RE
2mo ago
+3-2

Activation shedding snapshots and orders collection buckets by due time. Using LINQ OrderBy allocated an additional sort buffer and iterator objects on every memory-pressure collection pass.

Sort the existing snapshot array in place instead. This preserves due-time ordering and concurrency safety while avoiding the extra allocations.

In a BenchmarkDotNet comparison with 500 buckets, the in-place sort reduced mean time from 33.87 us to 27.20 us (20% faster) and allocations from 21.79 KB to 7.84 KB (64% lower).

Microsoft Reviewers: Open in CodeFlow