caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Leonardo Laguna Ruiz <modlfo@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Performance degradation when using '=' instead of 'compare'
Date: Fri, 28 Apr 2017 16:36:19 +0200	[thread overview]
Message-ID: <00fad276-cfec-0aca-9718-ae00a38f2437@gmail.com> (raw)

I don't know if this has been discussed before, but a few weeks back we 
detected a large performance degradation in our product. We tracked down 
the problem and turned out to be that an innocent looking line was 
changed. Something like this:

if compare a b = 0 then  .... else ...

became:

if a = b then ... else ...

in our specific algorithm, 'a' and 'b' where values of some custom type. 
By looking at the ocaml runtime code we could see that 'compare' 
performs physical equality before doing the structural comparison.  
While '=' only performs structural equality.  In our case, 'a' and 'b' 
were most of the times physically equal, and by changing to the operator 
'=' a full structural comparison of the object was performed.

I wonder what's the reason why '=' does not uses physical equality. Now 
we are trying to track all the places where '=' is used and changing it 
to either:  "a == b | a=b", or "compare a b = 0"

Leonardo





             reply	other threads:[~2017-04-28 14:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 14:36 Leonardo Laguna Ruiz [this message]
2017-04-28 15:21 ` octachron

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=00fad276-cfec-0aca-9718-ae00a38f2437@gmail.com \
    --to=modlfo@gmail.com \
    --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).