emacs-devel
[Top][All Lists]
Advanced

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

Re: Compilation to native


From: Matthew Mundell
Subject: Re: Compilation to native
Date: 30 Mar 2004 23:18:03 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Richard Stallman <address@hidden> writes:

>     The loop _is_ purely computational.
>
> I was fooled by the indentation, which makes it appear
> that the call to current-time-string is inside the loop.
> See?
>
>     (defun silly-loop (n)
>       "Return time before and after N iterations of a loop."
>       (let ((t1 (current-time-string)))
>       (while (> (setq n (1- n))
>                             0))
>           (list t1 (current-time-string))))
>
> Anyway, such a small speedup is not worth the trouble.
> Compilation of CCL may be worth while.  Or optimization
> of the CCL interpreter may be possible.

This is for the record, at least.  The speedup is a little better with
Fgtr inlined into the native, a few excess memory instructions saved,
and, where possible, objects passed between byte operations using
registers instead of the stack.

Byte compiled:
  ("Tue Mar 30 21:54:05 2004" "Tue Mar 30 21:54:21 2004")  16 s
  ("Tue Mar 30 21:54:26 2004" "Tue Mar 30 21:54:42 2004")  16 s
  ("Tue Mar 30 21:54:45 2004" "Tue Mar 30 21:55:01 2004")  16 s

Compiled from byte code to native:
  ("Tue Mar 30 21:55:43 2004" "Tue Mar 30 21:55:49 2004")  6 s
  ("Tue Mar 30 21:55:51 2004" "Tue Mar 30 21:55:58 2004")  7 s
  ("Tue Mar 30 21:56:01 2004" "Tue Mar 30 21:56:07 2004")  6 s

There is the possibility of further improvement, especially for this
example, by moving Lisp object referencing and setting out of loops.
This will surely be tricky, though, if only because the functions
called by the byte code operations could change these objects.

There are also two extra function calls inside the variable setting
operation (Bvarset), which is used inside the loop in the example.
They're a work around to modify struct bit fields, which can probably
be done quicker in place.

The original figures:

> (silly-loop 100000000)
> => ("Sat Feb 28 10:04:39 2004" "Sat Feb 28 10:05:30 2004")     ; 51 secs
>
> (byte-compile 'silly-loop)
> (silly-loop 100000000)
> => ("Sat Feb 28 10:06:37 2004" "Sat Feb 28 10:06:53 2004")     ; 16 secs
>
> (native-compile 'silly-loop)
> (silly-loop 100000000)
> => ("Sat Feb 28 10:17:13 2004" "Sat Feb 28 10:17:22 2004")     ; 9 secs




reply via email to

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