How efficient can cat(1) be?
ariadne.space
How efficient can cat(1) be?
1–10 of 51 posts
Re: How efficient can cat(1) be?
#2- https://man7.org/linux/man-pages/man2/sendfile.2.html
- https://man7.org/linux/man-pages/man2/splice.2.html
(Funny how used I've gotten to "hypertext", I was quite irritated I couldn't click those function names.)
Re: How efficient can cat(1) be?
#3This was a good read! The missing hyperlinks: - https://man7.org/linux/man-pages/man2/sendfile.2.html - https://man7.org/linux/man-pages/man2/splice.2.html (Funny how used I've gotten to "hypertext", I was quite irritated I couldn't click those function names.)
Re: How efficient can cat(1) be?
#4Re: How efficient can cat(1) be?
#5copy_file_range is much preferable to any of these because filesystems can "hook into" it and just share the underlying data, not copying at all.
Re: How efficient can cat(1) be?
#6copy_file_range is much preferable to any of these because filesystems can "hook into" it and just share the underlying data, not copying at all.
In general, yes, but as the article notes, itt's not applicable to cat, as cat always outputs to stdout and not to a file.
Re: How efficient can cat(1) be?
#7This was a good read! The missing hyperlinks: - https://man7.org/linux/man-pages/man2/sendfile.2.html - https://man7.org/linux/man-pages/man2/splice.2.html (Funny how used I've gotten to "hypertext", I was quite irritated I couldn't click those function names.)
Re: How efficient can cat(1) be?
#8Earlier quoted context omitted.
In general, yes, but as the article notes, itt's not applicable to cat, as cat always outputs to stdout and not to a file.
You can handle the cat foo bar baz > file case this way though, because stdout is a file then.
Re: How efficient can cat(1) be?
#9 do
{
splice(from stdin...);
if (A)
handle_a();
goto out;
splice(to stdout...);
if (B)
handle_b();
goto out;
} while (nwritten > 0);
// do we need some kind of handle_c()??
out:
...
Why make a special case for the "nwritten > 0" condition here? And what's wrong with "break" vs "goto"? for (;;)
{
thing_a();
if (A)
handle_a();
break;
thing_b();
if (B)
handle_b();
break;
if (C)
handle_c();
break;
}
is cleaner in my eyes.Re: How efficient can cat(1) be?
#10> There have been a few initiatives in recent years to implement new a new userspace base system for Linux distributions as an alternative to the GNU coreutils and BusyBox.
Have there been? And why?