File I/O Metrics
Alan Ruttenberg
alanruttenberg at gmail.com
Sat Oct 22 05:07:51 UTC 2022
If you need super fast I/O in ABCL the way to go is to do the direct java
calls, same as your Java program. That's what I've done and one gets the
expected performance. The JSS syntax makes it fairly painless. I'll have to
check but I'm fairly sure no serious optimization has been done for
read-sequence.
Alan
On Fri, Oct 21, 2022 at 7:54 PM Garrett Dangerfield <garrett at dangerimp.com>
wrote:
> Good call. Got the time down with SBCL to 3.5 seconds. So still more than
> twice Java. ABCL with the same code with the big file (5.8G) is around
> 110+ seconds.
>
> I'm still surprised by ABCL being SO much slower than SBCL especially with
> Java being faster than SBCL.
>
> Thoughts?
>
> Thanks,
> Garrett.
>
> P.S. I also took the "time" out, I am doing SBCL/ABCL the same way as I
> did in Java with the getting the start time before reading and getting the
> time after reading. and calculating the duration that way. It didn't make
> any difference that I could see in the times.
>
> Lisp code:
> (with-open-file (stream "/media/danger/OS/temp/great_expectations.iso"
> :element-type '(unsigned-byte 8)
> :external-format 'iso-8859-1) ; jars.txt iso-8859-1 also tried :default
> and the time was the same
> (let ((size (file-length stream))
> (buffer-size (* 16 1024 1024)) ; 16M
> (start (get-internal-real-time))
> )
> (loop with buffer = (make-array buffer-size :element-type
> '(unsigned-byte 8))
> for n-characters = (read-sequence buffer stream)
> while (< 0 n-characters))
> (format t "took ~,2f secs" (/ (- (get-internal-real-time) start)
> internal-time-units-per-second))
> ))
>
> On Fri, Oct 21, 2022 at 2:52 PM Pascal Bourguignon <pjb at informatimago.com>
> wrote:
>
>> Le 21/10/2022 à 23:18, Garrett Dangerfield a écrit :
>> > I tried changing (make-array buffer-size :element-type 'character)
>> > to
>> > (make-array buffer-size :element-type 'byte)
>> > and I got additional warnings and it took 70 seconds instead of 20.
>> >
>>
>> You need to specify a binary file too!
>>
>> (deftype octet () '(unsigned-byte 8))
>> (with-open-file (stream #P"~/Downloads/Discord.dmg"
>> :element-type 'octet
>> :external-format :default)
>> (print `(size = ,(file-length stream)))
>> (let ((buffer-size (* 16 1024 1024)))
>> (time
>> (loop with buffer = (make-array buffer-size :element-type 'octet)
>> for n-bytes = (read-sequence buffer stream)
>> while (plusp n-bytes)))))
>>
>>
>>
>> --
>> __Pascal Bourguignon__
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20221022/177e7a33/attachment-0001.html>
More information about the armedbear-devel
mailing list