mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Implemented workqueue limiter settings on starting batch
This commit is contained in:
parent
b3a61a00a7
commit
a3450900a3
@ -47,6 +47,11 @@ namespace Wabbajack.Lib
|
||||
|
||||
private readonly CompositeDisposable _subs = new CompositeDisposable();
|
||||
|
||||
// WorkQueue settings
|
||||
public bool ManualCoreLimit = true;
|
||||
public byte MaxCores = byte.MaxValue;
|
||||
public double TargetUsagePercent = 1.0d;
|
||||
|
||||
protected void ConfigureProcessor(int steps, int threads = 0)
|
||||
{
|
||||
if (1 == Interlocked.CompareExchange(ref _configured, 1, 1))
|
||||
@ -64,6 +69,33 @@ namespace Wabbajack.Lib
|
||||
VFS = new Context(Queue) { UpdateTracker = UpdateTracker };
|
||||
}
|
||||
|
||||
public async Task<int> RecommendQueueSize()
|
||||
{
|
||||
const ulong GB = (1024 * 1024 * 1024);
|
||||
// Most of the heavy lifting is done on the scratch disk, so we'll use the value from that disk
|
||||
var memory = Utils.GetMemoryStatus();
|
||||
// Assume roughly 2GB of ram needed to extract each 7zip archive, and then leave 2GB for the OS
|
||||
var based_on_memory = (memory.ullTotalPhys - (2 * GB)) / (2 * GB);
|
||||
var scratch_size = await RecommendQueueSize(Directory.GetCurrentDirectory());
|
||||
var result = Math.Min((int)based_on_memory, (int)scratch_size);
|
||||
Utils.Log($"Recommending a queue size of {result} based on disk performance, number of cores, and {((long)memory.ullTotalPhys).ToFileSizeString()} of system RAM");
|
||||
if (ManualCoreLimit)
|
||||
{
|
||||
if (result > MaxCores)
|
||||
{
|
||||
Utils.Log($"Only using {MaxCores} due to user preferences.");
|
||||
}
|
||||
result = MaxCores;
|
||||
}
|
||||
else if (TargetUsagePercent < 1.0d && TargetUsagePercent > 0d)
|
||||
{
|
||||
result = (int)Math.Ceiling(result * TargetUsagePercent);
|
||||
result = Math.Max(1, result);
|
||||
Utils.Log($"Only using {result} due to user scaling preferences of {(TargetUsagePercent * 100)}%.");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<int> RecommendQueueSize(string folder)
|
||||
{
|
||||
if (!Directory.Exists(folder))
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
@ -327,19 +327,6 @@ namespace Wabbajack.Lib
|
||||
*/
|
||||
}
|
||||
|
||||
public async Task<int> RecommendQueueSize()
|
||||
{
|
||||
const ulong GB = (1024 * 1024 * 1024);
|
||||
// Most of the heavy lifting is done on the scratch disk, so we'll use the value from that disk
|
||||
var memory = Utils.GetMemoryStatus();
|
||||
// Assume roughly 2GB of ram needed to extract each 7zip archive, and then leave 2GB for the OS
|
||||
var based_on_memory = (memory.ullTotalPhys - (2 * GB)) / (2 * GB);
|
||||
var scratch_size = await RecommendQueueSize(Directory.GetCurrentDirectory());
|
||||
var result = Math.Min((int)based_on_memory, (int)scratch_size);
|
||||
Utils.Log($"Recommending a queue size of {result} based on disk performance, number of cores, and {((long)memory.ullTotalPhys).ToFileSizeString()} of system RAM");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The user may already have some files in the OutputFolder. If so we can go through these and
|
||||
|
@ -192,6 +192,9 @@ namespace Wabbajack
|
||||
ModListWebsite = ModlistSettings.Website,
|
||||
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
|
||||
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
|
||||
ManualCoreLimit = Parent.MWVM.Settings.Performance.Manual,
|
||||
MaxCores = Parent.MWVM.Settings.Performance.MaxCores,
|
||||
TargetUsagePercent = Parent.MWVM.Settings.Performance.TargetUsage,
|
||||
};
|
||||
await ActiveCompilation.Begin();
|
||||
}
|
||||
|
@ -204,6 +204,9 @@ namespace Wabbajack
|
||||
ModListWebsite = ModlistSettings.Website,
|
||||
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
|
||||
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
|
||||
ManualCoreLimit = Parent.MWVM.Settings.Performance.Manual,
|
||||
MaxCores = Parent.MWVM.Settings.Performance.MaxCores,
|
||||
TargetUsagePercent = Parent.MWVM.Settings.Performance.TargetUsage,
|
||||
};
|
||||
await ActiveCompilation.Begin();
|
||||
}
|
||||
|
@ -151,7 +151,12 @@ namespace Wabbajack
|
||||
modList: Parent.ModList.SourceModList,
|
||||
outputFolder: Location.TargetPath,
|
||||
downloadFolder: DownloadLocation.TargetPath,
|
||||
parameters: SystemParametersConstructor.Create());
|
||||
parameters: SystemParametersConstructor.Create())
|
||||
{
|
||||
ManualCoreLimit = Parent.MWVM.Settings.Performance.Manual,
|
||||
MaxCores = Parent.MWVM.Settings.Performance.MaxCores,
|
||||
TargetUsagePercent = Parent.MWVM.Settings.Performance.TargetUsage,
|
||||
};
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
@ -68,7 +68,12 @@ namespace Wabbajack
|
||||
modList: Parent.ModList.SourceModList,
|
||||
outputFolder: staging,
|
||||
downloadFolder: download,
|
||||
parameters: SystemParametersConstructor.Create());
|
||||
parameters: SystemParametersConstructor.Create())
|
||||
{
|
||||
ManualCoreLimit = Parent.MWVM.Settings.Performance.Manual,
|
||||
MaxCores = Parent.MWVM.Settings.Performance.MaxCores,
|
||||
TargetUsagePercent = Parent.MWVM.Settings.Performance.TargetUsage,
|
||||
};
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user