From: Berke Durak <berke.durak@exalead.com>
To: Francois Rouaix <francois.rouaix@gmail.com>
Cc: John Caml <camljohn42@gmail.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] large hash tables
Date: Wed, 20 Feb 2008 10:37:59 +0100 [thread overview]
Message-ID: <47BBF4F7.7000101@exalead.com> (raw)
In-Reply-To: <f2d6cc680802191551r2385d6b4p89af2bbd1db4ff15@mail.gmail.com>
Francois Rouaix a écrit :
> In the resizing code there is a non-tailrec function (insert_bucket).
> This is most likely causing the stack overflow, as I can't see any other
> non tail recursive function at first glance. Looks like it's not tail
> rec in order to maintain an invariant on the order of elements. If that
> invariant is not useful to you, you might want to write a slightly
> different version of the Hashtbl module, where insert_bucket would be
> tail rec.
> Also, during resizing, memory usage will be twice the memory required
> for the table (roughly), since the bucket array remains available until
> the resize is completed, so all the bucket contents exist in two
> versions (old and new). You might want to stick to a large initial size
> and do not attempt resizing.
In that casse a quick hack could also be to slightly randomize the key, as in
let digest_bytes = 5
let keyify u =
(String.substring (Digest.string u) 0 digest_bytes, u)
> let read_whole_chan chan =
> let movieMajor = Hashtbl.create 777777 in
>
> let rec loadLines count =
> let line = input_line chan in
> let murList = Pcre.split line in
> match murList with
> | m::u::r::[] ->
> let rFloat = float_of_string r in
> Hashtbl.add (keyify movieMajor) m (u, rFloat);
> if (count mod 10000) == 0 then Printf.printf "count:
> %d, m: %s, u: %s, r: %f \n" count m u rFloat;
> loadLines (count + 1)
> | _ -> raise SplitError
> in
>
> try
> loadLines 0
> with
> End_of_file -> ()
> ;;
--
Berke DURAK
next prev parent reply other threads:[~2008-02-20 9:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-19 23:01 John Caml
2008-02-19 23:34 ` [Caml-list] " Gabriel Kerneis
2008-02-19 23:36 ` Gerd Stolpmann
2008-02-19 23:51 ` Francois Rouaix
2008-02-20 9:37 ` Berke Durak [this message]
2008-02-20 9:56 ` Berke Durak
2008-02-20 12:48 ` Richard Jones
2008-02-20 15:54 ` Oliver Bandel
2008-02-21 22:45 ` John Caml
2008-02-22 0:33 ` Richard Jones
2008-02-24 5:39 ` John Caml
2008-02-22 14:19 ` Brian Hurt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47BBF4F7.7000101@exalead.com \
--to=berke.durak@exalead.com \
--cc=caml-list@yquem.inria.fr \
--cc=camljohn42@gmail.com \
--cc=francois.rouaix@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox