MrPig91 / PSChiaPlotter

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

Suggestion: Detect process and start plotting infinite #36

Open abides opened 3 years ago

abides commented 3 years ago

First of all thank you for this. I tried and used this method to start my plotters. First thing i realized the phase one process can be overlapped with specific timed delay. I saw my system processing phase one about 2.5 hour and i use this value in config parameters. Second plot just started correct time, just after first one finish the phase 1 process, then third one started just after second plot first phase. Then things start to get overlapped. Before third one finish phase one, first plotter finish plotting and start another plot so i have 2x phase 1 process at the same time.

I made some changes on script;

$numOfChiaPlotter = 0
foreach ($process in Get-Process powershell) {
    if($process.mainWindowtitle.IndexOf("Chia Process") -ge 0 ) {
        $numOfChiaPlotter += 1
    }
}

Using this i can find out active processes. So i forget about all delays in script and just checking processes. when its reach the phase one ends (reach line 801) its start another process until it reach the maxParalel parameter. I added this on ChiaPlotting so when i run it onces, its keep creating processes without any overlap phase one until i decide to kill all.

Best regards.

Falacio commented 3 years ago

I like that idea a lot... I'd like to implement it, but I'm a newbie at programming and not experienced with powershell...

I'd like to make you a couple of (maybe noob) questions, if you don't mind.

First one: Do you insert the code you wrote down as it is? Or is just an example. My doubt is: if you got several queues(i. e. several temp disks) , will the processes "interfere" with each other? I mean, when checking for processes, how will it know that the process being checked belongs to the queue you are trying to kick, and is not a process from another queue?

Second question: in the explanation, you talk about phase one end (line 801). If I'm not mistaken, that line refers to log file and is written when phase one finishes... But I cannot understand where do you get this value from checking processes.

So, my suggestion for avoiding overlapping phase 1 (I really want this) without time delays or process checking, would be using log length(in lines). Something like:

Do forever each 60 seconds: Get list of chia processes for this queue if any length(process.plotter.log) < 801 do nothing else, if not max_parallel_plots
kick another plot

So, if I have 2 temp disks, and I make a queue for each one of them, they will kick a plot as soon as there is no other one in phase one for that disk (taking in account another limiting factors you may add), just by checking individual logs. This could be like an "auto-plot" option: turn it on if you want just 1 concurrent phase one for each disk, optimizing threads, RAM usage and SSD writing.

Sorry if I'm making a silly suggestion, or is already done... Any insight would be greatly appreciated.

abides commented 3 years ago

I try to cover all your questions.

First one: Yes i insert this code in checking progress section which is running every 10 sec. Im not using chia queue that means i dont use -n parameter so everytime this process started its just create 1 plot. Multiple temp disks are not covered, need more improvements.

Second one: Start-ChiaPlotting script already has progress tracker using log file its created. So you can find the which line is at every 10 sec.

Think about like this. This process responsible to start another process depends on if there is enough room and if its reached end of first phase. So second process also responsible to start another process when conditions are met... goes like this.

Using count of cpu threads, available space in given temp drives, available space in given destination drives can lead to adding more features to this script. Maybe even move files to big file server.

Best regards.

Falacio commented 3 years ago

First of all, thanks a lot for your response (as well I'd like to thank MrPig for the code)

I've seen the scripts video on youtube and worked hard to understand most of the code and learn and I came with my own solution. I've made another script doing what I proposed: It starts some auto mode in which one plot starts and next one starts when first one exits or reach phase 2. And so on until the number of total plots. It only works for one TempDir but another script can be launched to make another queue. Right now is working fine, and I'm doing plots in 6 hours without overlapping phase 1

I made a fork with the changes, but I'm new to Github too and I'm not sure if it is visible. For sure It could have been done better, but at least seems to work and is fully compatible with main PSChiaPloter

About the code you wrote, I've tried to put it everywhere and try to understand what it does, but I couldn't. Unless I'm missing something important, that code only counts the number of chia processes running and stores that number in $numOfChiaPlotter, that I couldn't find anywhere in the scripts...

I imagine you have put it somewhere here:?

while (!$chiaProcess.HasExited){ $progress = Get-ChiaPlotProgress -LogPath $logPath

$plotid = $progress.plotid

    $plotid = Get-Content -Path $logPath | Select-String -SimpleMatch "ID: " | foreach {$_.ToString().Split(" ")[1]}
    Write-Progress -Activity "Queue $($QueueName): Plot $plotNumber out of $plotTotal" -Status "$($progress.phase) - $($progress.Progress)%" -PercentComplete $progress.progress -SecondsRemaining $progress.EST_TimeReamining.TotalSeconds
    sleep 10
}

But still I cannot see it working... Sorry If I'm bothering you, I 'd just like to know And thanks again

abides commented 3 years ago

Posted code in here but its broke its format. So pretty much this is it;

https://gist.github.com/abides/9403538d6a92a321af12848db12226ab

Best regards.

Falacio commented 3 years ago

Thanks a lot for sharing the code. Now I understand everything. It was not just that piece of code but something else.

I made an alternate starting script for auto mode. I had only to add and Auto flag to ChiaPlotting, and one check to provide LogName as parameter:

https://github.com/Falacio/PSChiaPlotter/blob/main/Scripts/Start-ChiaAutoPlotting.ps1

Best regards.