Skip to content

Instantly share code, notes, and snippets.

View AndyAyersMS's full-sized avatar

Andy Ayers AndyAyersMS

  • Microsoft
  • Newport, OR USA
  • 22:31 (UTC -07:00)
View GitHub Profile
@AndyAyersMS
AndyAyersMS / IteratorCeaShapeRepro.csproj
Created August 23, 2026 16:32
Indexed LINQ Where + Any iterator CEA shape benchmark
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Optimize>true</Optimize>
</PropertyGroup>
</Project>
@AndyAyersMS
AndyAyersMS / 0001-Use-acquire-reads-for-cast-cache-entries.patch
Created August 20, 2026 01:04
ARM64 LDAPR CastCache and VSD backpatch fixes for .NET 10.0.10
From aad563bbc3784792493afc917d6347da60465a3d Mon Sep 17 00:00:00 2001
From: Andy Ayers <andya@microsoft.com>
Date: Wed, 19 Aug 2026 17:51:14 -0700
Subject: [PATCH 1/2] Use acquire reads for cast cache entries
Replace the ARM64 load barrier in CastCache.TryGet with acquire reads of the source and target/result fields.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6bd43e03-841f-47ee-80f4-4da985b32a67
@AndyAyersMS
AndyAyersMS / Program.cs
Created August 20, 2026 00:21
ARM64 Virtual Stub Dispatch stale backpatch benchmark and .NET 10.0.10 fix
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
interface ITarget
{
int Invoke(int value);
}
@AndyAyersMS
AndyAyersMS / CastCacheBarrierTest.csproj
Created August 13, 2026 21:15
.NET ARM64 CastHelpers cast-cache dmb ishld stress test
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Optimize>true</Optimize>
</PropertyGroup>
</Project>
@AndyAyersMS
AndyAyersMS / jit-cse-writeup.md
Last active July 16, 2026 21:45
JIT CSE Heuristic Improvement via Oracle-Guided Imitation Learning

JIT CSE Heuristic Improvement via Oracle-Guided Imitation Learning

A methodology writeup for improving the .NET JIT's Common Subexpression Elimination (CSE) heuristic using RL and oracle-derived labels, with an emphasis on the evaluation loop. Written up so somebody else can leverage the pattern for a similar heuristic-improvement task.

Results delivered by this line of work:

  • v10, v11, v12b — successive imitation-learning models baked into the runtime as CSE_HeuristicImitation (~155KB weights, transformer over
@AndyAyersMS
AndyAyersMS / stack-allocation-diffs.md
Created June 24, 2024 18:49
Stack Allocation Diffs

Diffs are based on 2,219,596 contexts (807,447 MinOpts, 1,412,149 FullOpts).

MISSED contexts: base: 4,468 (0.20%), diff: 589 (0.03%)

Base JIT options: JitObjectStackAllocation=0

Overall (-18,212 bytes)
@AndyAyersMS
AndyAyersMS / diff.md
Created June 16, 2024 02:50
Stack allocate boxes diffs as of 6/15

Diffs are based on 1,872,949 contexts (616,222 MinOpts, 1,256,727 FullOpts).

MISSED contexts: base: 3,555 (0.19%), diff: 0 (0.00%)

Base JIT options: JitObjectStackAllocation=0

Overall (-16,169 bytes)
@AndyAyersMS
AndyAyersMS / jit.dump
Created April 30, 2024 02:10
Jit dump for runtime 101695
This file has been truncated, but you can view the full file.
****** START compiling System.Text.Json.JsonHelpers:TraverseGraphWithTopologicalSort[System.__Canon](System.__Canon,System.Func`2[System.__Canon,System.__Canon],System.Collections.Generic.IEqualityComparer`1[System.__Canon]):System.__Canon[] (MethodHash=ddfd2475)
Generating code for Unix x64
OPTIONS: Tier-1 compilation
OPTIONS: compCodeOpt = FAST_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
OPTIONS: compProcedureSplitting = false
OPTIONS: compProcedureSplittingEH = false
OPTIONS: optimizer should use profile data
@AndyAyersMS
AndyAyersMS / stats.txt
Created December 19, 2023 22:40
CSE stats from ASP.NET
115838 methods, 34802 methods with cses; 193807 cse candidates, 56973 cses
Count: Cses Candidates
1 [n: 10259 o: 0.53]: 0: 4836; 1: 5423
2 [n: 4913 o: 0.44]: 0: 1760; 1: 2028; 2: 1125
3 [n: 4058 o: 0.36]: 0: 1351; 1: 1329; 2: 1031; 3: 347
4 [n: 3454 o: 0.37]: 0: 788; 1: 1100; 2: 860; 3: 570; 4: 136
5 [n: 2576 o: 0.35]: 0: 586; 1: 497; 2: 792; 3: 470; 4: 175; 5: 56
6 [n: 1627 o: 0.31]: 0: 264; 1: 452; 2: 474; 3: 182; 4: 227; 5: 21; 6: 7
7 [n: 999 o: 0.33]: 0: 168; 1: 184; 2: 261; 3: 173; 4: 78; 5: 70; 6: 63; 7: 2
8 [n: 979 o: 0.28]: 0: 194; 1: 198; 2: 243; 3: 128; 4: 100; 5: 42; 6: 36; 7: 15; 8: 23
@AndyAyersMS
AndyAyersMS / diffs.md
Created June 28, 2023 15:41
Block jump thread phi if block has memory phi

Diffs are based on 1,514,429 contexts (459,672 MinOpts, 1,054,757 FullOpts).

MISSED contexts: base: 12,403 (0.82%), diff: 12,404 (0.82%)

Overall (+117,686 bytes)

|Collection|Base size (bytes)|Diff size (bytes)|