Re: [Chicken-hackers] [PATCH] Fix performance bottleneck in compiling large files, add profiling option
From: Peter Bex peter@xs4all.nl Subject: Re: [Chicken-hackers] [PATCH] Fix performance bottleneck in compiling large files, add profiling option Date: Mon, 23 Jan 2012 09:09:56 +0100 On Mon, Jan 23, 2012 at 05:47:55AM +0100, Felix wrote: I think this option is generally useful since if the compiler reports a procedure nesting depth of more than about 10, this rapidly becomes useless to a user (it also reports procedure nesting when the scrutinizer finds a possible type error). Thanks for the patch and the investigation of this problem. I must say that I would find such an option rather obscure. I considered that, but I think in some cases it would be useful to be able to increase the limit, or remove it altogether. Don't forget, it's not just the C comments but also the scrutinizer messages that are affected by this option. We could move the option to the obscure options section of the help :) No, please no such option. Couldn't we simply do a cutoff, probably preserving starting and ending elements of the nesting list?, in other words: FOO in BAR in ... in YES in NO in PERHAPS ? With (say) 10 elements at the front and the back this should be more than sufficient. This could be done but I'm afraid that traversing all the way up the tree also causes exponential cost. A cutoff point ensures that there's an upper bound for each item, and that upper bound can be seen as a constant factor of the compilation as a whole. Then cut it off, 20 should be enough. cheers, felix ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] inline calls to variables bound to extended binding
* felix winkelmann fe...@call-with-current-continuation.org [120123 06:10]: Hello! The attached patch add a special case of inlining by transforming calls like (variable ...) to (standard-or-extended binding ...), where variable is known to refer to some of the builtin procedures known as standard/extended bindings (listed in the FAQ). Previously only direct calls to such bindings where specifically handled). Looks fine to me, pushed! Thanks, christian -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix performance bottleneck in compiling large files, add profiling option
On Mon, Jan 23, 2012 at 11:19:14AM +0100, Felix wrote: I considered that, but I think in some cases it would be useful to be able to increase the limit, or remove it altogether. Don't forget, it's not just the C comments but also the scrutinizer messages that are affected by this option. We could move the option to the obscure options section of the help :) No, please no such option. OK, no prob, then we'll just hardcode it. I doubt people will find it useful to increase the depth, anyway. This could be done but I'm afraid that traversing all the way up the tree also causes exponential cost. A cutoff point ensures that there's an upper bound for each item, and that upper bound can be seen as a constant factor of the compilation as a whole. Then cut it off, 20 should be enough. How about the attached patch? Cheers, Peter -- http://sjamaan.ath.cx -- The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music. -- Donald Knuth From 3b3e278df64b5d8ae4dd1dcd8576f9597d32c5ca Mon Sep 17 00:00:00 2001 From: Peter Bex peter@xs4all.nl Date: Mon, 23 Jan 2012 18:39:34 +0100 Subject: [PATCH] Limit depth for procedure nesting reports to ensure linear scaling of compilation times on input file size. --- support.scm | 24 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/support.scm b/support.scm index 191ae7c..fe85940 100644 --- a/support.scm +++ b/support.scm @@ -1398,6 +1398,9 @@ (define (set-real-name! name rname) (##sys#hash-table-set! real-name-table name rname) ) +;; Arbitrary limit to prevent runoff into exponential behavior +(define real-name-max-depth 20) + (define (real-name var . db) (define (resolve n) (let ([n2 (##sys#hash-table-ref real-name-table n)]) @@ -1409,15 +1412,20 @@ (cond [(not rn) (##sys#symbol-qualified-string var)] [(pair? db) (let ([db (car db)]) -(let loop ([nesting (list (##sys#symbol-qualified-string rn))] +(let loop ([nesting (list (##sys#symbol-qualified-string rn))] +[depth 0] [container (get db var 'contained-in)] ) - (if container - (let ([rc (resolve container)]) -(if (eq? rc container) -(string-intersperse (reverse nesting) in ) -(loop (cons (symbol-string rc) nesting) - (get db container 'contained-in) ) ) ) - (string-intersperse (reverse nesting) in )) ) ) ] + (cond +(( depth real-name-max-depth) + (string-intersperse (reverse (cons ... nesting)) in )) +(container + (let ([rc (resolve container)]) + (if (eq? rc container) + (string-intersperse (reverse nesting) in ) + (loop (cons (symbol-string rc) nesting) + (fx+ depth 1) + (get db container 'contained-in) ) ) )) +(else (string-intersperse (reverse nesting) in ))) ) ) ] [else (##sys#symbol-qualified-string rn)] ) ) ) (define (real-name2 var db) -- 1.7.3.4 ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Fix performance bottleneck in compiling large files, add profiling option
* Peter Bex peter@xs4all.nl [120123 18:50]: How about the attached patch? I have pushed it, thanks! -- Who can (make) the muddy water (clear)? Let it be still, and it will gradually become clear. Who can secure the condition of rest? Let movement go on, and the condition of rest will gradually arise. -- Lao Tse. ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers