New ask Hacker News story: Ask HN: C# reloadOnChange=true slows down startup on Linux by 2.2 seconds. Why?
Ask HN: C# reloadOnChange=true slows down startup on Linux by 2.2 seconds. Why?
2 by sandreas | 1 comments on Hacker News.
I asked this question on stackoverflow, but nobody seems to have an answer yet. Maybe you guys could help. Using the configBuilder with reloadOnChange=true leads to a HUGE slowdown in startup time (usually >1000% - in bigger apps 10 seconds and more). It is dotnet 6 with release mode producing a single executable binary... The line that matters is: configBuilder.AddJsonFile(f, true, true); Here is the full code: var configBuilder = new ConfigurationBuilder(); var configFiles = new[] { Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), // the files below do not exist, not even the directory - just a fallback Path.Combine(Environment.GetFolderPath(UserProfile, DoNotVerify), ".tester/appsettings.json"), Path.Combine(Environment.GetFolderPath(ApplicationData, DoNotVerify), "tester/appsettings.json"), }; foreach (var f in configFiles) { // using the line below works fast like expected // configBuilder.AddJsonFile(f, true, false); // HUGE slowdown of app startup with second parameter set to true. Why? configBuilder.AddJsonFile(f, true, true); } var config = configBuilder.Build(); Console.WriteLine("tester"); More details: https://ift.tt/rL1ubkF
2 by sandreas | 1 comments on Hacker News.
I asked this question on stackoverflow, but nobody seems to have an answer yet. Maybe you guys could help. Using the configBuilder with reloadOnChange=true leads to a HUGE slowdown in startup time (usually >1000% - in bigger apps 10 seconds and more). It is dotnet 6 with release mode producing a single executable binary... The line that matters is: configBuilder.AddJsonFile(f, true, true); Here is the full code: var configBuilder = new ConfigurationBuilder(); var configFiles = new[] { Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json"), // the files below do not exist, not even the directory - just a fallback Path.Combine(Environment.GetFolderPath(UserProfile, DoNotVerify), ".tester/appsettings.json"), Path.Combine(Environment.GetFolderPath(ApplicationData, DoNotVerify), "tester/appsettings.json"), }; foreach (var f in configFiles) { // using the line below works fast like expected // configBuilder.AddJsonFile(f, true, false); // HUGE slowdown of app startup with second parameter set to true. Why? configBuilder.AddJsonFile(f, true, true); } var config = configBuilder.Build(); Console.WriteLine("tester"); More details: https://ift.tt/rL1ubkF
Comments
Post a Comment