[00:00:06] Hi and thanks Maddie. Uh I'm Chet Husk. [00:00:08] I'm a PM that works on the SDK and the [00:00:11] .NET CLI and a whole bunch of the other [00:00:13] core tooling. [00:00:14] And we've got something really exciting [00:00:17] in store for everybody for .NET 11 that [00:00:19] I'm I'm very happy to take the next bit [00:00:21] of time to talk about. [00:00:23] Uh if you saw the keynote, then you saw [00:00:26] this slide and I wanted to sort of rest [00:00:28] on it here again for a minute to hammer [00:00:30] home why it's important that we invest [00:00:33] in the .NET CLI. Our whole ecosystem is [00:00:36] built on this thing and its usage is [00:00:38] only climbing. This chart tells part of [00:00:40] the story. [00:00:41] Billions and billions and billions of [00:00:43] commands get run on the .NET CLI every [00:00:47] month. And what that means is that every [00:00:50] command is an opportunity to cut the the [00:00:54] throughput, increase the efficiency, get [00:00:56] out of your way so that you can do what [00:00:59] you're trying to actually do instead of [00:01:02] whatever inefficiencies in our processes [00:01:04] might be doing, right? [00:01:06] So uh I want to start with some exciting [00:01:09] numbers that we are able to deliver in [00:01:11] .NET 11 for the .NET CLI now that we are [00:01:14] a native AOT app and then kind of do a [00:01:16] deep dive into how we got here and some [00:01:20] things that we learned because we are [00:01:21] all in on native AOT as a technology [00:01:24] now. We could not be happier for both [00:01:27] its present and its future uh uh in as [00:01:30] as a tech. [00:01:31] So let's without further ado, take a [00:01:34] look at some numbers. Um I love showing [00:01:36] these kinds of numbers off. So what we [00:01:39] have here are three different .NET CLI [00:01:41] commands that are kind of representative [00:01:44] of uh [00:01:45] scenario certain scenarios. So the first [00:01:47] one on the top is .NET version. This is [00:01:50] kind of a diagnostic command that you [00:01:51] might run similar to list SDKs or list [00:01:54] runtimes. This is to me kind of like the [00:01:57] bare minimum. If we cut out all of stuff [00:02:00] the .NET CLI does, how much more [00:02:02] efficient can we get? And the answer is [00:02:04] about two-thirds more efficient. Uh, [00:02:06] we cut off about 80 milliseconds as [00:02:08] measured on the laptop that you see [00:02:10] right here with the release bits, right? [00:02:13] Um, this is going to be a recurring [00:02:15] theme. We're going to see uh for .NET [00:02:17] tool list, which is a command that you [00:02:19] would use to see what local tools you [00:02:21] have installed. Again, cutting out about [00:02:25] 100 milliseconds off of every single one [00:02:27] of those interactions. [00:02:29] And it's not just commands that are [00:02:31] built into the .NET CLI itself. The CLI [00:02:34] has a very extensive uh sort of [00:02:36] pluggable tools ecosystem that other [00:02:39] teams inside Microsoft and the broader [00:02:42] community plugs into. And the work that [00:02:44] we've done to make the .NET CLI an AOT [00:02:47] application applies to you as well. So [00:02:50] we'll go a little bit more into this in [00:02:52] detail, but we've even made invoking [00:02:55] your tools faster and more efficient. [00:02:57] And you can see that here too with [00:02:59] another 100 milliseconds saved on this [00:03:01] machine. For context, this is an M1 uh [00:03:05] ARM64 macOS machine on the latest uh [00:03:09] macOS operating system. [00:03:11] So like [00:03:13] relatively modern but not top of the [00:03:14] line. And so if you have a faster [00:03:16] system, you will likely see even more [00:03:17] benefit. And if you have a slower system [00:03:19] or if you are on a system that has [00:03:21] spinning disks instead of SSD storage, [00:03:24] you will probably see even more drastic [00:03:26] deltas here. [00:03:28] Why does this efficiency matter? Well, [00:03:31] these were one-off command executions, [00:03:33] but we often don't execute just a single [00:03:35] command. We're often executing chains of [00:03:38] commands, whether ourselves or with an [00:03:39] agent operating on our behalf. So we've [00:03:42] got some simple scenarios here of like [00:03:45] trying to discover some information [00:03:47] about the SDK. And you can see that as [00:03:50] you [00:03:51] chain commands together, that reduced [00:03:53] overhead really starts to open up uh the [00:03:56] opportunity for uh aggregate [00:03:58] performance, right? So we are trying to [00:04:00] come at the .NET CLI now with an eye [00:04:03] towards [00:04:04] scale. If we can save X percent on an [00:04:07] interaction, if we can cut 20 [00:04:09] milliseconds off of a command at scale, [00:04:12] that matters. And that scale can be over [00:04:14] the course of your working day or over [00:04:16] the course of every .NET user ever [00:04:19] saving money. [00:04:21] Um so yeah, where can you use this [00:04:24] today? Where are you going to see the [00:04:25] benefits of native AOT? Well, like I [00:04:28] showed before, some of those core [00:04:29] diagnostic commands are plugged into [00:04:31] this. Um the entire sort of solution [00:04:34] management command structure is plugged [00:04:36] into this. Most .NET tool management, [00:04:39] including listing tools, running tools, [00:04:42] removing tools, and looking for new [00:04:43] tools, that's all uh AOT capable. [00:04:47] Tool execution, uh both global and local [00:04:51] uh and the built-in commands like EF, [00:04:53] that's all or not EF um user secrets and [00:04:56] Jwts and that sort of thing, all on [00:04:58] board. And then there are some more [00:05:00] exciting kind of happy paths here. So we [00:05:03] talked about file-based apps before. [00:05:05] They have a built-in cache so that the [00:05:08] first time that you run them, there's a [00:05:09] compile action that happens and then [00:05:12] subsequent times that you run them, [00:05:13] you're running built binaries. [00:05:15] That cached already built workflow is in [00:05:19] AOT now as well, which makes it [00:05:21] lightning fast. [00:05:22] Uh as well as if you're using the new [00:05:24] MTP test functionality, uh when you [00:05:27] don't do a build and you just run the [00:05:29] tests, you get to make use of AOT as [00:05:31] well. So uh these are all things that we [00:05:34] expand or intend to expand on in future [00:05:38] releases. So like the big next feature [00:05:40] areas we're looking to expand to are [00:05:43] anything build related, [00:05:45] closing the loop on tool installation [00:05:47] and restore, and then like the .NET [00:05:49] templating ecosystem. And we'll go into [00:05:52] a little bit more about why those areas [00:05:55] are interesting for AOT enablement in a [00:05:58] bit. [00:06:01] So that's what you can do now and what [00:06:02] you you you expect in the future. And I [00:06:04] kind of want to talk about the journey [00:06:06] we got there because I've said like five [00:06:08] times already in this talk that the .NET [00:06:10] CLI is a native AOT app, and I've been [00:06:13] lying to you the whole time. [00:06:15] It's not actually an app. It's a native [00:06:18] AOT library, and that's because of the [00:06:20] way the .NET platform works. [00:06:23] When you type dotnet exe or dotnet if [00:06:25] you're on Linux and macOS, you're not [00:06:28] running [00:06:29] what many people think of as the .NET [00:06:31] CLI, the thing that lets you build and [00:06:33] run and test. Instead, you're running [00:06:36] what's called the .NET muxer, which is a [00:06:38] pure native application whose entire job [00:06:42] is twofold. One, to launch arbitrary [00:06:45] .NET DLLs. So if you've ever run an app [00:06:48] with dotnet path to DLL, you're using [00:06:50] the muxer directly. [00:06:52] But the other thing it does is selects [00:06:54] and load an SDK. [00:06:56] And so all of that remains the same in [00:06:58] this world. We If we wanted the managed [00:07:01] .NET CLI to be able to be native AOT and [00:07:04] to get all of the performance [00:07:05] enhancements, we needed to expose a [00:07:09] native binary that the muxer could call [00:07:12] so that the muxer wouldn't have to do [00:07:15] all of the things it does for a normal [00:07:17] core CLR binary, [00:07:19] right? So this is how things work today. [00:07:22] The muxer finds the SDK, and if it finds [00:07:26] the AOT binary, it will load a C ABI [00:07:31] native method that we expose. [00:07:34] And then that's the entry point to all [00:07:36] of the AOT goodness I was just talking [00:07:37] about. And then from there, we do all of [00:07:39] the command line parsing for the entire [00:07:41] CLI, and we decide can we run this [00:07:44] command purely AOT or not? And if we can [00:07:48] run it purely AOT, then we do. And [00:07:50] that's all the things I showed a couple [00:07:52] slides ago. If we can't run it AOT, then [00:07:55] it becomes our job to do what the muxer [00:07:58] would typically do. We have to use the [00:08:00] host FXR resolver to find the [00:08:02] frameworks, to spin up a core CLR, to [00:08:05] then launch our managed version to do [00:08:07] the real command. So the net result of [00:08:10] this is same commands to end users, [00:08:14] better performance on the AOT commands, [00:08:16] and maintained compatibility with the [00:08:19] managed commands. And you would expect [00:08:21] those proportions of managed to [00:08:22] unmanaged commands to change over time [00:08:24] as we light up more commands. [00:08:28] Why did we choose the commands that we [00:08:30] currently chose to to sort of start this [00:08:33] journey with? [00:08:34] Well, [00:08:36] the .NET CLI was kind of a normal .NET [00:08:38] application, and by that I mean it was [00:08:40] an application that had a lot of [00:08:41] practices that weren't great for native [00:08:44] AOT. [00:08:46] And this is kind of two kinds of not [00:08:48] great. One is this programming model [00:08:50] will never work with AOT and needs to be [00:08:52] rewritten, and the other is it will work [00:08:55] with native AOT, but due to certain [00:08:57] decisions it will result in a larger AOT [00:09:00] binary. And balancing this size of the [00:09:04] binary has been an important topic [00:09:06] conversation for us, and we've made some [00:09:08] tools to help us analyze that. [00:09:11] But across the .NET CLI, we needed to [00:09:13] sort of audit cases where our own code [00:09:17] or the code of our library dependencies [00:09:19] made us unable to do native AOT [00:09:22] compilation. We had to take an audit of [00:09:25] any reflection-based discovery that we [00:09:27] did, including using things like [00:09:29] assembly location in a load-bearing way. [00:09:32] We had to look at cases where we did [00:09:33] runtime code generation and find [00:09:35] alternative strategies for those, and we [00:09:37] had to look at dependencies of ours that [00:09:39] did those things and identify alternate [00:09:41] strategies or work with those teams to [00:09:43] enable those dependencies to be AOT [00:09:46] friendly. [00:09:47] And sometimes this is [00:09:49] entire rewrites, which sucks, but is not [00:09:52] super frequent. But most of the time it [00:09:54] really just comes down to leveraging the [00:09:56] annotations and attributes that the [00:09:59] runtime team has already provided. In [00:10:01] many cases, if you can help the trimmer [00:10:04] understand the intent and the way that [00:10:07] your code flows, it can get you a large [00:10:09] part of the way And we found that [00:10:11] ourselves as we started rolling out AOT [00:10:13] commands in phases through our [00:10:15] architecture. [00:10:17] One of the biggest uh hurdles we kind of [00:10:20] ran into though was um a lack of [00:10:24] sort of domain design strength, right? [00:10:27] In the .NET SDK, one of the main things [00:10:29] we do is try and locate resources within [00:10:33] what I call the SDK installation root. [00:10:36] So if you've ever looked at the SDK on [00:10:37] disk, then you've probably seen the .NET [00:10:40] root where .NET exe or .NET bare lives. [00:10:44] And then there's an SDK directory and [00:10:46] then there's a bunch of versioned [00:10:47] directories within that. [00:10:50] Each of those versioned directories is [00:10:51] an SDK root and within it you'll find MS [00:10:54] build, you'll find Roslyn, you'll find [00:10:56] the F Sharp compiler, you'll find .NET [00:10:58] format, you'll find all of the [00:11:00] components that make that specific SDK. [00:11:04] And we were doing things like using the [00:11:06] location of an assembly in that [00:11:09] directory [00:11:10] as a launching off point to locate other [00:11:12] resources. This works great in a managed [00:11:15] application and the trimmers will flag [00:11:18] or the trimmer analyzers will flag this [00:11:20] and direct you towards equivalents like [00:11:22] app context base directory or [00:11:24] environment dot process path depending [00:11:26] on how you're using it. [00:11:28] The problem is for a native AOT library, [00:11:31] you don't actually have a real version [00:11:34] or a real value for either of those [00:11:36] things. [00:11:37] As a native AOT library, you don't [00:11:39] really have a base directory that is [00:11:42] meaningful to you. Practically for us, [00:11:45] when we would read these values, it [00:11:47] would report the value of the [00:11:49] application that was hosting us. So we [00:11:52] had assumptions that this value would be [00:11:55] the SDK versioned root, but in reality [00:11:57] it was the unversioned .NET root. So [00:12:00] this kind of forced us to strengthen our [00:12:02] architecture, to introduce a domain [00:12:04] concept of the SDK root and implement [00:12:07] strategies for locating that root that [00:12:09] were valid for each of our hosting [00:12:11] methods, the managed CLI and the [00:12:13] unmanaged library. [00:12:15] So this was in effect a good thing. It [00:12:18] has forced our architecture to become [00:12:19] more clear and to make it more obvious [00:12:23] how each component in our architecture [00:12:25] is used. [00:12:26] But that's an example of one of the [00:12:28] hurdles that we had to clear. [00:12:30] Another one is that we were kind of a [00:12:32] forcing function or we view ourselves as [00:12:34] a forcing function for key elements of [00:12:37] our ecosystem to push forward and become [00:12:39] AOT friendly. [00:12:40] The .NET CLI has a lot of dependencies. [00:12:43] We depend on MS Build, we depend on [00:12:44] NuGet, we depend on code from ASP.NET [00:12:46] Core and the runtime itself. All sorts [00:12:49] of things flow into us and we use those [00:12:51] things to deliver the functionality that [00:12:53] you all use so many times every day. [00:12:56] Some of those libraries are more or less [00:13:00] capable of AOT compilation and so this [00:13:03] began a partnership with those teams to [00:13:05] identify the concrete blockers [00:13:08] and to begin working on them, right? And [00:13:10] this is not an all or nothing [00:13:13] shift. This is a an incremental kind of [00:13:14] progressive enhancement where we [00:13:17] identify what use cases are most [00:13:19] important to us and work with those [00:13:21] teams to unblock those with an eye [00:13:23] towards eventually all scenarios being [00:13:25] available. [00:13:26] As a concrete example, we're working [00:13:28] with the NuGet team right now to enable [00:13:30] AOT writing and reading of the various [00:13:33] JSON files that the NuGet libraries used [00:13:36] to handle package management and package [00:13:38] asset tracking. That's necessary to do [00:13:42] tool installation and once those [00:13:44] features land in a future release, we [00:13:46] will be able to turn tool installation [00:13:48] AOT. So that entire tool set of commands [00:13:52] will be inside the AOT bubble, right? So [00:13:54] again, it's not all or nothing. It's a [00:13:56] continual process of improvement so that [00:13:58] we can enlighten each command at a time. [00:14:01] And kind of even more exciting, [00:14:03] we've done early experiments with doing [00:14:05] MS Build evaluation in the AOT bubble as [00:14:08] well. So these libraries are not just [00:14:10] foundational for the .NET CLI itself, [00:14:13] but they are kind of foundational [00:14:15] libraries for the whole ecosystem. So [00:14:16] investments in making them AOT friendly [00:14:19] open the door for community AOT tools of [00:14:22] all kinds. So I'm very excited to be [00:14:24] pushing forward there. [00:14:26] We also kind of ran into issues [00:14:29] balancing where work should happen in [00:14:32] our app. So as we are kind of strangler [00:14:35] figging our CLI application here, we had [00:14:38] to make sure that we did not do [00:14:40] duplicate work unnecessarily, both for [00:14:43] performance and for like data [00:14:44] consistency reasons. So one of the [00:14:47] lessons we have learned is to more [00:14:49] clearly identify what stages of the [00:14:52] command application different aspects of [00:14:55] work should happen. [00:14:56] So for things like telemetry where we [00:14:58] didn't want to emit duplicate data [00:15:00] accidentally, we wanted to make sure [00:15:03] that we held off on [snorts] publishing [00:15:06] any telemetry until we were sure which [00:15:07] branch we were going to go down. And [00:15:10] we're also experimenting at things like [00:15:12] a separate background process and a [00:15:14] producer consumer model to help ensure [00:15:17] that we don't send duplicate data here, [00:15:20] right? So pushing for native AOT has [00:15:22] again forced us to [00:15:25] more strictly look at our architecture [00:15:27] and design things that are correct by [00:15:29] construction. [00:15:30] So it's been great in that regard. [00:15:33] But everything we bring into the AOT [00:15:35] bubble has a cost. There's no free [00:15:37] lunch. When we started publishing this [00:15:39] AOT version of the .NET CLI, it was an [00:15:42] additional 5 megabytes of size to the [00:15:45] overall SDK bundle. [00:15:46] And that was with very little done. That [00:15:49] was just command parsing and not [00:15:52] actually implementing any command and [00:15:54] bumping it off to the managed CLI. So we [00:15:57] knew things were just going to get [00:15:58] bigger from there. [00:16:00] And so we started looking at ways of [00:16:01] analyzing the size increase. And the [00:16:03] simplest thing you can do is just a [00:16:06] pipeline or some tooling that on every [00:16:07] build checks the delta of size. And you [00:16:10] can see some examples of the size impact [00:16:12] of specific commands here. [00:16:15] When we made tool execution part of the [00:16:17] AOT bubble, we cut 100 milliseconds off [00:16:20] of that process on my machine, more or [00:16:22] less on yours, but we added 2 megabytes [00:16:25] to the size of the overall payload. So [00:16:27] we've had to make cost-benefit decisions [00:16:29] here. [00:16:30] In general, those decisions have been [00:16:33] beneficial, but they've forced us to [00:16:34] kind of reconcile with the overall size [00:16:37] of the SDK. [00:16:39] So in addition to making this new [00:16:41] parallel AOT CLI bundle, [00:16:45] we took a look at the overall size of [00:16:47] the .NET CLI. And this is work I'm super [00:16:49] happy about because it applies to [00:16:51] everyone regardless of if you use the [00:16:52] CLI in the AOT mode or not. [00:16:56] But Michael Simons took a look at the [00:16:58] bundles that we were making. So [00:17:00] literally the tarballs and zips that we [00:17:02] were creating with each release. [00:17:04] And he noticed that [00:17:06] due to the way that we package the SDK, [00:17:09] there were many duplicate assemblies. So [00:17:11] we were able to make use of symlinks and [00:17:13] specifically the support inside tarball [00:17:15] archives for symlinks and content-based [00:17:18] deduplicate [00:17:21] 53 megabytes of compressed binaries and [00:17:23] about 150 on Linux x64. [00:17:27] And that's just size reductions that [00:17:29] everyone gets for free. So if you are [00:17:31] pulling SDK container images now, you [00:17:34] get a smaller SDK [00:17:35] as a side effect almost of the AOT work [00:17:38] that we've done, right? [00:17:40] And so in our view, [00:17:41] we were able to sort of buy back some [00:17:43] space and so we are able to then claw [00:17:46] back some of that bought space, [00:17:48] approximately 15 to 20 megabytes for all [00:17:51] of the performance that we're getting. [00:17:53] So that's the cost-benefit that we've [00:17:54] made. [00:17:56] If you ship a purely native AOT [00:17:57] application, then you don't have to care [00:17:59] about shipping both kinds of bits, of [00:18:00] course. [00:18:02] But how do we judge that size in the [00:18:04] first place? Well, there's some tooling [00:18:06] that exists today for this and we've [00:18:08] also built some of some tooling of our [00:18:10] own. All of it is built on the raw data [00:18:13] that the current IL compilation [00:18:15] toolchain gives us. So there are some [00:18:17] flags that you can turn on in your [00:18:18] project file and when you do a .NET [00:18:20] publish of a native AOT application or [00:18:22] library uh from that point, you get [00:18:25] several files, some XML files and some [00:18:28] binary files [00:18:29] that describe the whole call chain and [00:18:32] uh rooted uh [00:18:35] methods, members of your application. [00:18:38] And then you can use tools like the Size [00:18:39] of Scope CLI or a tool I built called [00:18:42] Size of Spy, which is uh built on top of [00:18:45] the Size of Scope uh concept [00:18:47] to analyze reachability of code paths [00:18:50] and in the case of my Size of Spy tool, [00:18:52] look for what I call dominators, which [00:18:55] are code paths that are singularly [00:18:57] responsible for dragging in the most [00:19:00] code. [00:19:01] And you can make a cost-benefit decision [00:19:03] yourself uh in that regard. You can look [00:19:06] at if how worth it is to you. And so one [00:19:09] thing that we did in our repository was [00:19:11] we set up a slash command that you could [00:19:13] run on PRs that you thought would affect [00:19:15] the the size and do this analysis out of [00:19:17] band and get a size diff report for each [00:19:20] PR on each platform that we publish AOT [00:19:22] binaries for. And that's been helpful [00:19:24] for us to kind of level check and gauge [00:19:27] our uh our willingness to take a [00:19:29] particular change. [00:19:31] In the abstract, if a change cut 10 [00:19:32] milliseconds off of something but caused [00:19:35] an additional 8 megabytes of size, would [00:19:37] we take that change? Probably not. We'd [00:19:39] want to look for other things that were [00:19:41] less costly to get that same benefit, [00:19:43] right? [00:19:44] So the key point here that I've sort of [00:19:47] been thinking about more is that [00:19:50] with native AOT, you start caring about [00:19:52] size, and caring about size of your [00:19:54] binary changes the way you design your [00:19:56] APIs. [00:19:57] Um there are a few specific examples [00:19:59] we'll talk about in just a second, but [00:20:01] each time we see this size increase or [00:20:04] when we look at the size of the [00:20:05] application and do one of these analyses [00:20:07] and see an area that is exceedingly [00:20:09] large, [00:20:11] we try and ask what do we get out of [00:20:12] this chunk of size and can we get it [00:20:15] another way? [00:20:17] So some concrete instances that we've [00:20:19] looked at is XML parsing, for example. [00:20:22] My Size of 5 tool parses XML files, like [00:20:26] the DGML files that the IL uh compiler [00:20:29] emits and the trimmer emits. [00:20:31] And it looks for dominators, uh members [00:20:34] that are excessively sized inside that [00:20:36] file. But when I first did it, I was [00:20:39] using the BCL XML Reader APIs for this, [00:20:42] and my overall binary was something like [00:20:44] 15 megabytes per platform. [00:20:46] I ran my tool on my tool, and it said [00:20:49] that loading the XML was responsible for [00:20:51] about 5 megabytes of overall size, not [00:20:53] because parsing the XML is hard, but [00:20:56] because parsing XML involves XSDs, which [00:21:00] involves network access, which involves [00:21:02] crypto, [00:21:03] right? That's a whole chain of libraries [00:21:05] that had to come in to satisfy this one [00:21:07] requirement. So for my tool, because it [00:21:09] is very scoped to just reading these [00:21:11] files, I could write a recursive [00:21:14] hand-descent parser custom for that [00:21:15] format and save more than 5 megabytes on [00:21:18] every platform. [00:21:20] This is the kind of decision that you [00:21:21] can make for your tool when you are [00:21:23] aware of the size impact of your code. [00:21:25] And doing that then acts as a discussion [00:21:28] point to the .NET runtime and libraries [00:21:30] team. Hi, it seems like XML parsing is [00:21:33] relatively expensive. Here are the roots [00:21:36] that I found. How would we design this [00:21:38] API so that the trimmer can trim more [00:21:40] efficiently if I don't have XSDs, right? [00:21:43] Are there ways that I can tell the BCL [00:21:46] more about my intent so that we can get [00:21:49] the benefit for everyone that uses the [00:21:51] BCL libraries, right? [00:21:53] Uh [00:21:54] similar kind of area was embedded [00:21:55] resources. The AOT CLI by default embeds [00:21:59] a whole bunch of resources in it, [00:22:01] um just like any other application [00:22:03] would. But in our case, all of our [00:22:05] localization resources are still present [00:22:08] in the satellite assemblies that are in [00:22:09] the SDK payload. So for as long as we [00:22:12] ship the native AOT .NET CLI with the [00:22:14] entire SDK, we can look up resources [00:22:17] from those if we need to instead of [00:22:19] bundling them in our binary. And doing [00:22:21] this also saved a non-trivial amount of [00:22:24] size. So again, [00:22:26] knowing and understanding the size of [00:22:28] your binary can lead to interesting [00:22:29] design decisions to help mitigate that [00:22:31] size or reduce it. [00:22:34] Um in general, we found some kind of [00:22:36] interesting problematic areas. So [00:22:38] builder APIs and builder patterns in [00:22:40] your APIs can be really awesome, but [00:22:42] they are also really hard to annotate [00:22:44] such that the trimmer can trim out parts [00:22:46] that you don't use. So try narrower, [00:22:48] more specific purpose-built APIs. [00:22:51] Um there's a library called hex1b that [00:22:53] Mitch Denny wrote that is all about [00:22:55] terminal interpolation and replay. And [00:22:58] an API that the Aspire CLI was using was [00:23:01] using a sort of broad API that [00:23:05] internally pivoted to do different [00:23:07] operations, and some of those operations [00:23:09] were expensive. [00:23:10] The way the Aspire CLI was using this [00:23:12] particular API [00:23:13] didn't use any of those expensive [00:23:15] things. So by changing the [00:23:17] implementation of that one method, the [00:23:19] Aspire CLI could save, I think it was [00:23:21] like 300 kilobytes or something, right? [00:23:23] So none of these changes is going to be [00:23:25] huge in isolation, but taken together, [00:23:28] they can result in material changes to [00:23:30] the size of your application. [00:23:32] Uh and also like the trimmer operates on [00:23:34] this concept of like runtime feature [00:23:36] switches and capability checks. And it's [00:23:39] possible to create some of those on your [00:23:41] own so that you can encode [00:23:43] domain-specific knowledge or information [00:23:45] in your APIs that help the trimmer [00:23:47] identify dead code, right? So definitely [00:23:50] go read up on that and try that if you [00:23:52] are using your own APIs [00:23:54] or creating your own APIs that need to [00:23:56] be AOT friendly. [00:23:57] The last hurdle we had was uh testing [00:24:00] correctly. [00:24:01] Testing AOT libraries and AOT apps is [00:24:04] still kind of an emerging thing in our [00:24:05] ecosystem. [00:24:07] And so uh we of course used MS Test [00:24:09] because it supports AOT quite well. [00:24:12] Um but the big problem we had was we [00:24:15] needed an uh test harness that behaved [00:24:17] like the .NET muxer to get true [00:24:19] reproducibility, uh true parity with the [00:24:22] way the .NET muxer loaded us. So we [00:24:25] ended up building one called DN inside [00:24:27] of our repo that is used to help [00:24:28] validate the full end-to-end and not [00:24:30] just test the AOT logic that is run in [00:24:33] the muxer or in our application. So you [00:24:37] may need to write some additional code [00:24:38] to accurately test your AOT library or [00:24:41] application, but it's well worth it [00:24:42] because it can help identify parity [00:24:44] gaps. [00:24:45] Uh and parity was the most important [00:24:47] thing to us. We always wanted to if [00:24:48] there was any doubt on a particular AOT [00:24:51] code code path fall back to the managed [00:24:54] implementation because that we know is [00:24:56] correct and good and compatible for [00:24:58] everyone. [00:25:00] That's kind of the gist of all of this. [00:25:03] We think native AOT for the .NET CLI has [00:25:05] paid off beyond just the startup time [00:25:07] benefits, which are huge, right? Native [00:25:10] AOT has forced us to re-evaluate some of [00:25:12] the architecture of our application in a [00:25:14] way that is easier to expand and much [00:25:17] more clear about where responsibility [00:25:20] lies, right? And it has also allowed us [00:25:23] to incrementally grow portions of our [00:25:26] application so that it's not an [00:25:28] all-or-one migration. It's something [00:25:29] that can get better over time. I don't [00:25:31] know that we will ever have the entire [00:25:33] .NET CLI AOT, but I do know that we will [00:25:36] continue to push forward as much as we [00:25:38] can because the benefits are real and [00:25:41] that's all I can say on that. I highly [00:25:43] encourage everyone if you're building [00:25:45] CLI applications today, strongly [00:25:47] consider native AOT, uh especially if [00:25:49] your application gets any kind of broad [00:25:51] usage. Starting in .NET 10, we support [00:25:54] uh native AOT tools that can be RID [00:25:57] specific and so you don't even sacrifice [00:25:59] ergonomics there. Your .NET tools can be [00:26:02] both fast and easy to write. You don't [00:26:04] have to choose anymore. [00:26:06] So that's all I had on that.