khaines / enigo.com wrote:
> Like everyone else, I've been testing my stuff under 1.9.0.  In general, 
> it's been pretty easy to get things running under it.  However, I have 
> ran into an interesting issue.
> 
> My async logger, Analogger, uses slice!() on strings to shave chunks off 
> of incoming buffers.  It's quite fast compared to alternativs under 1.8.x.
> 
> In 1.9.0, though, Analogger was running at 8% of the 1.8.x speed.  Yes, 
> _eight_ percent.  The entire blame for the speed difference turned out 
> to fall on a single line that used slice!() on a string.
> 
> I changed the code to use a position pointer in the buffer, and it 
> works, now.  Under 1.8.x, that implementation is substantially slower.  
> By about 25%.  But it is faster under 1.9.0.
> 
> The situation begs a question, though.  For code that needs to implement 
> buckets of bytes, shouldn't there be something that offers much of the 
> functionality of the 1.8.x String in order to support efficient 
> bucket-of-bytes operations?
> 
> There is a lot of code out there besides mine that manipulates these 
> chunks of bytes, and doesn't care about string encodings.  It makes 
> sense to me that there still exist an efficient way to deal with that.
> 
> 
> Kirk Haines
> 

I would expect the speed to go back up if you call force_encoding(nil) 
on the string before calling slice! That allows you to treat it as 
unencoded bytes.

Only do this, though if you can be confident that you won't slice any 
multi-byte characters down the middle, since that would leave you with 
corrupt data.

	David Flanagan