MrPig91 / PSChiaPlotter

A repo for powershell module that helps Chia Plotting
MIT License
181 stars 47 forks source link

Jobs Process Priority #60

Open Jaga-Telesin opened 3 years ago

Jaga-Telesin commented 3 years ago

Left this suggestion on the YT page, but thought I'd better copy it over here to make sure it didn't get lost in the shuffle...

"Just a request to add Process Priority to the jobs. I typically run chia.exe at Below Normal priority so the computer in question can still be used for other tasks."

MrPig91 commented 3 years ago

I will see if I can implement this and then add it to the roadmap, great suggestion!

Jaga-Telesin commented 3 years ago

Great, glad to hear it!

Jacek-ghub commented 3 years ago

Below is what I was using, but as already mentioned in the other thread, I didn't get much out of it (I tried to slow down / speed up one process/plot to avoid the final copy collision, but it didn't work). Also, my understanding is that in addition to setting up the process priority, there is a need to change process affinity (again, I was just trying to manipulate the longest running process, so was fixing affinity to 1 just for that one process, and it also didn't help).

Although, when we have a system that is fully booked by chia processes (# of processes == # of phys cores) that all run with BelowNormal priority, it is possible that a new process (say a browser, or compiler) will get more CPU clocks than if it would be getting if running with the same priority as those chia processes. Also, on a fully booked system, whether we run those plots with Normal or Below/AboveNormal priorities it doesn't change anything for those plotters (as long as that extra process (browser) will not kick in). At least that is the concept of setting up those priorities - they only kick in when there is a competition for a give resource, and a fully booked box is not really starving for CPU resources (to some extent).

Here is the code:

# get all processes with the "chia" name (we get here chia.exe as well as CHIA.EXE, as it is case insensitive)
$chia_processes = Get-Process chia
foreach ($process in $chia_processes)
{
  # filter on plotters (lower case chia)
  $pname = $process.ProcessName
  if ($pname -ceq "chia")
  {
    # we should only have chia plotters here

    # dump the process info we got, maybe the only thing that we may be interested in is process id - $process.id
    echo $process

    # possible priority values: Idle, BelowNormal, Normal, AboveNormal, High, RealTime
    $process.PriorityClass = 'BelowNormal'
    $process.ProcessorAffinity = 1
  }
}