[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: In support of guile-emacs
From: |
Taylan Ulrich Bayırlı/Kammer |
Subject: |
Re: In support of guile-emacs |
Date: |
Mon, 19 Oct 2015 23:01:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Alan Mackenzie <address@hidden> writes:
> Hello, Taylan.
>
> [... snip ...]
>
>> I actually did some silly looping tests, but decided not to post them.
>> As far as the silly loops were concerned, there wasn't much difference.
>> Elisp's dotimes counts to ten million slightly faster than Guile's 'do'
>> with explicit counting (best approximation of 'dotimes' I could come up
>> with). Guile iterates over a list of ten million elements faster. It
>> didn't seem worthwhile to post; ....
>
> _Any_ real timings are better than hand waving. Sophisticated testing
> can wait until things are ready for them.
You're right, that may have been overly hand-wavy...
>> .... silly loops are just silly loops. (Incidentally, silly loops got
>> faster in Guile 2.2![0] Apparently non-silly loops also got faster
>> though.[1])
>
>> [0] http://wingolog.org/archives/2013/11/26/a-register-vm-for-guile
>> [1] http://wingolog.org/archives/2015/07/28/loop-optimizations-in-guile
>
>> And here some fun; when I tried to imitate dotimes with a "named let"
>> loop instead of 'do':
>
>> > ,time (let loop ((i 0)) (unless (= 10000000) (loop (+ i 1))))
>> ;; 0.002618s real time, 0.002607s run time. 0.000000s spent in GC.
>
>> What?! That's way too fast. Oh wait...
>
> That's a loop of 10,000,000 taking 2.618e-3 seconds. That would be
> 2.6e-10 seconds per iteration, or approximately 4.0e9 iterations per
> second. With a 4 GHz processor, that's 1 clock cycle per iteration. It
> seems likely that some processing has been optimised away.
>
> When I run this in Emacs on my 2.6 GHz Athlong machine, with M-:
>
> (time-it (let ((i 0)) (while (<= i 10000000) (setq i (1+ i)))))
>
> , this takes 1.8881s. (`time-it' is my own macro, not a standard Emacs
> one.) So, thus far, it's looking like Guile is a factor of ~700 faster.
> :-)
Oh oh, don't forget to byte-compile Elisp. Was my first mistake too.
>> > ,optimize (let loop ((i 0)) (unless (= 10000000) (loop (+ i 1))))
>> $2 = (if #f #f)
>
>> Oh, heh. A void 'do' loop doesn't get the same treatment because of
>> slightly different semantics, but a void named-let loop simply gets
>> eliminated out.
>
> Ah. Shame. How about calculating 1 + 2 + 3 + .... + 10,000,000 in a
> loop, then outputting it? The sum (50,000,005,000,000) should easily fit
> into a 64-bit Lisp integer.
>
> This:
>
> (time-it (let ((i 0) (s 0)) (while (<= i 10000000) (setq s (+ s i)) (setq i
> (1+ i))) (message "%s" s)))
>
> takes 3.389s on my machine.
Takes about 0.62s here, when byte-compiled. The Guile variant:
(let ((i 0) (s 0))
(while (<= i 10000000)
(set! s (+ s i))
(set! i (1+ i)))
(format #t "~s" s))
Takes about 0.55s. That's a very literal transcription of the function
to Scheme. A more idiomatic version:
(let loop ((i 0) (s 0))
(if (<= i 10000000)
(loop (+ i 1) (+ s i))
(format #t "~s" s)))
Takes about 0.50s.
BTW here's a timing function that automatically byte-compiles the
argument (side-effectfully if a symbol):
(defun time (function)
"Return execution time of calling FUNCTION in seconds as a
float. FUNCTION is byte-compiled automatically."
(setq function (byte-compile function))
(let ((start (current-time)))
(funcall function)
(let ((end (current-time)))
(let ((time (time-subtract end start)))
(+ (* (nth 0 time) (expt 2 16))
(nth 1 time)
(/ (nth 2 time) 1000000.0))))))
>> > Is the Guile VM, in fact, faster than the Emacs byte interpreter? Who's
>> > done any measurements? Surely the speed advantage/disadvantage of the
>> > Guile VM will depend, possibly a lot, on what program is being tested,
>> > but has anybody actually done any actual benchmarking?
>
>> I would also like to know, really. I don't know what good benchmarks
>> might be that are both realistic and show the benefits of Guile's added
>> optimization passes and such.
>
> If Guile Emacs is advanced enough, timing the fontification of a file
> (say, ..../src/xdisp.c in our repository) would be a very meaningful
> timing.
I'm guessing that Guile Emacs isn't ready for that yet but, how can one
time that?
Taylan
- Re: In support of guile-emacs, (continued)
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/19
- Re: In support of guile-emacs, David Kastrup, 2015/10/19
- Re: In support of guile-emacs, Daniel Colascione, 2015/10/19
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/19
- Re: In support of guile-emacs, Taylan Ulrich Bayırlı/Kammer, 2015/10/19
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/19
- Re: In support of guile-emacs, Taylan Ulrich Bayırlı/Kammer, 2015/10/19
- Re: In support of guile-emacs, Dmitry Gutov, 2015/10/19
- Re: In support of guile-emacs, Taylan Ulrich Bayırlı/Kammer, 2015/10/19
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/19
- Re: In support of guile-emacs,
Taylan Ulrich Bayırlı/Kammer <=
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/20
- Re: In support of guile-emacs, Taylan Ulrich Bayırlı/Kammer, 2015/10/20
- Re: In support of guile-emacs, John Wiegley, 2015/10/20
- Re: In support of guile-emacs, Taylan Ulrich Bayırlı/Kammer, 2015/10/21
- Re: In support of guile-emacs, Alan Mackenzie, 2015/10/21
- Re: In support of guile-emacs, David Kastrup, 2015/10/20
- Re: In support of guile-emacs, David Kastrup, 2015/10/19
Re: In support of guile-emacs, Tom, 2015/10/19