[fetter-devel] Verrazano Speedup, take 2

Daniel Herring dherring at tentpost.com
Sun Jan 28 01:53:44 UTC 2007


FWIW, running Verrazano against Qt4.2 (a) isn't working for me and (b) is 
very slow.  Thus, I'm trying to fix (b) to help debug (a).  Profiling 
indicates that most of the time is being spent in (read-macros), hence my 
focus.

>From my read of parser.lisp, (create-macro-nodes) sets the "current file" 
when a line begins with "# ", and (create-macro-node) only processes lines 
beginning with "#define ".

When Verrazano obtains the Qt macros, it calls
`gccxml --preprocess -dDI -I/opt/qt4.2/include vzntemp.cpp > vzntemp.mac`
where vzntemp.cpp is simply the two lines
#include "Qt/QtCore"
const int __verrazano_binding = 1;

The resulting vzntemp.mac is 1.5MB in size, but only 215KB consists of 
lines starting with "#"; the rest is blank lines or function definitions.
Examples:
void qDebug(const char *, ...)
     __attribute__ ((format (printf, 1, 2)))
;

class QString;
  QString qt_error_string(int errorCode = -1);
  void qCritical(const char *, ...)
     __attribute__ ((format (printf, 1, 2)))
;


Thus, I modified (read-macros) to only store non-empty lines beginning 
with #\# (since the rest are never used).

verrazano/frontend/parser.lisp:74
; read macro definitions from the macro file
(defun read-macros (path)
   (let ((macs nil))
     (with-open-file (in path :direction :input :if-exists :supersede)
       (loop for line = (read-line in nil 'eof)
 	    until (eq line 'eof)
 	    do (if (and (not (equal "" line)) (eq #\# (char line 0)))
                    (push-end (split-sequence #\Space line) macs))))
     macs))


This results in fast operation (10s versus 90s), with the added benefit of 
(hopefully) not breaking the macro processing.

Later,
Daniel



More information about the fetter-devel mailing list