mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-23 13:45:49 +00:00
Configured the garbage collector for lower spikes (#88)
Did you know that the garbage collector's default settings are designed for single-threaded applications and quick start-up times? We don't care about either of these. Configured: - Concurrent GC (default is true) (set for clarity) - RetainVM: segments that should be deleted are put on a standby list for future use (default is false) - QuickJit: enabling quick JIT decreases startup time but can produce code with degraded performance characteristics; for example, the code may use more stack space, allocate more memory, and run slower. (default is true) (disabled) - ReadyToRun: configures whether the .NET runtime uses pre-compiled code for images with available ReadyToRun data; disabling this option forces the runtime to JIT-compile framework code. (default is true) (set to false, we dont publish with this option anyway) - TieredPGO: this setting enables dynamic (tiered) profile-guided optimization (PGO) in .NET 6 and later versions. If quick JIT is disabled but tiered compilation is enabled, only pre-compiled code participates in tiered compilation. If a method is not pre-compiled with ReadyToRun, the JIT behavior is the same as if tiered compilation were disabled. Features: - Set ``GCLatencyMode.Interactive`` when in-menu and emulator is paused, otherwise uses ``GCLatencyMode.LowLatency``. - Added a new UI option in the Settings > CPU menu to toggle ``GCLatencyMode.LowLatency`` during guest runtime.  Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/88
This commit is contained in:
@@ -200,6 +200,31 @@
|
|||||||
"zh_TW": "使用 Hypervisor"
|
"zh_TW": "使用 Hypervisor"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ID": "SettingsTabSystemGCLowLatency",
|
||||||
|
"Translations": {
|
||||||
|
"ar_SA": "",
|
||||||
|
"de_DE": "",
|
||||||
|
"el_GR": "",
|
||||||
|
"en_US": "Use Low-latency Garbage Collector",
|
||||||
|
"es_ES": "Usa recolección de basura de baja latencia",
|
||||||
|
"fr_FR": "",
|
||||||
|
"he_IL": "",
|
||||||
|
"it_IT": "",
|
||||||
|
"ja_JP": "",
|
||||||
|
"ko_KR": "",
|
||||||
|
"no_NO": "",
|
||||||
|
"pl_PL": "",
|
||||||
|
"pt_BR": "",
|
||||||
|
"ru_RU": "",
|
||||||
|
"sv_SE": "",
|
||||||
|
"th_TH": "",
|
||||||
|
"tr_TR": "",
|
||||||
|
"uk_UA": "",
|
||||||
|
"zh_CN": "",
|
||||||
|
"zh_TW": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ID": "MenuBarFile",
|
"ID": "MenuBarFile",
|
||||||
"Translations": {
|
"Translations": {
|
||||||
@@ -16550,6 +16575,31 @@
|
|||||||
"zh_TW": "變更客體記憶體的映射和存取方式。這會極大地影響模擬 CPU 效能。\n\n如果不確定,請設定為主體略過檢查模式。"
|
"zh_TW": "變更客體記憶體的映射和存取方式。這會極大地影響模擬 CPU 效能。\n\n如果不確定,請設定為主體略過檢查模式。"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ID": "GCLowLatencyTooltip",
|
||||||
|
"Translations": {
|
||||||
|
"ar_SA": "",
|
||||||
|
"de_DE": "",
|
||||||
|
"el_GR": "",
|
||||||
|
"en_US": "Sets the garbage collector for the CLR to low-latency mode.\n\nThis may decrease stuttering at the cost of performance.\n\nLeave OFF if unsure.",
|
||||||
|
"es_ES": "",
|
||||||
|
"fr_FR": "",
|
||||||
|
"he_IL": "",
|
||||||
|
"it_IT": "",
|
||||||
|
"ja_JP": "",
|
||||||
|
"ko_KR": "",
|
||||||
|
"no_NO": "",
|
||||||
|
"pl_PL": "",
|
||||||
|
"pt_BR": "",
|
||||||
|
"ru_RU": "",
|
||||||
|
"sv_SE": "",
|
||||||
|
"th_TH": "",
|
||||||
|
"tr_TR": "",
|
||||||
|
"uk_UA": "",
|
||||||
|
"zh_CN": "",
|
||||||
|
"zh_TW": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ID": "MemoryManagerSoftwareTooltip",
|
"ID": "MemoryManagerSoftwareTooltip",
|
||||||
"Translations": {
|
"Translations": {
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
|||||||
|
|
||||||
using SKBitmap bitmap = new(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
using SKBitmap bitmap = new(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
||||||
|
|
||||||
IntPtr pixels = bitmap.GetPixels();
|
nint pixels = bitmap.GetPixels();
|
||||||
|
|
||||||
if (pixels == IntPtr.Zero)
|
if (pixels == 0)
|
||||||
{
|
{
|
||||||
return ResultCode.InvalidArgument;
|
return ResultCode.InvalidArgument;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,6 +198,12 @@ namespace Ryujinx.Ava
|
|||||||
public static AppBuilder BuildAvaloniaApp() =>
|
public static AppBuilder BuildAvaloniaApp() =>
|
||||||
AppBuilder.Configure<RyujinxApp>()
|
AppBuilder.Configure<RyujinxApp>()
|
||||||
.UsePlatformDetect()
|
.UsePlatformDetect()
|
||||||
|
|
||||||
|
// Vulkan UI rendering performs better, but its unpolished, and as such it lacks effective transparency.
|
||||||
|
// https://github.com/AvaloniaUI/Avalonia/issues/19378
|
||||||
|
// https://github.com/AvaloniaUI/Avalonia/issues/9610
|
||||||
|
// X11RenderingMode.Glx && X11RenderingMode.Egl, Win32RenderingMode.Vulkan have these issues.
|
||||||
|
|
||||||
.With(new X11PlatformOptions
|
.With(new X11PlatformOptions
|
||||||
{
|
{
|
||||||
EnableMultiTouch = true,
|
EnableMultiTouch = true,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -579,6 +580,12 @@ namespace Ryujinx.Ava.Systems
|
|||||||
{
|
{
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
_playTimer.Stop();
|
_playTimer.Stop();
|
||||||
|
|
||||||
|
GCSettings.LatencyMode = GCLatencyMode.Interactive;
|
||||||
|
if (ConfigurationState.Instance.System.GCLowLatency)
|
||||||
|
{
|
||||||
|
Logger.Info?.Print(LogClass.Application, "Garbage collector set to interactive mode.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Exit()
|
private void Exit()
|
||||||
@@ -662,6 +669,12 @@ namespace Ryujinx.Ava.Systems
|
|||||||
|
|
||||||
_chrono.Stop();
|
_chrono.Stop();
|
||||||
_playTimer.Stop();
|
_playTimer.Stop();
|
||||||
|
|
||||||
|
GCSettings.LatencyMode = GCLatencyMode.Interactive;
|
||||||
|
if (ConfigurationState.Instance.System.GCLowLatency)
|
||||||
|
{
|
||||||
|
Logger.Info?.Print(LogClass.Application, "Garbage collector set to interactive mode.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeGpu()
|
public void DisposeGpu()
|
||||||
@@ -915,7 +928,14 @@ namespace Ryujinx.Ava.Systems
|
|||||||
ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
|
ApplicationLibrary.LoadAndSaveMetaData(Device.Processes.ActiveApplication.ProgramIdText,
|
||||||
appMetadata => appMetadata.UpdatePreGame()
|
appMetadata => appMetadata.UpdatePreGame()
|
||||||
);
|
);
|
||||||
|
|
||||||
_playTimer.Start();
|
_playTimer.Start();
|
||||||
|
|
||||||
|
if (ConfigurationState.Instance.System.GCLowLatency)
|
||||||
|
{
|
||||||
|
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
|
||||||
|
Logger.Info?.Print(LogClass.Application, "Garbage collector set to low latency mode.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Resume()
|
internal void Resume()
|
||||||
@@ -926,6 +946,12 @@ namespace Ryujinx.Ava.Systems
|
|||||||
_playTimer.Start();
|
_playTimer.Start();
|
||||||
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device?.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowOldUI);
|
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device?.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowOldUI);
|
||||||
Logger.Info?.Print(LogClass.Emulation, "Emulation was resumed.");
|
Logger.Info?.Print(LogClass.Emulation, "Emulation was resumed.");
|
||||||
|
|
||||||
|
if (ConfigurationState.Instance.System.GCLowLatency)
|
||||||
|
{
|
||||||
|
GCSettings.LatencyMode = GCLatencyMode.LowLatency;
|
||||||
|
Logger.Info?.Print(LogClass.Application, "Garbage collector set to low latency mode.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Pause()
|
internal void Pause()
|
||||||
@@ -936,6 +962,12 @@ namespace Ryujinx.Ava.Systems
|
|||||||
_playTimer.Stop();
|
_playTimer.Stop();
|
||||||
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device?.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowOldUI, LocaleManager.Instance[LocaleKeys.Paused]);
|
_viewModel.Title = TitleHelper.ActiveApplicationTitle(Device?.Processes.ActiveApplication, Program.Version, !ConfigurationState.Instance.ShowOldUI, LocaleManager.Instance[LocaleKeys.Paused]);
|
||||||
Logger.Info?.Print(LogClass.Emulation, "Emulation was paused.");
|
Logger.Info?.Print(LogClass.Emulation, "Emulation was paused.");
|
||||||
|
|
||||||
|
GCSettings.LatencyMode = GCLatencyMode.Interactive;
|
||||||
|
if (ConfigurationState.Instance.System.GCLowLatency)
|
||||||
|
{
|
||||||
|
Logger.Info?.Print(LogClass.Application, "Garbage collector set to interactive mode.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitEmulatedSwitch()
|
private void InitEmulatedSwitch()
|
||||||
|
|||||||
@@ -470,6 +470,11 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
/// Uses Hypervisor over JIT if available
|
/// Uses Hypervisor over JIT if available
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseHypervisor { get; set; }
|
public bool UseHypervisor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable low-latency mode for garbage collection
|
||||||
|
/// </summary>
|
||||||
|
public bool GCLowLatency { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enables or disables the GDB stub
|
/// Enables or disables the GDB stub
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
System.IgnoreControllerApplet.Value = cff.IgnoreApplet;
|
System.IgnoreControllerApplet.Value = cff.IgnoreApplet;
|
||||||
System.SkipUserProfilesManager.Value = cff.SkipUserProfiles;
|
System.SkipUserProfilesManager.Value = cff.SkipUserProfiles;
|
||||||
System.UseHypervisor.Value = cff.UseHypervisor;
|
System.UseHypervisor.Value = cff.UseHypervisor;
|
||||||
|
System.GCLowLatency.Value = cff.GCLowLatency;
|
||||||
|
|
||||||
UI.GuiColumns.FavColumn.Value = shouldLoadFromFile ? cff.GuiColumns.FavColumn : UI.GuiColumns.FavColumn.Value;
|
UI.GuiColumns.FavColumn.Value = shouldLoadFromFile ? cff.GuiColumns.FavColumn : UI.GuiColumns.FavColumn.Value;
|
||||||
UI.GuiColumns.IconColumn.Value = shouldLoadFromFile ? cff.GuiColumns.IconColumn : UI.GuiColumns.IconColumn.Value;
|
UI.GuiColumns.IconColumn.Value = shouldLoadFromFile ? cff.GuiColumns.IconColumn : UI.GuiColumns.IconColumn.Value;
|
||||||
@@ -535,7 +536,8 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
{
|
{
|
||||||
if (cff.AudioBackend is AudioBackend.SDL2)
|
if (cff.AudioBackend is AudioBackend.SDL2)
|
||||||
cff.AudioBackend = AudioBackend.SDL3;
|
cff.AudioBackend = AudioBackend.SDL3;
|
||||||
})
|
}),
|
||||||
|
(72, static cff => cff.GCLowLatency = false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,6 +417,11 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
/// Uses Hypervisor over JIT if available
|
/// Uses Hypervisor over JIT if available
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<bool> UseHypervisor { get; private set; }
|
public ReactiveObject<bool> UseHypervisor { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable low-latency garbage collection
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<bool> GCLowLatency { get; private set; }
|
||||||
|
|
||||||
public SystemSection()
|
public SystemSection()
|
||||||
{
|
{
|
||||||
@@ -471,6 +476,8 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
AudioVolume.LogChangesToValue(nameof(AudioVolume));
|
AudioVolume.LogChangesToValue(nameof(AudioVolume));
|
||||||
UseHypervisor = new ReactiveObject<bool>();
|
UseHypervisor = new ReactiveObject<bool>();
|
||||||
UseHypervisor.LogChangesToValue(nameof(UseHypervisor));
|
UseHypervisor.LogChangesToValue(nameof(UseHypervisor));
|
||||||
|
GCLowLatency = new ReactiveObject<bool>();
|
||||||
|
GCLowLatency.LogChangesToValue(nameof(GCLowLatency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||||||
IgnoreApplet = System.IgnoreControllerApplet,
|
IgnoreApplet = System.IgnoreControllerApplet,
|
||||||
SkipUserProfiles = System.SkipUserProfilesManager,
|
SkipUserProfiles = System.SkipUserProfilesManager,
|
||||||
UseHypervisor = System.UseHypervisor,
|
UseHypervisor = System.UseHypervisor,
|
||||||
|
GCLowLatency = System.GCLowLatency,
|
||||||
GuiColumns = new GuiColumns
|
GuiColumns = new GuiColumns
|
||||||
{
|
{
|
||||||
FavColumn = UI.GuiColumns.FavColumn,
|
FavColumn = UI.GuiColumns.FavColumn,
|
||||||
|
|||||||
@@ -2066,7 +2066,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
// Remove window chrome: WS_OVERLAPPEDWINDOW -> WS_POPUP | WS_VISIBLE
|
// Remove window chrome: WS_OVERLAPPEDWINDOW -> WS_POPUP | WS_VISIBLE
|
||||||
Win32NativeInterop.SetWindowLongPtrW(hwnd, Win32NativeInterop.GWL_STYLE,
|
Win32NativeInterop.SetWindowLongPtrW(hwnd, Win32NativeInterop.GWL_STYLE,
|
||||||
unchecked((nint)(Win32NativeInterop.WS_POPUP | Win32NativeInterop.WS_VISIBLE)));
|
unchecked((nint)(Win32NativeInterop.WS_POPUP | Win32NativeInterop.WS_VISIBLE)));
|
||||||
|
|
||||||
|
// TODO: why is this nullable
|
||||||
Avalonia.Platform.Screen? screen = Window.Screens.ScreenFromVisual(Window);
|
Avalonia.Platform.Screen? screen = Window.Screens.ScreenFromVisual(Window);
|
||||||
int w = screen?.Bounds.Width ?? 0;
|
int w = screen?.Bounds.Width ?? 0;
|
||||||
int h = screen?.Bounds.Height ?? 0;
|
int h = screen?.Bounds.Height ?? 0;
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
public bool IsVulkanSelected =>
|
public bool IsVulkanSelected =>
|
||||||
GraphicsBackendIndex == 1 || (GraphicsBackendIndex == 0 && !OperatingSystem.IsMacOS());
|
GraphicsBackendIndex == 1 || (GraphicsBackendIndex == 0 && !OperatingSystem.IsMacOS());
|
||||||
public bool UseHypervisor { get; set; }
|
public bool UseHypervisor { get; set; }
|
||||||
|
public bool GCLowLatency { get; set; }
|
||||||
public bool DisableP2P { get; set; }
|
public bool DisableP2P { get; set; }
|
||||||
|
|
||||||
public bool ShowDirtyHacks => ConfigurationState.Instance.Hacks.ShowDirtyHacks;
|
public bool ShowDirtyHacks => ConfigurationState.Instance.Hacks.ShowDirtyHacks;
|
||||||
@@ -689,6 +690,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
EnableLowPowerPptc = config.System.EnableLowPowerPtc;
|
EnableLowPowerPptc = config.System.EnableLowPowerPtc;
|
||||||
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
MemoryMode = (int)config.System.MemoryManagerMode.Value;
|
||||||
UseHypervisor = config.System.UseHypervisor;
|
UseHypervisor = config.System.UseHypervisor;
|
||||||
|
GCLowLatency = config.System.GCLowLatency;
|
||||||
TurboMultiplier = config.System.TickScalar;
|
TurboMultiplier = config.System.TickScalar;
|
||||||
|
|
||||||
// Graphics
|
// Graphics
|
||||||
@@ -800,6 +802,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
config.System.EnableLowPowerPtc.Value = EnableLowPowerPptc;
|
config.System.EnableLowPowerPtc.Value = EnableLowPowerPptc;
|
||||||
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
config.System.MemoryManagerMode.Value = (MemoryManagerMode)MemoryMode;
|
||||||
config.System.UseHypervisor.Value = UseHypervisor;
|
config.System.UseHypervisor.Value = UseHypervisor;
|
||||||
|
config.System.GCLowLatency.Value = GCLowLatency;
|
||||||
config.System.TickScalar.Value = TurboMultiplier;
|
config.System.TickScalar.Value = TurboMultiplier;
|
||||||
|
|
||||||
// Graphics
|
// Graphics
|
||||||
|
|||||||
@@ -71,6 +71,11 @@
|
|||||||
<TextBlock Text="{ext:Locale SettingsTabSystemUseHypervisor}"
|
<TextBlock Text="{ext:Locale SettingsTabSystemUseHypervisor}"
|
||||||
ToolTip.Tip="{ext:Locale UseHypervisorTooltip}" />
|
ToolTip.Tip="{ext:Locale UseHypervisorTooltip}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox
|
||||||
|
IsChecked="{Binding GCLowLatency}"
|
||||||
|
ToolTip.Tip="{ext:Locale GCLowLatencyTooltip}">
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabSystemGCLowLatency}" />
|
||||||
|
</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Separator Height="1" />
|
<Separator Height="1" />
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
|||||||
11
src/Ryujinx/runtimeconfig.template.json
Normal file
11
src/Ryujinx/runtimeconfig.template.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"configProperties": {
|
||||||
|
"System.GC.Concurrent": true,
|
||||||
|
"System.GC.Server": false,
|
||||||
|
"System.GC.RetainVM": true,
|
||||||
|
"System.Runtime.TieredCompilation.QuickJit": false,
|
||||||
|
"System.Runtime.TieredCompilation.QuickJitForLoops": false,
|
||||||
|
"DOTNET_ReadyToRun": false,
|
||||||
|
"DOTNET_TieredPGO": true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user