[racket] Extremely slow reading a hash

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Mar 8 23:39:42 EST 2011

Earlier today, Jeremy Price wrote:
> I saved and loaded using:
> (with-output-to-file "/home/user/bayes-data" (lambda () (write
> trained_categories) ))
> (with-input-from-file "/home/user/bayes-data" (lambda () (set!
> trained_categories (read))))

When you read a hash table you get an immutable one, which is
intenally very different from mutable ones.  I don't know the details,
but it might be that it's less efficient when it gets to a huge table
(IIRC, it's implemented as a balanced tree?).  But even if it wasn't,
it might be that the reader is reading the list and then making a
hash table out of it, which can be a problem at such sizes.  So it's
probably better to just write the entries one by one, and on reading
it write some small code that will read them and put them in a new

There's also the `racket/fasl' module (`scheme/fasl' in your version),
which might be worth trying, but since it also leads to getting an
immutable hash it might have the same problem.

Four minutes ago, Robby Findler wrote:
> I don't know if this has been fixed or not, but it is not difficult
> to try a more recent version. You can build it in your own home
> directory pretty easily once you get the basic source development
> packages installed. Under linux this is a pretty painless progress
> so I'd encourage you to give it a go.

There's no need to compile -- just grab the ubuntu installer from
racket-lang.org.  It's a simple .sh installer -- just run it, and for
the first question (use a unix-style distribution) answer "no".
You'll get the complete racket installed in a single directory that
you can keep in your home directory or moved around, and if you want
to uninstall it, you just remove the whole thing.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.