>On Sun, Feb 7, 2010 at 2:09 PM, Theo de Raadt <dera...@cvs.openbsd.org>
>wrote:
>>> Why does cp need to be portable?  Who's porting OpenBSD cp to other
>systems?
>>
>> Will the same diff be added to every io generating program in /bin?
>>
>> They all generate io, of course.
>
>I was planning on something similar for tar.  But that's it really.
>They are the programs that read/write in a loop, where the
>reads/writes are blocked by writes/reads.  ls doesn't generate IO of
>the same magnitude as cp, the writes are very small in proportion to
>reads, and the writes don't go to disk either.  Very different.
>
>Programs like scp are also unaffected (unless you forget the colon),
>because one of the ends is network.  The source and sink aren't
>dependent.

And in mv, for the cross-device case?  I see others that do fast
reads, like sum.  diff?  cmp?  grep?  How many others?  If cp(1)
is such a common operation (I bet it isn't), how soon before other
programs doing exactly the same thing want the same chunk of code?

I think adding big chunks of sysctl code to such specific applications
is very un-unix.

If choosing a buffer size is going to be a common operation, it should
be an API called to "ask what the buffer size should be".  If that is
the case, it will soon over-commit the resources of the machine.  So
then it starts being something you want a system call for.  The unix
practice is to undercommit, and punish userland because userland is
commonly unefficient, while the kernel is trying to be efficient (as
much as it can).  This scaling undoes that.  cp will have it's
priority increased since it is "efficient", and an un-modified one
using the standard buffer sizes will be demoted.

So I guess it begs for an extension to the UNIX system calls.

That is a road that requires long consideration, to avoid overcommit.
You would not want a bunch of applications asking "how much should I
use", and then doing the allocation later.

That is why I don't like what you are doing in cp.  I think your
heuristic is hasty.

For those of you who asked why cp needs to be portable, come on.
You've got it all wrong.  If cp isn't written in a portable fashion,
then what is the point of doing anything else in a portable fashion.

Reply via email to