Re: File I/O Metrics
Garrett Dangerfield <[email protected]> Fri, 21 Oct 2022 16:53:03 -0700
| Newsgroups | gmane.editors.j.devel |
|---|---|
| Message-ID | <CAH3WWf_i7ZVOqy2uF=MWf5Szg=Cj9gL7qTbh=62vOqNZcGtgcw@mail.gmail.com> |
--000000000000315dfa05eb942548 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =3D (make-array buffer-size :element-type '(unsigned-byte 8)) for n-characters =3D (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 <[email protected]> wrote: > Le 21/10/2022 =C3=A0 23:18, Garrett Dangerfield a =C3=A9crit : > > 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 =3D ,(file-length stream))) > (let ((buffer-size (* 16 1024 1024))) > (time > (loop with buffer =3D (make-array buffer-size :element-type 'octet) > for n-bytes =3D (read-sequence buffer stream) > while (plusp n-bytes))))) > > > > -- > __Pascal Bourguignon__ > > > --000000000000315dfa05eb942548 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Good call. Got the time down with SBCL to 3.5 seconds= .=C2=A0 So still more than twice Java.=C2=A0 ABCL with the same code with t= he big file (5.8G) is around 110+ seconds.</div><div><br></div><div>I'm= still surprised by ABCL being SO much slower than SBCL especially with Jav= a being faster than SBCL.</div><div><br></div><div>Thoughts?</div><div><br>= </div><div>Thanks,</div><div>Garrett.<br></div><div><br></div><div>P.S. I a= lso took the "time" out, I am doing SBCL/ABCL the same way as I d= id in Java with the getting the start time before reading and getting the t= ime after reading. and calculating the duration that way.=C2=A0 It didn'= ;t make any difference that I could see in the times.</div><div><br></div><= div>Lisp code:</div><div>=C2=A0 (with-open-file (stream "/media/danger= /OS/temp/great_expectations.iso"<br> =C2=A0:element-type '(unsi= gned-byte 8)<br> =C2=A0:external-format 'iso-8859-1) ; jars.txt iso-= 8859-1 also tried :default and the time was the same<br> =C2=A0(let ((siz= e (file-length stream))<br> (buffer-size (* 16 1024 1024)) ; 16M<br> (s= tart (get-internal-real-time))<br> )<br>=C2=A0=C2=A0 (loop with buffer = =3D (make-array buffer-size :element-type '(unsigned-byte 8))<br> = =C2=A0for n-characters =3D (read-sequence buffer stream)<br> =C2=A0while= (< 0 n-characters))<br> =C2=A0 =C2=A0(format t "took ~,2f secs&q= uot; (/ (- (get-internal-real-time) start)<br> =C2=A0 internal-time-= units-per-second))<br>=C2=A0=C2=A0 ))<br></div></div><br><div class=3D"gmai= l_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 21, 2022 at 2:52= PM Pascal Bourguignon <<a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a>> wrote:<br></div><blockquote class= =3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg= b(204,204,204);padding-left:1ex">Le 21/10/2022 =C3=A0 23:18, Garrett Danger= field a =C3=A9crit=C2=A0:<br> > I tried changing (make-array buffer-size :element-type 'character)= <br> > to<br> > (make-array buffer-size :element-type 'byte)<br> > and I got additional warnings and it took 70 seconds instead of 20.<br= > > <br> <br> You need to specify a binary file too!<br> <br> (deftype octet () '(unsigned-byte 8))<br> (with-open-file (stream #P"~/Downloads/Discord.dmg"<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0:element-type 'octet<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0:external-format :default)<br> =C2=A0 =C2=A0(print `(size =3D ,(file-length stream)))<br> =C2=A0 =C2=A0(let ((buffer-size (* 16 1024 1024)))<br> =C2=A0 =C2=A0 =C2=A0(time<br> =C2=A0 =C2=A0 =C2=A0 (loop with buffer =3D (make-array buffer-size :element= -type 'octet)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for n-bytes =3D (read-sequence bu= ffer stream)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 while (plusp n-bytes)))))<br> <br> <br> <br> -- <br> __Pascal Bourguignon__<br> <br> <br> </blockquote></div> --000000000000315dfa05eb942548--