Re: register-compiled-module performance

2020-01-11 Thread Matt Welland
On Sat, Jan 11, 2020 at 8:47 AM megane  wrote:

>
> Matt Welland  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.
>

Ok, that is good to know. I'll not worry about startup time for now and
will put the energy into getting to chicken 5. Thanks.


> 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
> >
> ---
> >   29
> >  1.8800.064   12.384
> > megamod.import.scm:71: ##sys#register-compiled-module  1
> >  1.6601.660   10.935
> > readline.scm:74: ##sys#register-compiled-module1
> >  1.5801.580   10.408
> > runsmod.import.scm:43: ##sys#register-compiled-module  1
> >  1.3501.3508.893
>
>

-- 
--
Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.


Re: register-compiled-module performance

2020-01-11 Thread megane


Matt Welland  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
> ---
>   29
>  1.8800.064   12.384
> megamod.import.scm:71: ##sys#register-compiled-module  1
>  1.6601.660   10.935
> readline.scm:74: ##sys#register-compiled-module1
>  1.5801.580   10.408
> runsmod.import.scm:43: ##sys#register-compiled-module  1
>  1.3501.3508.893




register-compiled-module performance

2020-01-11 Thread Matt Welland
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?

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
---
  29
 1.8800.064   12.384
megamod.import.scm:71: ##sys#register-compiled-module  1
 1.6601.660   10.935
readline.scm:74: ##sys#register-compiled-module1
 1.5801.580   10.408
runsmod.import.scm:43: ##sys#register-compiled-module  1
 1.3501.3508.893


--
Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.