cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Zero-copy interface

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 12 Jul 2010 18:18:54 +0200 (CEST)

On Thu, 8 Jul 2010, G Drukier wrote:

(Please don't reply to a subject as a shortcut to start a new thread, you'll
end up as a reply in the existing thread in clients and web archives and more,
and it is messy.)

> We're working on an application where we're taking a video feed off of an IP
> camera via HTTP or RTSP and then processing the video in memory without
> writing to disk. In order to maximize performance we'd prefer to not have to
> copy the incoming data from the libcurl internal buffer.
>
> So, has there actually been any work in implementing the zero-copy interface?

No.

> I've been poking around the code-base, but I'm not that familiar with it
> yet. Does anyone have any guidance they could give in implementing
> zero-copy?

My vision of a zero copy interface would be that you provide buffers in
advance to libcurl, and as it goes about and stores data into the buffers
it'll ask for more and use those accordingly.

That way, it would only be a matter of updating the main "buffer pointer" at
the suitable place in the code to not point to the internal buffer all the
time but instead point to the correct new one.

Possibly it could be made as another callback: getbuffer()

getbuffer() gets called when libcurl needs a new buffer, and the buffer you
provide to libcurl with that callback must be able to hold at least
CURL_MAX_WRITE_SIZE bytes. When libcurl calls the write callback, it will pass
on a pointer to within that buffer and a length. Note that it MAY not point to
the first byte of the passed-in buffer.

What what you say about that concept?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-07-12