[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Speed of Lua's immutable strings vs buffers (split from Re: Pooling of strings is good)
- From: Coroutines <coroutines@...>
- Date: Tue, 26 Aug 2014 16:53:35 -0700
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?)
> 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.
- References:
- Re: Pooling of strings is good, Coroutines
- Re: Pooling of strings is good, Philipp Janda
- Re: Pooling of strings is good, Coroutines
- Re: Pooling of strings is good, Axel Kittenberger
- Re: Pooling of strings is good, Coroutines
- Re: Pooling of strings is good, Roberto Ierusalimschy
- Re: Pooling of strings is good, Coroutines
- Speed of Lua's immutable strings vs buffers (split from Re: Pooling of strings is good), Sean Conner
- Re: Speed of Lua's immutable strings vs buffers (split from Re: Pooling of strings is good), Coroutines
- Re: Speed of Lua's immutable strings vs buffers (split from Re: Pooling of strings is good), Coroutines
- Re: Speed of Lua's immutable strings vs buffers (split from Re: Pooling of strings is good), Sean Conner