This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
There are a number of modules defined in boot-9.scm. This slows loading notably, makes boot-9.scm harder to maintain, and serves no useful purpose. I found that by moving these modules into separate files, named so that they are correctly autoloaded by the module system, I could cut the startup time of the guile interpreter, as measured by time guile -c "(quit)" in tcsh was cut nearly in half. Before: [mstachow@starman-jones] ~ > time guile -c "(quit)" 1.290u 0.050s 0:02.86 46.8% 0+0k 0+0io 180pf+0w After: [mstachow@starman-jones] ~ > time guile -c "(quit)" 0.780u 0.020s 0:01.71 46.7% 0+0k 0+0io 180pf+0w I wrote a short guile script to automatically make the change in a somewhat intelligent manner when run in the ice-9 directory, so that the maintainers can make the change at their leisure, even if boot-9.scm changes before they get around to it. I ran the script on my /usr/share/guile/1.3a/ice-9 directory, and it worked perfectly. I checked if the (ice-9 {calling,common-list, q,runq,ls,string-fun}) modules, which were previously in the boot-9.scm file, still autoloaded correctly in response to the appropriate use-modules command, and they did. Without further adieu, here is the script (pardon the style, it was just a quick hack to get the job done). If you don't trust it, make the changes by hand instead. - Maciej Stachowiak ---------- #!/usr/bin/guile !# (use-modules (ice-9 string-fun)) (define boot-9-port (open-input-file "boot-9.scm")) (define all-lines '(("boot-9.scm.new.1"))) (define last-page-break all-lines) (while #t (let ((current-line (read-delimited "\n" boot-9-port))) (if (eof-object? current-line) (break 'done)) (append! all-lines (list current-line)) (if (equal? "" current-line) (set! last-page-break (last-pair all-lines))) ; the modules need to go into separate files (if (string-prefix=? "(define-module (ice-9 " current-line) (set-car! last-page-break (list (string-append (split-before-char #\) (make-shared-substring current-line 22 (string-length current-line)) (lambda (x y) x)) ".scm")))) ; but everything after this line needs to go back into boot-9.scm (if (string-prefix=? ";;; {Load debug" current-line) (set-car! last-page-break (list "boot-9.scm.new.2"))))) (define work-port boot-9-port) (for-each (lambda (x) (cond ((string? x) (display x work-port) (newline work-port)) ((list? x) (close-port work-port) (set! work-port (open-output-file (car x)))))) all-lines) (close-port work-port) (rename-file "boot-9.scm" "boot-9.scm.orig") (system "cat boot-9.scm.new.1 boot-9.scm.new.2 > boot-9.scm") (delete-file "boot-9.scm.new.1") (delete-file "boot-9.scm.new.2")