cat /dev/zero | pv > /dev/null
What exactly happens here and what determines the speed of this process.
Even on low end hardware you get a couple of GB/s transfer speeds like this.
cat /dev/zero | pv > /dev/null
What exactly happens here and what determines the speed of this process.
Even on low end hardware you get a couple of GB/s transfer speeds like this.
cat /dev/zero
gives you a stream of zero-characters. When you open it and read from it you're using the kernel. The kernel implements /dev/zero
in drivers/char/mem.c.
As far as cat
or pv
is concerned this is nothing special. Choosing to use /dev/zero
is no different from reading /etc/passwd
. The only difference is that you're reading a virtual file, not a real file. So the work the kernel does is different - i.e. It doesn't have to do things with the filesystem ,etc.
Writing to /dev/null
is pretty much the same. pv
doesn't care about the target (well in this case it is your shell, due to redirection) and so again the only difference is that the write is thrown away, because that's what the kernel-driver for /dev/null
does, again in drivers/char/mem.c
.
The speed of this process will depend on the system I/O load and the processor, as much as anything else.