caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Francois BERENGER <berenger@bioreg.kyushu-u.ac.jp>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Hashtbl and shrinking
Date: Mon, 2 Apr 2018 09:34:10 +0900	[thread overview]
Message-ID: <e6d651aa-58a7-6a67-0888-8cf1a6e6b932@bioreg.kyushu-u.ac.jp> (raw)
In-Reply-To: <b779b358-d344-4a4c-c790-746f7e569cf7@ens-lyon.fr>

On 03/30/2018 05:49 AM, Armaël Guéneau wrote:
> Dear caml-list,
> 
> It happens Arthur Charguéraud and myself were looking this afternoon at
> the implementation of the Hashtbl module, provided in our beloved OCaml
> standard library.
> 
> We noticed there is no shrinking implemented, that would typically
> happen when the number of elements goes under a certain threshold
> compared to the size of the underlying array.
> 
> This yields a space complexity that we think may not be what people
> might expect: an almost empty hashtable will consume as much memory as
> when it was full. The time complexity might also be worse than expected,
> because the GC will still spend time scanning the whole array even when
> there are only a few elements.
> 
> What do people here think about this?

That your change would introduce some time complexity that may not be
what people expect for some operations.

That being said, if a resize operations was added to the module, appart
from changing the current interface, it would not harm people much I guess.

We could accept this in batteries, or even revive the old code that was
doing this previously.

Also, if you are so much concerned about the size of your hashtbl, why
don't you use a map?

Regards,
Francois.

> If we submitted a patch implementing shrinking for Hashtbl, could it be
> detrimental for some specific workloads?
> 
> — Armaël
> 

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

      parent reply	other threads:[~2018-04-02  0:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 20:49 Armaël Guéneau
2018-03-30  9:40 ` Christoph Bauer
2018-03-30 19:10 ` Cedric Cellier
2018-04-02  0:34 ` Francois BERENGER [this message]

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=e6d651aa-58a7-6a67-0888-8cf1a6e6b932@bioreg.kyushu-u.ac.jp \
    --to=berenger@bioreg.kyushu-u.ac.jp \
    --cc=caml-list@inria.fr \
    /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).