Only assign physicalCoreCount when needed.

This commit is contained in:
sunshineinabox 2023-07-08 07:46:43 -07:00
parent b5cb5c83fa
commit f9ec040ca5

View file

@ -57,6 +57,8 @@ namespace ARMeilleure.Translation
private Thread[] _backgroundTranslationThreads;
private volatile int _threadCount;
private static int physicalCoreCount;
// FIXME: Remove this once the init logic of the emulator will be redone.
public static readonly ManualResetEvent IsReadyForTranslation = new(false);
@ -104,8 +106,6 @@ namespace ARMeilleure.Translation
public void Execute(State.ExecutionContext context, ulong address)
{
int physicalCoreCount = SystemInfo.GetPhysicalCoreCount();
if (Interlocked.Increment(ref _threadCount) == 1)
{
IsReadyForTranslation.WaitOne();
@ -121,6 +121,8 @@ namespace ARMeilleure.Translation
_ptc.Disable();
physicalCoreCount = SystemInfo.GetPhysicalCoreCount();
// Simple heuristic, should be user configurable in future. (1 for 4 core/ht or less, 2 for 6 core + ht
// etc). All threads are normal priority except from the last, which just fills as much of the last core
// as the os lets it with a low priority. If we only have one rejit thread, it should be normal priority