caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Odd performance result with HLVM
Date: Sat, 28 Feb 2009 21:52:18 +0000	[thread overview]
Message-ID: <200902282152.18430.jon@ffconsultancy.com> (raw)
In-Reply-To: <C61E9F1C-36D0-4429-BDFB-6F36A3F67AA5@osu.edu>

On Saturday 28 February 2009 20:18:40 Kuba Ober wrote:
> You didn't let us in on how it really works. You said "high-level
> virtual machine
> built upon LLVM and written in OCaml". LLVM means too many things to be
> able to decipher what you mean, and your statement is too general.

I'm referring to my HLVM project that I described here:

http://flyingfrogblog.blogspot.com/2008/12/building-better-future-high-level.html

That is built upon the Low-Level Virtual Machine here:

http://llvm.org

Basically, my idea is to build a better VM for OCaml-like languages. My work 
is still at a very early stage of development but the results are already 
promising: faster than ocamlopt on all of my benchmarks and several times 
faster on some numerical benchmarks.

There are really two major advantages over the current ocamlopt design and 
both stem from the use of JIT compilation:

. Run-time types allow per-type functions like generic pretty printers and 
comparison.

. Monomorphisation during JIT compilation completely removes the performance 
cost of polymorphism, e.g. floats, tuples and records are never boxed.

Algebraic datatypes were the latest addition and I expected them to be very 
slow because I am calling thread-safe malloc every time one is created. 
However, a simple benchmark that creates and folds over a huge list actually 
runs faster on my HLVM than it does in OCaml.

> I'm assuming, but that's forced, so don't shoot if I make an asinus
> out of myself ;)
>
> So, it's a VM and it runs native jit-ted code like say .net would. So
> presumably you
> have some OCaml code that then invokes jit and some native functions
> to dispatch
> to jit-ted code?

Yes.

> Do you interpret any bytecode, or always compile?

Always compile.

> Do  
> you even
> have to have any OCaml code running in the process where the jit-ted
> code runs in?

I believe the OCaml bindings to LLVM JIT compile a function, get a pointer to 
it and call into that function from the current thread. So there is no 
process separation.

> I presume you use the LLVM infrastructure to do the jit-ting, but
> without knowing
> exactly what code runs in the process space of the application, it's
> hard to tell
> what's going on.

You just gave me another idea: use LLVM to compile the same IR code to a 
standalone executable and benchmark that. I'll get back to you...

> There's no floating point state to change that would slow things up
> that much.
> At least I have never seen anything like that.

That's what I thought.

> Maybe the FP exceptions are being fired somehow?

Maybe something like that. I have no idea.

This definitely only affects float performance so it is not a difference in 
the efficiency of calling into JIT compiled code from OCaml bytecode or 
native code.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


  parent reply	other threads:[~2009-02-28 21:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-28  1:12 Jon Harrop
2009-02-28 20:18 ` [Caml-list] " Kuba Ober
2009-02-28 21:21   ` Richard Jones
2009-02-28 21:59     ` Jon Harrop
2009-03-02  0:38       ` Jon Harrop
2009-02-28 21:52   ` Jon Harrop [this message]
2009-03-02  3:20     ` Jon Harrop
2009-03-02 14:28     ` Florent Ouchet
2009-03-02 16:18       ` Jon Harrop
2009-03-02 20:09       ` Kuba Ober
2009-03-04 16:17         ` Mikkel Fahnøe Jørgensen
2009-03-04 16:30           ` Kuba Ober
2009-03-04 18:15             ` Mikkel Fahnøe Jørgensen
2009-03-04 18:32               ` Jon Harrop
2009-03-04 19:05           ` Jon Harrop

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=200902282152.18430.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;
as well as URLs for NNTP newsgroup(s).