When using Microsoft.Extensions.Hosting v10.0.5 (other versions not checked), and leveraging CreateApplicationBuilder on Linux, all directories in the current working tree are iterated and inotify watches created.
This can create a startup performance delay, and additionally present a denial-of-service risk as inotify watches can be easily exhausted.
I have only checked this on openSUSE Leap 15.6 6.4.0-150600.23.87-default.
Steps to reproduce:
- Create a project (dotnet new console)
- Add Microsoft.Extensions.Hosting (dotnet package add)
- Add the extensive code below:
_ = Host.CreateApplicationBuilder();
- Build (optimisations don't seem to have an impact as I first noticed this on a aot single-file program)
- Run from a suitably lofty parent working directory and check inotify watches
Helpful troubleshooting
Running your built program with 'strace' you should be able to see heaps of inotify_add_watch() function calls spewing forth.
Adding a Console.ReadLine() and then using a script to analyse inotify watches is another way of seeing the impact compared to the rest of your system.
When using Microsoft.Extensions.Hosting v10.0.5 (other versions not checked), and leveraging CreateApplicationBuilder on Linux, all directories in the current working tree are iterated and inotify watches created.
This can create a startup performance delay, and additionally present a denial-of-service risk as inotify watches can be easily exhausted.
I have only checked this on openSUSE Leap 15.6 6.4.0-150600.23.87-default.
Steps to reproduce:
Helpful troubleshooting
Running your built program with 'strace' you should be able to see heaps of inotify_add_watch() function calls spewing forth.
Adding a Console.ReadLine() and then using a script to analyse inotify watches is another way of seeing the impact compared to the rest of your system.