From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] More efficient implementation of intersection of sets?
Date: Wed, 2 Apr 2008 00:42:01 +0100 [thread overview]
Message-ID: <200804020042.02016.jon@ffconsultancy.com> (raw)
In-Reply-To: <20080401155524.F1CE08B34A@xprdmxin.myway.com>
On Tuesday 01 April 2008 16:55:24 sasha mal wrote:
> Dear OCaml users!
>
> Currently,
>
> Set.inter x y
>
> splits y into two trees, one containing elements that are bigger and the
> other containing elements that are smaller than the top of x, then applies
> the procedure recursively. What is the exact runtime of the algorithm?
We discussed this before on this list and the result was inconclusive. Suffice
to say, it is very fast!
> Is there a better one for the intersection for OCaml sets?
Not likely. OCaml's implementation is already vastly more efficient than any
other language I have ever seen (e.g. C++). Your next best bet is probably to
parallelize the algorithm to improve the performance but that is extremely
difficult to do without a concurrent GC. Frederic Gava did some work on this
in OCaml. I am working on the same problem in F#.
Failing that, you might want to apply some of the stock optimizations to the
Set module, such as a Node1 type constructor for nodes with a value but no
child nodes. That can improve performance by 30%.
Alternatively, you may prefer to ditch immutable structures and opt for a
hashset, which can be many times faster but is much more difficult to use
because it is mutable.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e
next prev parent reply other threads:[~2008-04-01 23:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-01 15:55 sasha mal
2008-04-01 23:42 ` Jon Harrop [this message]
2008-04-02 14:05 ` [Caml-list] " Frédéric Gava
2008-04-02 15:34 ` Mike Furr
2008-04-02 13:30 sasha mal
2008-04-02 14:01 sasha mal
2008-04-04 17:27 ` 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=200804020042.02016.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.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