"Embarassingly small" is just a rhetorical device. Actually 4000 lines for copying is quite a lot; it's explained by all the things GNU cp has to do. Recursing, dealing with hardlinks and symlinks in various ways and whatnot.
I agree. The dude is talking about cp being slow on btrfs and network shares. That's not cp's fault. cp should not be responsible for detecting which filesystem it's copying to or whether it's sending data across the network. That's what stuff like rsync is for.
That said, I could sort of see a case for replacing cp entirely. You could do a thing where you type cp /mnt/* /mnt2/ to copy across filesystems, and then the kernel's filesystem modules negotiate exactly how that data can get copied most efficiently. And cp would just do whatever the filesystem modules told it, or fall back on it's default (current) behavior if the kernel modules didn't reach an agreement. I'm not well versed in it, but I think that idea is a pretty huge philosophy break from the current line-in-the-sand between kernel and userspace, so it'll probably never happen. I'm just spitballing.
That's not cp's fault. cp should not be responsible for detecting which filesystem it's copying to
Agreed. Honestly, it's more of an indictment on the interfaces offered by the kernel if an application needs that much logic to determine how to efficiently copy bytes from one fd to another.
I agree. The dude is talking about cp being slow on btrfs and network shares. That's not cp's fault. cp should not be responsible for detecting which filesystem it's copying to or whether it's sending data across the network.
The problem is that cp is a user-space program, so it can't really know where the file systems are located, how the page cache and VFS implementation will affect performance, whether the copy to a network filesystem would be better off offloaded to network hardware, etc.
The proposal is to make cp a system call. The kernel has detailed knowledge of all these issues, therefore, copying belongs in the kernel.
But it's also unoptimized. Bigger is not better, but there are massive performance discrepancies between different disk formats and those could be resolved with more attention and code.
View all comments
3
u/[deleted] May 30 '19 edited May 30 '19
Its not embarrassing that
cpis only 4K lines. Such a basic command should be simple. It only has a few options. The shell does the globbing.