On 4/13/26 10:40 AM, Camm Maguire wrote:
Greetings, and thank you so much for bringing this to my attention! I
have committed a fix to branch 2_7_2pre, which will be in the
forthcoming debian package being built now.
Thanks for the fix. My simple slurp-bytes test with maxima.info-1
(1030671 bytes) goes from 19.1 sec with gcl 2.7.1 to 0.090 sec with this
fix. With `si:fread`, it's 0.01 sec with the latest gcl. So there is
some room for improvement. But going from 19.1 to 0.09 is a huge
improvement and fast enough for me now.
Right now read-sequence loops over read-byte when appropriate, so could
be accelerated further with fread, but I doubt you will be able to see
much difference. If using fread, we will have to duplicate the logic in
read-byte concerning the stream-element-type, but that is just ugly and
could be done. One thing I've always wanted in GCL is an interface to
my favorite Linux file I/O facility, mmap.
Take care,
Raymond Toy<[email protected]> writes:
On 4/8/26 9:21 AM, Raymond Toy wrote:
I have this routine:
(defun slurp-bytes (filename)
"Return the entire contents of FILENAME as a (unsigned-byte 8) vector.
Results are cached in *bytes-cache* so each file is read only once."
(or (gethash filename *bytes-cache*)
(setf (gethash filename *bytes-cache*)
(with-open-file (s filename :direction :input
:element-type '(unsigned-byte 8))
(let* ((len (file-length s))
(buf (make-array len :element-type '(unsigned-byte 8))))
(read-sequence buf s)
buf)))))
When reading maxima.info-1 (1030671 bytes), it takes a very long time
(several seconds). Is there anyway to speed this up?
I would have expected reading a bunch of bytes from a file via read-sequence
would be very fast.
Some googling pointed me to si:fread. It makes slurp-bytes really fast taking
tiny fractions of a sec to read i a 1 MB file.
Having read-sequence use si:fread for element types of character or
(unsigned-byte 8) would be a really good thing.
​