chicken-users
[Top][All Lists]
Advanced

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

Re: register-compiled-module performance


From: megane
Subject: Re: register-compiled-module performance
Date: Sat, 11 Jan 2020 17:47:48 +0200
User-agent: mu4e 1.0; emacs 25.1.1

Matt Welland <address@hidden> writes:

> With Chicken 4 I'm seeing a pretty high impact on startup time from
> (declare (uses foo.import)). I think that will be less of a problem when I
> switch from using * for my export lists to only the procedures that need to
> be exported. However I was very surprised to see readline in the top three
> when I ran a profile. I'm thinking somehow I've created a genuine problem
> but I've no idea what to look for.
>
> Suggestions?

I'd guess this is from the O(n^2) behaviour of merge-se in modules.scm.
This has been fixed in C5.

Here's a version for C4 that I used to use:

(define (merge-se . ses*) ; later occurrences take precedence to earlier ones
  (let ([table (make-hash-table)]
        [rses (reverse ses*)])
    (let loop ([ses (cdr rses)]
               [last-se #f]
               [se2 (car rses)])
      (cond
       [(null? ses) se2]
       [(eq? last-se (car ses))
        (loop (cdr ses) last-se se2)]
       [(null? (car ses))
        (loop (cdr ses) last-se se2)]
       [(not last-se)
        (for-each (lambda (e) (hash-table-set! table (car e) #t)) se2)
        (loop ses se2 se2)]
       [else
        (let lp ([se (car ses)]
                 [se2 se2])
          (cond
           [(null? se) (loop (cdr ses) (car ses) se2)]
           [(hash-table-exists? table (caar se))
            (lp (cdr se) se2)]
           [else
            (hash-table-set! table (caar se) #t)
            (lp (cdr se) (cons (car se) se2))]))]))))
>
> Note - migration is a work in progress but we are not quite at a point
> where I can test this in Chicken 5.
>
> procedure                                                          calls
>  seconds  average  percent
> ---------------------------------------------------------------------------------------------------
> <syntax>                                                              29
>  1.880    0.064   12.384
> megamod.import.scm:71: ##sys#register-compiled-module                  1
>  1.660    1.660   10.935
> readline.scm:74: ##sys#register-compiled-module                        1
>  1.580    1.580   10.408
> runsmod.import.scm:43: ##sys#register-compiled-module                  1
>  1.350    1.350    8.893




reply via email to

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