[Redis] Perl Redis Client news

Steffen Mueller smueller at cpan.org
Fri Nov 22 17:42:41 GMT 2013


On 11/22/2013 06:21 PM, Aaron Crane wrote:
> Steffen Mueller wrote:
>>> I tried a more slightly elaborate solution which would calculate an
>>> upper bound on the output string length first and then allocated that
>>> all in one go. Of course, that would have to peek at each stacked
>>> parameter at least twice and that turned out SLOWER than pure-Perl. Rare
>>> occasion that shaving of mallocs isn't a clear win.
>
> That's a shame (not to mention somewhat surprising) — it was my first
> thought, too.
>
> I wonder whether it would help to preserve the output buffer in an
> encoder object, rather than creating a fresh mortal-SV buffer for each
> command.  At least that way there'd asymptotically be only O(1)
> reallocs.

Good idea. We do this in Sereal where ever we can.

> If there's really a bottleneck in encoding, it might conceivably be
> worth replacing the sv_catpvf() calls with a custom int-to-string
> formatting routine; custom code that handles exactly one type and
> doesn't need to parse a format string should be somewhat faster, but
> the difference might not be big enough to be worth it.

Indeed, that should help. But it's a fair amount of tedium that I wasn't 
prepare to take on. Other things are going to be a lot slower than the 
parser already at the 1.5M commands per second that I posted the other 
day. So I've probably overdone it a bit to begin with. :)

--Steffen



More information about the Redis mailing list