|
5 | 5 | using System.Collections.Generic; |
6 | 6 | using System.Linq; |
7 | 7 | using System.Net; |
| 8 | +using System.Threading; |
8 | 9 | using System.Threading.Tasks; |
9 | 10 | using System.Web; |
10 | 11 | using System.Web.Hosting; |
11 | 12 | using System.Web.Http; |
12 | 13 | using System.Web.Mvc; |
13 | 14 | using Elmah; |
| 15 | +using Microsoft.Extensions.Logging; |
14 | 16 | using Microsoft.Owin; |
15 | 17 | using Microsoft.Owin.Logging; |
16 | 18 | using Microsoft.Owin.Security; |
|
20 | 22 | using NuGetGallery.Authentication.Providers; |
21 | 23 | using NuGetGallery.Authentication.Providers.Cookie; |
22 | 24 | using NuGetGallery.Configuration; |
| 25 | +using NuGetGallery.Diagnostics; |
23 | 26 | using NuGetGallery.Infrastructure; |
24 | 27 | using Owin; |
25 | 28 |
|
| 29 | +using ILoggerFactory = Microsoft.Extensions.Logging.ILoggerFactory; |
| 30 | + |
26 | 31 | [assembly: OwinStartup(typeof(NuGetGallery.OwinStartup))] |
27 | 32 |
|
28 | 33 | namespace NuGetGallery |
@@ -91,6 +96,24 @@ public static void Configuration(IAppBuilder app) |
91 | 96 | } |
92 | 97 | } |
93 | 98 |
|
| 99 | + var tds = new TraceDiagnosticsSource(nameof(OwinStartup), dependencyResolver.GetService<ITelemetryClient>()); |
| 100 | + if (config.Current.MaxWorkerThreads.HasValue && config.Current.MaxIoThreads.HasValue) |
| 101 | + { |
| 102 | + int defaultMaxWorkerThreads, defaultMaxIoThreads; |
| 103 | + ThreadPool.GetMaxThreads(out defaultMaxWorkerThreads, out defaultMaxIoThreads); |
| 104 | + tds.Information($"Default maxWorkerThreads: {defaultMaxWorkerThreads}, maxIoThreads: {defaultMaxIoThreads}"); |
| 105 | + var success = ThreadPool.SetMaxThreads(config.Current.MaxWorkerThreads.Value, config.Current.MaxIoThreads.Value); |
| 106 | + tds.Information($"Attempt to update max threads to {config.Current.MaxWorkerThreads.Value}, {config.Current.MaxIoThreads.Value}, success: {success}"); |
| 107 | + } |
| 108 | + if (config.Current.MinWorkerThreads.HasValue && config.Current.MinIoThreads.HasValue) |
| 109 | + { |
| 110 | + int defaultMinWorkerThreads, defaultMinIoThreads; |
| 111 | + ThreadPool.GetMinThreads(out defaultMinWorkerThreads, out defaultMinIoThreads); |
| 112 | + tds.Information($"Default minWorkerThreads: {defaultMinWorkerThreads}, minIoThreads: {defaultMinIoThreads}"); |
| 113 | + var success = ThreadPool.SetMinThreads(config.Current.MinWorkerThreads.Value, config.Current.MinIoThreads.Value); |
| 114 | + tds.Information($"Attempt to update min threads to {config.Current.MinWorkerThreads.Value}, {config.Current.MinIoThreads.Value}, success: {success}"); |
| 115 | + } |
| 116 | + |
94 | 117 | // Get the local user auth provider, if present and attach it first |
95 | 118 | Authenticator localUserAuthenticator; |
96 | 119 | if (auth.Authenticators.TryGetValue(Authenticator.GetName(typeof(LocalUserAuthenticator)), out localUserAuthenticator)) |
|
0 commit comments