Skip to content

Commit

Permalink
Added: Multicore-JIT back to help avoid I/O bottleneck after cold boot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Jul 29, 2022
1 parent cd89921 commit 8b5fed4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 29 additions & 1 deletion source/Reloaded.Mod.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using static System.Environment;
using System.Runtime;
using static System.Environment;
using Paths = Reloaded.Mod.Loader.IO.Paths;

namespace Reloaded.Mod.Launcher;

Expand Down Expand Up @@ -36,6 +38,7 @@ private void OnStartup(object sender, StartupEventArgs e)
}

Application.Current.ShutdownMode = originalMode;
StartProfileOptimization();
}

private void SetupResources()
Expand Down Expand Up @@ -77,4 +80,29 @@ void TryAssignResource(string originalResource, string targetResource)
Current.MainWindow.InvalidateVisual();
}
}

/// <summary>
/// Starts profile-optimization a.k.a. 'Multicore JIT'.
/// We're not actually using this for the async JIT but to load other DLLs on a background thread to avoid an I/O bottleneck.
/// </summary>
public static void StartProfileOptimization()
{
// Start Profile Optimization
var profileRoot = Path.Combine(Paths.ConfigFolder, "ProfileOptimization");
Directory.CreateDirectory(profileRoot);

// Define the folder where to save the profile files.
ProfileOptimization.SetProfileRoot(profileRoot);

// Start profiling.
ProfileOptimization.StartProfile("Launcher-startup.profile");
}

/// <summary>
/// Finishes profile-optimization a.k.a. 'Multicore JIT'
/// </summary>
public static void StopProfileOptimization()
{
ProfileOptimization.StartProfile(null!);
}
}
1 change: 1 addition & 0 deletions source/Reloaded.Mod.Launcher/Pages/SplashPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private async void Load()
await _setupApplicationTask;
ChangeToMainPage();
_ = Task.Run(ControllerSupport.Init);
App.StopProfileOptimization();
DisplayFirstLaunchWarningIfNeeded();
}
catch (Exception ex)
Expand Down

0 comments on commit 8b5fed4

Please sign in to comment.