Live data from Hacker News

Pipe Viewer

ivarch.com

11–20 of 51 posts

Re: Pipe Viewer

#11
post #7
post #6

pv -d $(pidof xz):1 is great for when you realize too late that something is slow enough that you want a progress indication, and definitely do not want to restart from scratch.

How `pv -d` work ? Does it use perf probes or attach to the target PID ?

It appears to monitor the contents of /proc/‹pid›/fdinfo/‹fd›

Re: Pipe Viewer

#12
Probably my favorite non-POSIX tool that I insert into my pipelines whenever anything takes more than a few second. I find it super helpful to avoid premature optimization. If I can quickly see that my hacked together pipeline will run in a few minutes and I only ever need to do that once, I'll probably just let it finish. If it's going to take a few hours, I might decide it's worth optimizing.

It also helps me optimize my time. If something is going to finish in a few minutes, I probably won't context switch to another major task. However, if something is going to take a few hours then I'll probably switch to work on something different knowing approximately when I can go back and check on results.

Re: Pipe Viewer

#13

It would be nice to indicate if the upstream or the downstream is the 'limiting' factor in speed. Ie. within pv, is it the reading the input stream or the writing the output stream that is blocking most of the time?

It's open source, be the change you want to see in the world

Re: Pipe Viewer

#14
post #6

pv -d $(pidof xz):1 is great for when you realize too late that something is slow enough that you want a progress indication, and definitely do not want to restart from scratch.

Another good option for that, which works in a number of other useful circumstances too, is progress: https://github.com/Xfennec/progress

Re: Pipe Viewer

#15
As a person who runs a lot of ETL-like commands at work, I never find myself using pv(1). I love the idea of it, but for the commands I most want to measure progress of, they always seem to be either:

1. things where I'd be paranoid about pv(1) itself becoming the bottleneck in the pipeline — e.g. dd(1) of large disks where I've explicitly set a large blocksize and set conv=idirect/odirect, to optimize throughput.

2. things where the program has some useful cleverness I rely on that requires being fed by a named file argument, but behaves a lot less intelligently when being fed from stdin — e.g. feeding SQL files into psql(1).

3. things where the program, even while writing to stdout, also produces useful "sampled progress" informational messages on stderr, which I'd like to see; where pv(1) and this output logging would fight each-other if both were running.

4. things where there's no clean place to insert pv(1) anyway — mostly, this comes up for any command that manages jobs itself in order to do things in parallel, e.g. any object-storage-client mass-copy, or any parallel-rsync script. (You'd think these programs would also report global progress, but they usually don't!)

I could see pv(1) being fixed to address case 3 (by e.g. drawing progress while streaming stderr-logged output below it, using a TUI); but the other cases seem to be fundamental limitations.

Personally, when I want to observe progress on some sort of operation that's creating files (rsync, tar/untar, etc), here's what I do instead: I run the command-line, and then, in a separate terminal connected to the machine the files are being written/unpacked onto, I run this:

    # for files
    watch -n 2 -- ls -lh $filepath

    # for directories
    watch -n 4 -- du -h -d 0 $dirpath
If I'm in a tmux(1) session, I usually run the file-copying command in one pane, and then create a little three-vertical-line pane below it to run the observation command.

Doing things this way doesn't give you a percentage progress, but I find that with most operations I already know what the target's goal size is going to be, so all I really need to know is the size-so-far. (And pv(1) can't tell you the target size in many cases anyway.)

Re: Pipe Viewer

#17
post #15

As a person who runs a lot of ETL-like commands at work, I never find myself using pv(1). I love the idea of it, but for the commands I most want to measure progress of, they always seem to be either: 1. things where I'd be paranoid about pv(1) itself becoming the bottleneck in the pipeline — e.g. dd(1) of large disks where I've explicitly set a large blocksize and set conv=idirect/odirect, to optimize throughput. 2.…

Sometimes you prefer predictability and information over sheer speed. If do a very large transfer that could take hours, I'd rather trade a bit of speed to know the progress and make sure nothing is stuck than launching in the blind and then repeat slow and expensive du commands to know where I am in the transfer or have to strace the process.

Re: Pipe Viewer

#19
post #5

pv is a great tool. One of it's lesser known features is throttling; transfer a file without dominating your bandwidth: pv -L 200K bigfile.iso' Complete with a progress bar, speed, and ETA.

Oh damn that's neat I never thought to use `ssh` directly when transferring a file, I always used `scp bigfile.iso name@server.org:path/in/destination`

A similar trick that's nice is piping tar through ssh. Handy if you don't have rsync or something better around. Even handy for one file, since it preserves permissions, etc.

tar -cf - some/dir | ssh remote 'cd /place/to/go && tar -xvf -'

Re: Pipe Viewer

#20
post #8
post #5

Earlier quoted context omitted.

Oh damn that's neat I never thought to use `ssh` directly when transferring a file, I always used `scp bigfile.iso name@server.org:path/in/destination`

Also see `scp -l 200 bigfile.iso name@server.org:path/in/destination` from man page: -l limit Limits the used bandwidth, specified in Kbit/s.

Also you probably shouldn't use scp. rsync and sftp have mostly the same semantics.

    rsync --bwlimit=2OOK bigfile.iso name@server.org:path/in/destination
    sftp -l 200 bigfile.iso name@server.org:path/in/destination
Although it seems that scp is becoming a wrapper around sftp these days:

https://www.redhat.com/en/blog/openssh-scp-deprecation-rhel-...

https://news.ycombinator.com/item?id=25005567

Post reply on HN