Re: [Libevent-users] accessing a bufferevent's evbuffer directly

2009-04-06 Thread Phoenix Sol
I wish I had thought just another moment before asking that ;-)

Thanks for the generous answer.

I know the best answer is to learn C, TCP/IP, etc. properly, instead of
'groping in the dark' with scripting languages.


On Mon, Apr 6, 2009 at 10:04 PM, Nick Mathewson  wrote:

> On Mon, Apr 06, 2009 at 01:38:44PM -0700, Phoenix Sol wrote:
> > Thanks, Nick.
> >
> > Is zero-copy possible at all with the current libevent?  (I already
> assumed
> > it wouldn't work with bufferevent)
>
> If you mean, just using the regular event_base interface, without any
> bufferevent or evbuffer interfaces, then... sure, so long as your OS
> supports it, and supports it in a way that works with libevent.  None
> of the functions that manipulate a 'struct event' (such as event_set,
> event_add, event_del) ever read or write any data to the network
> stack, so none of _them_ will add any copies to your data's path to
> and from the network stack.  What you do to communicate with your
> kernel then is up to you.  If you use read or write, data will be
> copied.  If you use splice or sendfile, it typically won't.  So if you
> could write a zero-copy program that used kqueue or epoll, you could
> write one using Libevent.
>
> Then again, I could be offbase here.  I know libevent pretty well, but
> I'm not an expert on zero-copy stuff.  Adrian -- are you still around?
> I bet this topic is right up your alley.
>
> --
> Nick
>
>
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] accessing a bufferevent's evbuffer directly

2009-04-06 Thread Nick Mathewson
On Mon, Apr 06, 2009 at 01:38:44PM -0700, Phoenix Sol wrote:
> Thanks, Nick.
> 
> Is zero-copy possible at all with the current libevent?  (I already assumed
> it wouldn't work with bufferevent)

If you mean, just using the regular event_base interface, without any
bufferevent or evbuffer interfaces, then... sure, so long as your OS
supports it, and supports it in a way that works with libevent.  None
of the functions that manipulate a 'struct event' (such as event_set,
event_add, event_del) ever read or write any data to the network
stack, so none of _them_ will add any copies to your data's path to
and from the network stack.  What you do to communicate with your
kernel then is up to you.  If you use read or write, data will be
copied.  If you use splice or sendfile, it typically won't.  So if you
could write a zero-copy program that used kqueue or epoll, you could
write one using Libevent.

Then again, I could be offbase here.  I know libevent pretty well, but
I'm not an expert on zero-copy stuff.  Adrian -- are you still around?
I bet this topic is right up your alley.

-- 
Nick

___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] accessing a bufferevent's evbuffer directly

2009-04-06 Thread Nick Mathewson
On Mon, Apr 06, 2009 at 11:12:10AM -0700, Phoenix Sol wrote:
> Is it alright to call evbuffer_readline() on a buffevent's evbuffer?
> ( Or any of the other evbuffer functions for that matter? )

You can do nearly anything with the evbuffers.  I think the only
limitations right now are that you shouldn't remove data from the
outbuf, you shouldn't add data to the inbuf, and you shouldn't change
the callbacks on the buffers.  This latter limitation will go away in
libevent 2.0.

> I'm wrapping bufferevents with a python 'socket module' interface, and must
> accomadate a 'fileobject' interface, which implements readline.
>
> Also, I want to keep copying to a minimum; maybe using bufferevent is not
> the best approach?

If you want to try 0-copy stuff with bufferevents, you'll need to wait
for Libevent 2.0.  Libevent 1.4 doesn't really support that so well.

-- 
Nick
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


Re: [Libevent-users] accessing a bufferevent's evbuffer directly

2009-04-06 Thread Phoenix Sol
Thanks, Nick.

Is zero-copy possible at all with the current libevent?  (I already assumed
it wouldn't work with bufferevent)


On Mon, Apr 6, 2009 at 11:17 AM, Nick Mathewson  wrote:

> On Mon, Apr 06, 2009 at 11:12:10AM -0700, Phoenix Sol wrote:
> > Is it alright to call evbuffer_readline() on a buffevent's evbuffer?
> > ( Or any of the other evbuffer functions for that matter? )
>
> You can do nearly anything with the evbuffers.  I think the only
> limitations right now are that you shouldn't remove data from the
> outbuf, you shouldn't add data to the inbuf, and you shouldn't change
> the callbacks on the buffers.  This latter limitation will go away in
> libevent 2.0.
>
> > I'm wrapping bufferevents with a python 'socket module' interface, and
> must
> > accomadate a 'fileobject' interface, which implements readline.
> >
> > Also, I want to keep copying to a minimum; maybe using bufferevent is not
> > the best approach?
>
> If you want to try 0-copy stuff with bufferevents, you'll need to wait
> for Libevent 2.0.  Libevent 1.4 doesn't really support that so well.
>
> --
> Nick
>
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


[Libevent-users] accessing a bufferevent's evbuffer directly

2009-04-06 Thread Phoenix Sol
Is it alright to call evbuffer_readline() on a buffevent's evbuffer?
( Or any of the other evbuffer functions for that matter? )

I'm wrapping bufferevents with a python 'socket module' interface, and must
accomadate a 'fileobject' interface, which implements readline.

Also, I want to keep copying to a minimum; maybe using bufferevent is not
the best approach?

Gee... can I do 'zero-copy' networking in stackless python with libevent ?!

No? Then how about lua?

Thanks  :-\

( respectful bow to the monkeys )
( whoo hoo hoo haa haaa h haa! )
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users