dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.93k stars 480 forks source link

Change ResourceViewModel to use immutable dictionary #6668

Closed JamesNK closed 4 days ago

JamesNK commented 1 week ago

Description

I noticed FrozenDictionary showed up in profiling while I was fixing a memory leak - https://github.com/dotnet/aspire/pull/6666

We don't use this type anywhere else, and given that ResourceViewModel can be frequently updated (health checks, wait for, state, etc) a frozen dictionary doesn't seem like a good choice. There is probably more overhead in creating it vs a regular dictionary than time saved looking up its properties in an optimized fashion.

PR changes the type to immutable dictioanry.

Checklist