[Redis] Perl Redis Client news

Aaron Crane arc at cpan.org
Fri Nov 22 17:21:09 GMT 2013


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.

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.

-- 
Aaron Crane ** http://aaroncrane.co.uk/



More information about the Redis mailing list