Linux::PipeMagic - Perl extension to use the zero copy IO syscalls
use Linux::PipeMagic qw/ systee syssplice /; systee($fh_in, $fh_out, $num_bytes, 0); syssplice($fh_in, $fh_out, $num_bytes, 0);
Linux::PipeMagic is a Perl XS wrapper around the splice(2) and tee(2) syscalls. You can use them to efficiently data from one file descriptor to another inside the kernel (splice), or to efficiently copy data from one pipe to another (tee).
Moves $num_bytes from $fh_in to $fh_out. This is roughly equivilent to,
$num_bytes
$fh_in
$fh_out
sysread($fh_in, my $buf, $num_bytes); syswrite($fh_out, $buf);
although the transfer takes place entirely in kernel-space.
Returns the number of bytes transferred.
Copies $num_bytes from $fh_in to $fh_out. The filehandles must both be of pipes. This works similarly to syssplice, but does not advance the read pointer in $fh_in.
syssplice
SPLICE_F_MOVE
SPLICE_F_NONBLOCK
SPLICE_F_MORE
SPLICE_F_GIFT
http://github.com/davel/Linux-PipeMagic/
See the Linux manpages for more details on how splice and tee can be used, including the flags.
splice(2)
tee(2)
Dave Lambley, <cpan@davel.org.uk>
Copyright (C) 2011 by Dave Lambley
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
To install Linux::PipeMagic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::PipeMagic
CPAN shell
perl -MCPAN -e shell install Linux::PipeMagic
For more information on module installation, please visit the detailed CPAN module installation guide.