public void ColdStart_JitFailuresTest() { var path = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HostWarmupMiddleware).Assembly.CodeBase).LocalPath), WarmUpConstants.PreJitFolderName, WarmUpConstants.JitTraceFileName); var file = new FileInfo(path); Assert.True(file.Exists, $"Expected PGO file '{file.FullName}' does not exist. The file was either renamed or deleted."); JitTraceRuntime.Prepare(file, out int successfulPrepares, out int failedPrepares); var failurePercentage = (double)failedPrepares / successfulPrepares * 100; // using 1% as approximate number of allowed failures before we need to regenrate a new PGO file. Assert.True(failurePercentage < 1.0, $"Number of failed PGOs are more than 1 percent! Current number of failures are {failedPrepares}. This will definitely impact cold start! Time to regenrate PGOs and update the {WarmUpConstants.JitTraceFileName} file!"); }
private void PreJitPrepare() { // This is to PreJIT all methods captured in coldstart.jittrace file to improve cold start time var path = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HostWarmupMiddleware).Assembly.CodeBase).LocalPath), WarmUpConstants.PreJitFolderName, WarmUpConstants.JitTraceFileName); var file = new FileInfo(path); if (file.Exists) { JitTraceRuntime.Prepare(file, out int successfulPrepares, out int failedPrepares); // We will need to monitor failed vs success prepares and if the failures increase, it means code paths have diverged or there have been updates on dotnet core side. // When this happens, we will need to regenerate the coldstart.jittrace file. _logger.LogInformation(new EventId(100, "PreJit"), $"PreJIT Successful prepares: {successfulPrepares}, Failed prepares: {failedPrepares}"); } }