2006-12-10 10:06:51

by Amit Choudhary

[permalink] [raw]
Subject: [PATCH] [DISCUSS] Optimizing linux applications with the help of the kernel.

Hi All,

I just had an idea for improving the performance of linux applications with some help from the
kernel. Let's say that I have to make a copy of a file. So, I read the input file into a buffer
and then write the buffer to the output file.

In both these cases the same data is coming from kernel_to_user and then from user_to_kernel. If
this can be short-circuited, that is, from kernel_to_kernel then the performance can be increased
a lot.

The psuedocode would be:

fd_inp = open _output_file
fd_out = open _input_file
instruct_kernel to write next data read from fd_inp to fd_out
read fd_out

The same mechanism can be applied to many other scenarios.
May be whatever I am thinking is wrong or involves lot of complexities but this is just a thought.

Regards,
Amit




____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com


2006-12-10 10:20:22

by bert hubert

[permalink] [raw]
Subject: Re: [PATCH] [DISCUSS] Optimizing linux applications with the help of the kernel.

On Sun, Dec 10, 2006 at 02:06:49AM -0800, Amit Choudhary wrote:
> In both these cases the same data is coming from kernel_to_user and then from user_to_kernel. If
> this can be short-circuited, that is, from kernel_to_kernel then the performance can be increased
> a lot.

Google on 'splice linux'. It can't do what you want right now exactly, but
it might.

--
http://www.PowerDNS.com Open source, database driven DNS Software
http://netherlabs.nl Open and Closed source services

2006-12-10 11:10:56

by Benoit Boissinot

[permalink] [raw]
Subject: Re: [PATCH] [DISCUSS] Optimizing linux applications with the help of the kernel.

On 12/10/06, Amit Choudhary <[email protected]> wrote:
> Hi All,
>
> I just had an idea for improving the performance of linux applications with some help from the
> kernel. Let's say that I have to make a copy of a file. So, I read the input file into a buffer
> and then write the buffer to the output file.
>
> In both these cases the same data is coming from kernel_to_user and then from user_to_kernel. If
> this can be short-circuited, that is, from kernel_to_kernel then the performance can be increased
> a lot.
>
> The psuedocode would be:
>
> fd_inp = open _output_file
> fd_out = open _input_file
> instruct_kernel to write next data read from fd_inp to fd_out
> read fd_out
>
>
I think you are describing the splice syscall:

see http://lwn.net/Articles/178199/

regards,

Benoit

2006-12-10 11:14:48

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] [DISCUSS] Optimizing linux applications with the help of the kernel.

On 10/12/06, Amit Choudhary <[email protected]> wrote:
> Hi All,
>
> I just had an idea for improving the performance of linux applications with some help from the
> kernel. Let's say that I have to make a copy of a file. So, I read the input file into a buffer
> and then write the buffer to the output file.
>
> In both these cases the same data is coming from kernel_to_user and then from user_to_kernel. If
> this can be short-circuited, that is, from kernel_to_kernel then the performance can be increased
> a lot.
>

See the linux specific splice() syscall - "man 2 splice".

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html