Some users with low memory and good connection uploading some big files
can see memory crash, since mc will increase upload parallelism over
time when the bandwidth and the server is able to carry the load.
This PR will check the free OS memory before starting mirror/cp and will
estimate current memory usage based on uploaded objects sizes, it will
stop parallelism until the memory gets some room.
Mirroring watch supports parallel manager to run actions of the received
events in parallel, but sometimes the order of the execution of those
actions matter.
For example:
- A new bucket is created
- A new file is uploaded in the new bucket
This PR will bring support of the barrier concept. A task with a barrier
will only executed after all the previous tasks finish, the
subsequent tasks will also be only executed when the barrier task is
finished.
Later, we will bring support of tasks dependency to optimize the
parallelism.
Keep elements that are used with atomic.* functions as first element
of struct because it guarantees 64bit alignment on 32 bit machines.
atomic.* functions crash if operand is not aligned at 64bit.
See https://github.com/golang/go/issues/599
Tested by transferring 29GiB data, around 246569 files
over 100Gig network.
- master branch
```
time mc mirror /root myminio/testbucket/
real 2m10s
```
- after changes
```
time mc mirror /root myminio/testbucket/
real 1m2s
```
By default runtime.NumCPU() workers are started.
Each 5 seconds, calculate current bandwidth and add new workers as
bandwidth gets increased. Stop adding workers if it is not useful
for increasing bandwidth.
This PR removes --parallel flag and implements a dynamic way of adding
threads to accelerate mirror/cp command.
After the calculation of objects that need to be copied/removed, mc
sends tasks (upload/remove) to a parallel manager which monitors the
progress of tasks and decide to allocate more threads to it to
accelerate the overall work.
This is very useful when we copy/mirror many relatively small files.