caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] why does hashtbl not use lists?
Date: Tue, 10 Jul 2001 11:05:01 +0200 (MEST)	[thread overview]
Message-ID: <15178.50493.314895.925129@pc803> (raw)
In-Reply-To: <4.3.2.7.2.20010710013127.02c06600@shell16.ba.best.com>


Chris Hecker writes:
 > 
 > Why does hashtbl.ml (from  the standard library) use the bucketlist
 > variant instead of just the built in lists with tuples? Is there an
 > efficiency thing going on here?

Yes, it saves 33% of memory. Indeed, a list of tuples will give blocks
like this:

     ______
     |X|.|.|......>
     ---.--     _______
        ......> |X|a|b|
                -------

that is,  6 words for each  binding, whereas the  bucketlist type will
give blocks like this:

     _________
     |X|a|b|.|....>
     ---------

that is, 4 words. (X stands for  the block header, which is 1 word and
dots stand for pointers; sory for the ugly ASCII drawing).

(Beside saving  memory, you  also save time,  by allocating  one block
instead of two  and also when destructuring the  block to look inside,
since depth is 1 instead of 2.)

-- 
Jean-Christophe Filliatre
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-07-10  9:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-10  8:34 Chris Hecker
2001-07-10  9:00 ` Fergus Henderson
2001-07-10  9:05 ` Jean-Christophe Filliatre [this message]
2001-07-10  9:42   ` Fergus Henderson
2001-07-10 14:44     ` Xavier Leroy
2001-07-10 17:04 Charles Martin

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=15178.50493.314895.925129@pc803 \
    --to=jean-christophe.filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=checker@d6.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;
as well as URLs for NNTP newsgroup(s).