Mzscheme I / O performance

As a Linux administrator, I wrote my scripts in Bash, TCL, and, less commonly, in Perl. Just out of curiosity, I tried to write something in mzscheme, but it turned out that the performance was much worse. I disabled the script by simply reading the 500 MB log file:

#lang scheme (require rnrs/programs-6) (call-with-input-file (vector-ref (current-command-line-arguments) 0) (lambda (in) (let loop ((line (read-line in))) (unless (eof-object? line) (loop (read-line in)))))) 

This simple process takes about 40 seconds. The same script adapted for Guile is executed after 10 seconds. TCL version runs for 5 seconds. The chicken circuit takes only 3.8 seconds, ten times less than the MZScheme:

 #!/usr/bin/csi -script (call-with-input-file (list-ref (command-line-arguments) 0) (lambda (in) (let loop ((line (read-line in))) (if (not (eof-object? line)) (loop (read-line in)))))) 

What am I doing wrong? Are there any recommendations for writing faster MZScheme programs?

Some more tests:

 minaev@minaev :~/1$ time ./t.tcl blog.log real 0m8.907s user 0m8.417s sys 0m0.468s Mon Oct 31 13:15:19 MSK 2011 minaev@minaev :~/1$ time ./t.scm blog.log # Chicken 4.2.0 real 0m7.678s user 0m6.896s sys 0m0.580s Mon Oct 31 13:15:29 MSK 2011 minaev@minaev :~/1$ time /usr/bin/mzscheme t.ss blog.log # mzscheme 4.2.1 real 0m44.047s user 0m41.803s sys 0m0.948s Mon Oct 31 13:17:03 MSK 2011 minaev@minaev :~/1$ time racket t.ss blog.log # racket 5.1.3 real 0m25.287s user 0m23.189s sys 0m0.828s Mon Oct 31 13:17:39 MSK 2011 minaev@minaev :~/1$ raco make t.ss Mon Oct 31 13:17:47 MSK 2011 minaev@minaev :~/1$ time racket t.ss blog.log # racket 5.1.3 byte-compiled real 0m23.237s user 0m22.469s sys 0m0.688s 
+4
source share
2 answers

This has improved significantly in the Racket version. See Commit here and a message from Racket Matthew Flatt maintainer here . Now it should be about 50% slower than the chicken. The remaining slowdown is primarily due to additional features provided by Racket, such as events, line counting, Unicode encoding, etc.

+3
source

I tried to repeat your results, and I got about 3.4s for Chicken 4.5.0 and about 10 for different versions of mzscheme / racket. (I tried mzscheme from PLT Scheme 4.2 and racket from Racket 5.1.1 and the development tree, all compiled in 64-bit mode.)

What version of mzscheme are you using? Which platform?

Are your timings repeatable? (Interesting about block cache effects.)

+1
source

All Articles