Closed svenha closed 5 years ago
Hi Sven,
This is not what I observe. Considering the following program:
(module foo (main main))
(define (main argv) (define v (make-vector 100000 10)) (define f (if (equal? (getenv "FAST") "fast") test2 test))
(print (if (equal? (getenv "FAST") "fast") "fast" "slow"))
(let loop ((i (if (pair? (cdr argv)) (string->integer (cadr argv)) 10000))) (when (>fx i 0) (f v) (loop (-fx i 1)))))
(define (vfor-each pred v) (do ((i 0 (+ i 1)) (end (vector-length v))) ((>= i end)) (pred (vector-ref v i))))
(define (test v) (define (pred x) (integer? x))
(vfor-each pred v))
(define (test2 v) (define (pred x) (integer? x)) (vector-for-each pred v))
The version using the buitin vector-for-each version is about 3 times faster (which is expected because the macro-expansion of vector-for-each enables the compiler to eliminate the indirect call to integer?). Don't you observe something similar?
For this example, I see a similar speedup of 2.1. Hence, there must be some other effect in my affected program. I will investigate further, but I close this issue.
@manuel-serrano, how about removing vector-for-each definitions from bglstone (maze.scm)? Then we can track the performance of vector-for-each with the help of bglstone.
Done. I will generate a new bgltone tarball.
Thanks for the new bglstone version; it works as expected.
bigloo has a new builtin function vector-for-each (using a compiler expander). But a simple function seems to be faster:
Of course, this solution is missing a dispatch for the two-vector case and the n-vector case.