[Top][All Lists]
[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: |
12 Apr 2004 21:20:21 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Matthew Mundell <address@hidden> writes:
> Richard Stallman <address@hidden> writes:
> > [...]
> > 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.
This optimisation more than doubles the speed of the generated
function. The optimisation adds two new byte operations. As a start
the new operations always take parameters that are four bytes wide. I
think the loading of these four bytes is the cause of the slower byte
interpretation.
Byte compiled:
("Mon Apr 12 18:03:01 2004" "Mon Apr 12 18:03:20 2004") 19 s
("Mon Apr 12 18:03:50 2004" "Mon Apr 12 18:04:09 2004") 19 s
Compiled from byte code to native:
("Mon Apr 12 18:05:24 2004" "Mon Apr 12 18:05:26 2004") 2 s
("Mon Apr 12 18:05:45 2004" "Mon Apr 12 18:05:48 2004") 3 s
An equivalent primitive runs in under a second. I think the speed
difference between the primitive and the generated native is largely
due to type checking and type extraction done in the loop of the
generated native. Perhaps this could be also be optimised out of the
loop. I think that may be fairly difficult.
> [...]
> 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
The test function (aka silly-loop) is below.
(defun test-simple (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))))
- Re: Compilation to native, (continued)
- Re: Compilation to native, Kenichi Handa, 2004/04/13
- Re: Compilation to native, Juri Linkov, 2004/04/13
- Re: Compilation to native, Kenichi Handa, 2004/04/13
- Pure strings (Re: Compilation to native), Juri Linkov, 2004/04/15
- Re: Pure strings (Re: Compilation to native), Richard Stallman, 2004/04/18
- Re: Pure strings (Re: Compilation to native), Kenichi Handa, 2004/04/19
- Re: Pure strings (Re: Compilation to native), Stefan Monnier, 2004/04/19
- Re: Pure strings (Re: Compilation to native), Kenichi Handa, 2004/04/19
- Re: Pure strings (Re: Compilation to native), Richard Stallman, 2004/04/19
- Re: Pure strings (Re: Compilation to native), Kenichi Handa, 2004/04/19
Re: Compilation to native,
Matthew Mundell <=
- Re: Compilation to native, Stefan Monnier, 2004/04/12
- Re: Compilation to native, Matthew Mundell, 2004/04/13
- Re: Compilation to native, Stefan Monnier, 2004/04/13
- Re: Compilation to native, Matthew Mundell, 2004/04/13
- Re: Compilation to native, Miles Bader, 2004/04/13
- Re: Compilation to native, Miles Bader, 2004/04/13
- Re: Compilation to native, Matthew Mundell, 2004/04/14
- Re: Compilation to native, Matthew Mundell, 2004/04/16
Re: Compilation to native, Miles Bader, 2004/04/13
Re: Compilation to native, Matthew Mundell, 2004/04/16