madMAx43v3r / chia-plotter

Apache License 2.0
2.27k stars 664 forks source link

Wait until previous plot is Copied before plotting again #642

Open MaximusChia opened 3 years ago

MaximusChia commented 3 years ago

Could be add this feature so my NVME doesnt get bloated and copy/plotting speed gets compromised. I cant set queue cause of this because SSD ends full and the process is interrupted. Tried Windows compilations 0.5 and 0.6 btw

vladaepro commented 3 years ago

Agree, and/or, can you pause plotting if there's not enough room on destination drive (instead of crashing)? What's happens now when plotting speed is so great is that copy over network is slower than plots building - so at some point destination drive gets full.

eperdeme commented 3 years ago

I worked around this issue with the following;

#!/bin/bash
while :
do
    ./build/chia_plot --count 1 -r 12 -d /Network/nfs/chia/plots/ -t "/path/to/tmp/" -p XXX -f XXX
    sleep 1
done
vladaepro commented 3 years ago

nice, but plotting with count == 1 will wait for final plot to be copied to destination drive, so 3-5 minutes penalty compared to plotting with count > 0

eperdeme commented 3 years ago

nice, but plotting with count == 1 will wait for final plot to be copied to destination drive, so 3-5 minutes penalty compared to plotting with count > 0

Yes, but the issue is called "Wait until previous plot is Copied before plotting again" which is the users desired behaviour.

If he's like me and his NVME is say only 300Gb of spare space, you need to to wait for it to be copied before starting a new one or you run out of space.

vladaepro commented 3 years ago

i agree, but think this is related to that issue - just would be handled automatically - if there's enough space - proceed, if there's not enough space - wait.

madMAx43v3r commented 3 years ago

there's no standard way of getting free space in C++, sry

MaximusChia commented 3 years ago

nice, but plotting with count == 1 will wait for final plot to be copied to destination drive, so 3-5 minutes penalty compared to plotting with count > 0

Yes, but the issue is called "Wait until previous plot is Copied before plotting again" which is the users desired behaviour.

If he's like me and his NVME is say only 300Gb of spare space, you need to to wait for it to be copied before starting a new one or you run out of space.

Exactly this, My Nvme has around 300GB of free space, so clearing this space before replot again its important. After some research i managed to create a loop with plotter, i set in plotter n = 1 and loop counter the number of plots i want.

@ECHO OFF
SET /A "count = 1"
SET /A "total = 9"
:while
if %count% leq %total% (
echo Crafting %count% plot of %total%
echo.
[INSERT PLOTTER SCRIPT HERE]
SET /A "count = count + 1"
goto :while
)
PAUSE
vladaepro commented 3 years ago

there's no standard way of getting free space in C++, sry

can't use std::filesystem::space?

https://en.cppreference.com/w/cpp/filesystem/space

350d commented 3 years ago

Just a workaround - I have Primo Cache in front of all plot storage drives with L1/L2 cache. For L1 I've used all free RAM I have (around 40GB), for L2 - SATA SSD. Write delay in Primo Cache - 300s. My plot "copy" time now is about 140-200s. So, destination drive will start real write operation only after 300s but plotter will fill the cache very fast and will be ready for next job.

Dartellum commented 3 years ago

I wrote a bash script that detects used space and selects the destination appropriate. You could modify the disk_space function to have it wait until the copy completes. Although, my script does just that as it plots them consecutively as you set the number of plots not within chia_plot but with the loop. If interested: https://github.com/Dartellum/chia-madmax-plot_loop

madMAx43v3r commented 3 years ago

there's no standard way of getting free space in C++, sry

can't use std::filesystem::space?

https://en.cppreference.com/w/cpp/filesystem/space

no that doesn't compile anywhere except recent linux systems

Jacek-ghub commented 3 years ago

@madMAx43v3r

there's no standard way of getting free space in C++, sry

Isn't that where C/C++ shines thanks to "#if defined" concept?

Would the code below work (Windows side may need to check that _LARGEINTEGER to unsigned long conversion, whether some extra casting is needed).

#if defined (__linux__)
  #include <sys/statvfs.h>
#elif defined (_WIN32)
  #include <fileapi.h>
#else
  #error "SOL: not supported sytem: missing folder free space API/calculation"
#endif

bool GetDiskFree (const char * path,
                  unsigned long & freeBytes)
{
  bool bRet = false;
  freeBytes = 0;

  #if defined (__linux__)
    struct statvfs buf;
    if (0 == statvfs (path, &buf))
    {
      freeBytes = buf.f_bavail * buf.f_bsize;

      bRet = true;
    }
  #elif defined (_WIN32)
    unsigned long free;
    if (GetDiskFreeSpaceExA (path, &free, NULL, NULL))
    {
      freeBytes = free;

      bRet = true;
    }
  #endif

  return bRet;
}

https://linux.die.net/man/2/statvfs https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getdiskfreespaceexa?redirectedfrom=MSDN