SLUICE(1) | General Commands Manual | SLUICE(1) |
sluice - a tool to control data flow at a specified rate
sluice [options]
sluice reads input and outputs a specified data rate. It has various data rate controlling mechanisms that can be tuned for specific use cases where necessary.
sluice options are as follow:
This option is mutually exclusive to the -i option and implicitly enables the -o overrun and -u underrun buffer management options to dynamically re-size the read/write buffer to keep the data rate constant. By default this adjusts the buffer based on the total amount of data transferred and the time to write this (equivalent to the -s 0 turning mode). However, if the -s shift value is greater than 0, then the new size is adjusted by the previous size right shifted by the shift value.
Mode | Delay strategy | Delay Duration |
0 | Read, Write, Delay (default) | 1 × delay time |
1 | Delay, Read, Write | 1 × delay time |
2 | Read, Delay, Write | 1 × delay time |
3 | Delay, Read, Delay, Write | 2 × 1/2 delay time |
4 | Read, Delay, Write, Delay | 2 × 1/2 delay time |
5 | Delay, Read, Delay, Write, Delay | 3 × 1/3 delay time |
Note that modes 3 and 4 perform two delays each comprising of 1/2 the delay time and mode 5 performs 3 delays each comprising of 1/3 the delay time.
Modes 1, 3, 5 maybe considered as not entirely accurate in terms of the total run duration. In these modes an extraneous delay occurs before the final end-of-file empty read is performed.
In this mode, the delays between writes are used to control the data rate. By default the delay is based on the total amount of data transferred and the time taken to write this. This is equivalent to the -s 0 tuning mode. However, if the -s shift value is greater than 0, then the new delay is adjusted by the previous delay right shifted by the shift value.
A special hybrid rate control mode can be invoked by also using the -o overflow and -u underflow options to also enable dynamic re-sizing of the read/write buffer. By default this adjusts the buffer based on the total amount of data transferred and the time to write this (equivalent to the -s 0 turning mode). However, if the -s shift value is greater than 0, then the new size is adjusted by the previous size right shifted by the shift value.
For the -r option, the delay between each write is controlled by modifying the previous delay by adding or subtracting the previous delay right shifted by this shift value. The larger the shift value the longer it takes to adjust up/down to the specified rate. The smaller the shift value the quicker it takes to reach the optimal delay, however, this can result in a highly fluctuating rates at the the beginning because the delay varies by a large amount causing large overruns and underruns. A shift value of 3 works well for most fast rates.
For the -c, -o and -u options, the size of the buffer is modified by adding or subtracting the previous size shifted by the shift value. Again, a shift value of 3 works well for most fast rates.
If the shift value is set to 0, then the shift rate adjustment tuning mechanism is explicitly turned off and data rates are adjusted based on the total amount of data transferred and the time to write this.
Small -s shift values of 1 and 2 can cause rapid oscillations before data rate damping fully kicks into action. The value of -s 0 (the default) is recommended for accurate low-speed data transfers.
With the -p option, the progess statistics are displayed. This will display the current data rate, total bytes transferred, duration, percentage complete so far and the estimated time to completion. Note that the estimation is available using the -I and -m options and if the file size is non-zero.
If neither -i or -c options are used, then sluice defaults to using a write buffer size of 1/32 of the data rate and bounded between the limits of 1 byte and 64MB. Sluice will try to keep the data rate steady by adjusting the delay between writes. To tune this, see the -s option.
Read /dev/zero and write in 4K sizes at the rate of 1MB/sec to the file 'example.dat'
Read 32MB from /dev/zero and write at the rate of 64K/sec to stdout with feedback on duration and ETA on stderr using 4K buffer writes and a tuning shift of 4.
Generate a stream of zeros and write at a rate of 1MB/sec to a fifo named 'myfifo' with underrun and overrun buffer management
Write random data at 5MB per second to the file 'myfile' doing a write every 0.1 seconds
Write zeros to the file 'example-file' in 64K chunks and measure write rate as a crude throughput test
Read data from somehost.com on port 1234 at a rate of 2MB per second and discard the data, e.g. this is a constant rate data sink.
Sluice sets the exit status as follows:
Status | Decription |
0 | Exited successfully. |
1 | Invalid or out of range option provided. |
2 | File open error. |
3 | Sleep error. |
4 | Failed to get time of day. |
5 | Signal handler setup error. |
6 | Read error (file or stdin). |
7 | Write error (file or stdout). |
8 | Buffer allocation failed. |
Stopping and starting sluice using SIGSTOP and SIGCONT will interfere with the internal buffering rate calculations causing sluice to try to catch up and this may affect the short term data rate immediately after the SIGCONT.
sluice was written by Colin King <colin.king@canonical.com> with testing feedback and help from Kamal Mostafa.
This manual page was written by Colin King <colin.king@canonical.com>, for the Ubuntu project (but may be used by others).
Copyright © 2014-2018 Canonical Ltd.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
March 6, 2016 |