gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] Re: compiler speedup hack


From: Camm Maguire
Subject: [Gcl-devel] Re: compiler speedup hack
Date: 15 Mar 2006 18:11:59 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Thanks for the tip!  This is in now. gcc times down from 9 to 6.5
seconds on my machine in your example.  Have not measured the effects
on a real system compilation.

Am cc'ing Robert as we have discussed gcc time speedups before.
Robert, in thinking about your suggestions:

1) Not having gcc hit the file system -- this appears to be possible
   all the way up to the assembly stage.  The assembler (gas) is also
   bfd based, and cannot therefore output to stdout (file must be
   seekable).  We actually have the source to gas under binutils, and
   it is conceivable that we could incoporate it and modify it
   to write to a block of memory, then use gcc with -S with input and
   output pipes.  It would be a medium sized project, and I'm not sure
   what performance gain we'd see given Bob's results below.

2) gcc warm start -- This cmpinclude preprocess is the closest thing I
   can see at present.  It is too bad that gcc (apparently) does not
   have any incremental compile ability (even if only to assembler),
   i.e. read from stdin, special char means flush stdout, etc.  If you
   run across same or similar, please let me know.

Take care,



Robert Boyer <address@hidden> writes:

> As usual, I probably don't know what I am doing, but the following seems
> amusing.  I suspect we can cut the compile time costs of the sluggish GCL
> COMPILE function by 1/3 (at least for one line functions) with the following
> hack of using cpp to generate a cmpinclude file that has all of the cpp stuff
> done beforehand.  The following Lisp function creates the appropriate new
> cmpinclude-string.  I refer to the resulting string through the contents of
> the file /u/boyer/cmpinclude.h, which is referenced below.  I do not include
> this string itself in this message because it is over 200,000 characters
> long.
> 
> (defun make-new-cmpinclude-string ()
>   (let* ((c-file-name1 (format nil "~a.c" (compiler::gazonk-name)))
>          (c-file-name2 (format nil "~a.c" c-file-name1)))
>     (cond ((not (stringp compiler::*cmpinclude-string*))
>            (error "compiler::*cmpinclude-string* is not a string.")))
>     (with-open-file (s c-file-name1 :direction :output)
>       (si::fwrite compiler::*cmpinclude-string* 0
>                   (length compiler::*cmpinclude-string*)
>                   s))
>     (system (format nil
>                     "cpp -I/u/boyer/gcl/gcl-2.7.0/h -P -dD ~a > ~a"
>                     c-file-name1
>                     c-file-name2))
>     (setq compiler::*cmpinclude-string*
>           (si::file-to-string c-file-name2))
>     (delete-file c-file-name1)
>     (delete-file c-file-name2)
>     (length compiler::*cmpinclude-string*)
>     ))
> 
> Below are three transcripts that prove my point about the times, or so it
> seems to me.
> 
> Of course, the really winning thing to do is to figure out how to make a save
> image of gcc itself right at the exact instant it has cpp'ed the cmpinclude
> string, but that might take a gcc genius.  Maybe rms would be willing to do
> give it a try.
> 
> -------------------------------------------------------------------------------
> 
> Here's a run with the normal, default compiler.  Nothing to note here except
> the time.
> 
> % xg
> GCL (GNU Common Lisp)  2.7.0 ANSI    Mar 11 2006 13:56:48
> Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
> Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
> Modifications of this banner must retain notice of a compatible license
> Dedicated to the memory of W. Schelter
> 
> Use (help) to get some basic information on how to use GCL.
> Temporary directory for compiler files set to /tmp/
> 
> >(progn
>  ; (setq compiler::*cmpinclude-string* nil)
>  ; (setq compiler::*cmpinclude* "\"/u/boyer/my-partition/gcl/h\"")
>  ; (setq compiler::*cmpinclude* "\"/u/boyer/cmpinclude.h\"")
> 
>   ; to avoid some stupid new warnings, we stick a -w at the end of *cc*.
>   (setq compiler::*cc* "gcc -c -Wall -DVOL=volatile -fsigned-char -pipe -w ")
>   (setq *COMPILE-VERBOSE* nil)
>   (setq *LOAD-VERBOSE* nil)
>   ; to avoid gcing as much as we can we do some allocates.
>   (si::allocate 'array 3000 t)
>   (si::allocate 'cons 5000 t)
>   (si::allocate 'relocatable 5000 t)
>   (si::allocate 'contiguous 5000 t)
>   (si::allocate 'sfun 5000 t)
>   (si::gbc t)
>   (setq si::*notify-gbc* t)
>   ; We print this banner to see a gc maybe invalidated the test.
>   (format t "~%Start test.~%")
>   (defun test-time (n)
>     (time (loop for i from 1 to n
>                 do (eval '(progn (defun foo (x) x)(compile 'foo))))))
>   (compile 'test-time)
>   (test-time 100))
> 
> Start test.
> real time       :     11.500 secs
> run-gbc time    :      0.200 secs
> child run time  :      8.540 secs
> gbc time        :      0.000 secs
> NIL
> 
> >
> 
> -------------------------------------------------------------------------------
> Now we show that not writing out the cmpinclude string but using include does
> not really save any time, as you probably already knew.
> 
> % xg
> GCL (GNU Common Lisp)  2.7.0 ANSI    Mar 11 2006 13:56:48
> Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
> Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
> Modifications of this banner must retain notice of a compatible license
> Dedicated to the memory of W. Schelter
> 
> Use (help) to get some basic information on how to use GCL.
> Temporary directory for compiler files set to /tmp/
> 
> >(progn
>  (setq compiler::*cmpinclude-string* nil)
>  (setq compiler::*cmpinclude* "\"/u/boyer/my-partition/gcl/h\"")
>  ; (setq compiler::*cmpinclude* "\"/u/boyer/cmpinclude.h\"")
> 
>   ; to avoid some stupid new warnings, we stick a -w at the end of *cc*.
>   (setq compiler::*cc* "gcc -c -Wall -DVOL=volatile -fsigned-char -pipe -w ")
>   (setq *COMPILE-VERBOSE* nil)
>   (setq *LOAD-VERBOSE* nil)
>   ; to avoid gcing as much as we can we do some allocates.
>   (si::allocate 'array 3000 t)
>   (si::allocate 'cons 5000 t)
>   (si::allocate 'relocatable 5000 t)
>   (si::allocate 'contiguous 5000 t)
>   (si::allocate 'sfun 5000 t)
>   (si::gbc t)
>   (setq si::*notify-gbc* t)
>   ; We print this banner to see a gc maybe invalidated the test.
>   (format t "~%Start test.~%")
>   (defun test-time (n)
>     (time (loop for i from 1 to n
>                 do (eval '(progn (defun foo (x) x)(compile 'foo))))))
>   (compile 'test-time)
>   (test-time 100))
> 
> Start test.
> real time       :     11.390 secs
> run-gbc time    :      0.150 secs
> child run time  :      8.480 secs
> gbc time        :      0.000 secs
> NIL
> 
> >
> -------------------------------------------------------------------------------
> Now we show that having the cpp preprocessed version of the cmpinclude string
> (actually as an include file) saves a lot of time.
> 
> % xg
> GCL (GNU Common Lisp)  2.7.0 ANSI    Mar 11 2006 13:56:48
> Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
> Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
> Modifications of this banner must retain notice of a compatible license
> Dedicated to the memory of W. Schelter
> 
> Use (help) to get some basic information on how to use GCL.
> Temporary directory for compiler files set to /tmp/
> 
> >(progn
>  (setq compiler::*cmpinclude-string* nil)
>  ; (setq compiler::*cmpinclude* "\"/u/boyer/my-partition/gcl/h\"")
>  (setq compiler::*cmpinclude* "\"/u/boyer/cmpinclude.h\"")
> 
>   ; to avoid some stupid new warnings, we stick a -w at the end of *cc*.
>   (setq compiler::*cc* "gcc -c -Wall -DVOL=volatile -fsigned-char -pipe -w ")
>   (setq *COMPILE-VERBOSE* nil)
>   (setq *LOAD-VERBOSE* nil)
>   ; to avoid gcing as much as we can we do some allocates.
>   (si::allocate 'array 3000 t)
>   (si::allocate 'cons 5000 t)
>   (si::allocate 'relocatable 5000 t)
>   (si::allocate 'contiguous 5000 t)
>   (si::allocate 'sfun 5000 t)
>   (si::gbc t)
>   (setq si::*notify-gbc* t)
>   ; We print this banner to see a gc maybe invalidated the test.
>   (format t "~%Start test.~%")
>   (defun test-time (n)
>     (time (loop for i from 1 to n
>                 do (eval '(progn (defun foo (x) x)(compile 'foo))))))
>   (compile 'test-time)
>   (test-time 100))
> 
> Start test.
> real time       :      7.470 secs
> run-gbc time    :      0.200 secs
> child run time  :      5.000 secs
> gbc time        :      0.000 secs
> NIL
> 
> >(/ 7.47 11.39)
> 
> 0.65583845478489899
> 
> >
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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