lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Coroutines once stated:
> On Tue, Aug 26, 2014 at 4:44 PM, Sean Conner <sean@conman.org> wrote:
> 
> >   Since the buffer is to be reused, and I know how I'm using the buffer,
> > recvb() reads into the buffer starting at offset 0.  It then sets idx to the
> > number of bytes read.  buffermeta_byte() uses idx as the length of the
> > "string".
> 
> What I was confused about was that returned the byte indexed from
> buf[idx + i - 1] -- this seems incorrect.  Shouldn't it just be i - 1
> (up to idx at most?)

  Check out str_byte() in lstrlib.c of Lua.  I copied that routine.

> >   Okay, the names are bad, and it assumes a particular usage.  What can I
> > say, it's proof-of-concept code.
> >
> >> Seems like immutable, pooled strings are still winning on speed though :-)
> >
> >   Yup.
> 
> I would love to know why that is -- if Lua's GC is keeping up with how
> often the recv() (not recvb()) string is unreferenced or it's just
> truly faster to create many many duplicates ~ somehow.  Maybe it's
> just a stack vs heap difference -- someone told me strings are
> stack-allocated in Lua but I forget how.

  Have you tried the other network stacks?  Or are you testing the buffer
code alone?

  -spc