chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATCH] Improve performance of read-u8vector


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Improve performance of read-u8vector
Date: Thu, 25 Jun 2015 20:21:14 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hello all,

Yesterday Andy Bennett posted a message about http-client being very slow.
While this is *NOT* the cause of the delays, he did figure out that
(read-u8vector) was slower than (string->u8vector (read-string)).

It turns out that read-u8vector contained its own implementation which
is very similar to, but less efficient than ##sys#read-string/port from
unit extras.  It reads a character at a time, while it would be better
to read from the port in a buffered way.  Also, it's better to share the
code to avoid problems from getting fixed in only one of the two places.

I wrote up a quick hack for Andy which he tested; you can see this at
http://paste.call-cc.org/paste?id=b46e6a3905ae611f2dcce3c3214e7d20384fa8ed
to which he kindly added some benchmark results.  It's somewhere between
2 and 5 times faster now (the results from CHICKEN (time...) and UNIX
time are oddly inconsistent).

At first I thought this would create a (perhaps unwanted) dependency on
the "extras" unit, but then I saw that read-u8vector! is calling
##sys#read-string! which is also defined in extras.  However, there's no
(declare (uses extras)) at the top of srfi-4.scm!  So I also added that
in my patch.

I've attached a separate patch for chicken-5 because cherry-picking from
master caused a merge conflict due to ##sys#check-exact being replaced
with ##sys#check-fixnum; that's the only thing that's different.
I also noticed that Andy wasn't mentioned in the Acknowledgements
section of the manual, so I took the liberty of adding him there.

I'm not sure whether this needs to go into prerelease; it's somewhat
more invasive than a typical "simple bugfix".  On the other hand, it
could be worthwhile.  If not, we should probably move the item to a
different NEWS entry: one for 4.10.1.

Cheers,
Peter

Attachment: 0001-Improve-read-u8vector-performance.CHICKEN-5.patch
Description: Text Data

Attachment: 0001-Improve-read-u8vector-performance.MASTER.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]