Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Basile Starynkevitch [local]" <basile.starynkevitch@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Alternative Bytecodes for OCaml
Date: Sat, 28 Aug 2004 18:40:12 +0200	[thread overview]
Message-ID: <20040828164012.GA6420@bourg.inria.fr> (raw)
In-Reply-To: <20040828.083835.21913928.yoriyuki@mbg.ocn.ne.jp>

On Sat, Aug 28, 2004 at 08:38:35AM +0900, Yamagata Yoriyuki wrote:
> From: Richard Jones <rich@annexia.org>
> Subject: Re: [Caml-list] Alternative Bytecodes for OCaml
> Date: Fri, 27 Aug 2004 23:18:01 +0100
> 
> The doc is somewhat vague, but Parrot seems to use conservative
> mark&sweep GC.  http://www.parrotcode.org/docs/pdd/pdd09_gc.html
> 
> There are a lot of people in academia in this list.  Maybe
> OCaml->Parrot compiler is a good project for undergraduates?

Unfortunately, I am not sure it would be a good thing - and I think
that it is quite sad that Parrot designers did not consider more
cooperation (or feedback?) with the functional language communities.

I think that Ocaml programs

  use a lot of "tuples", as seen by the runtime system (ie a tagged
  block of value pointers) ; tuples are essential in Ocaml for tuples
  and recorda in the Ocaml source language.

  need to allocate tuples quickly (because functional programming style
  means lots of allocations of small immutable tuples), and to test
  quickly the tuples' tag, and to fetch quieckly the n-th component of a
  tuple (for implementation of pattern matching)

  need to have efficient closures - quickly allocated, and quickly
  applied (both thru ordinary and tail-recursive terminal calls).

Unfortunately, Parrot http://www.parrotcode.org/docs/intro.html
implement all structured objects as PMCs, which are opaque data chunks
on which all operations goes thru a table of functions (similar to C++
vtables). So, using PMCs for tuple implementations would require an
indirect call (even with Parrot JIT technology) for every basic tuple
operations (ie allocation, tag fetching, field fetching). Also, I am
not sure that Parrot has terminal (tail recursive) calls which are
essential to Ocaml (and other functional languages).

So, I would guess that a Parrot-based Ocaml implementation (even using
Parrot JIT technology) would probably be at least two times slower
than the current ocaml byterun implementation (hence about 4 times
slower than my OcamlJitRun implementation, at least on x86).

An alternative not yet considered in this interesting "bytecode"
related thread would be to *extend* a competitive VM (eg Parrot, or
maybe CLR or JVM) to add the few features needed to Ocaml, notably:
quick tuple allocation & access (both to fields and to tag), quick
closure allocation and application, tail-recursive calls.

Alos, note that Ocaml (and other functional languages) need a
performant garbage collector (because immutable tuples and closures
are allocated and accessed a lot), and that conservative GCs (à la
Boehm) have lots of interesting features (in particular,
conservativeness which makes then C-friendly, and multithreading), but
are slower than naive generational copying precise GC (see
http://starynkevitch.net/Basile/qishintro.html for some benches).


So, instead of porting Ocaml to Parrot, I would favor an extension of
Parrot (or any other competitive VM) - by adding the few needed
features suggested above) and then a port of the Ocaml compiler to
this extended VM. I do recognize that it is a big work, and that the
result might be disappointing (in terms of performance at least)
w.r.t. the current Ocaml bytecode VM.


Regards.


NB: in this post, all tuples are (unless explicitly said) in the
runtime sense of a tagged block of GC-ed pointers - not in the Ocaml
source sense. tuples (in the runtime sense) implements both Ocaml
tuples & records.

-- 
Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr
other email : basile at starynkevitch dot net
Project cristal.inria.fr - temporarily
http://cristal.inria.fr/~starynke --- all opinions are only mine 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2004-08-28 16:40 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-25 14:26 John Goerzen
2004-08-25 14:38 ` Richard Jones
2004-08-25 14:50   ` John Goerzen
2004-08-25 15:02     ` John Goerzen
2004-08-26  9:05       ` Raphael Montelatici
2004-08-26 13:20         ` John Goerzen
2004-08-26 13:30           ` John Goerzen
2004-08-25 14:55   ` Lars Nilsson
2004-08-25 15:06     ` Jason Smith
2004-08-25 16:14       ` John Goerzen
2004-08-28  3:49     ` John Goerzen
2004-08-25 15:05 ` skaller
2004-08-25 15:21   ` Lars Nilsson
2004-08-25 15:22   ` Jason Smith
2004-08-25 15:52     ` John Goerzen
2004-08-25 16:26       ` Jason Smith
2004-08-25 16:40         ` Jason Smith
2004-08-25 16:49       ` Ville-Pertti Keinonen
2004-08-25 17:01         ` Jason Smith
2004-08-25 17:17         ` John Goerzen
2004-08-25 20:00       ` skaller
2004-08-25 15:23   ` Brian Hurt
2004-08-25 15:24     ` Christophe TROESTLER
2004-08-27 14:26     ` Daniel Ortmann
2004-08-27 14:44       ` skaller
2004-08-27 14:59       ` Brian Hurt
2004-08-25 15:35   ` John Goerzen
2004-08-25 16:00   ` Richard Jones
2004-08-25 15:40 ` Nicolas Cannasse
2004-08-27 17:55   ` John Goerzen
2004-08-27 18:37     ` skaller
2004-08-27 18:49       ` John Goerzen
2004-08-27 20:39         ` skaller
2004-08-27 20:56           ` John Goerzen
2004-08-27 22:05             ` Richard Jones
2004-08-27 23:15               ` John Goerzen
2004-08-31 11:10                 ` Keith Wansbrough
2004-08-28  0:25             ` skaller
2004-08-28  9:35               ` Marcin 'Qrczak' Kowalczyk
2004-08-28  9:50                 ` Marcin 'Qrczak' Kowalczyk
2004-08-28 10:41                   ` skaller
2004-08-28 11:37                     ` Marcin 'Qrczak' Kowalczyk
2004-08-25 17:37 ` Basile Starynkevitch [local]
2004-08-25 18:00   ` Richard Jones
2004-08-25 22:10 ` Yamagata Yoriyuki
2004-08-26  0:09   ` John Goerzen
2004-08-26  4:26     ` [Caml-list] bytecode and native code at once Brandon J. Van Every
2004-08-26  9:55       ` skaller
2004-08-26 15:52         ` [Caml-list] " mikel
2004-08-26 17:09           ` Paul Snively
2004-08-26 17:31             ` mikel evins
2004-08-26 18:04               ` Paul Snively
2004-08-26 18:28                 ` mikel evins
2004-08-26 21:15             ` skaller
2004-08-27  8:52           ` Keith Wansbrough
2004-08-27 15:39             ` David Brown
2004-08-27 15:48               ` mikel evins
2004-08-26 21:42     ` [Caml-list] Alternative Bytecodes for OCaml Michal Moskal
2004-08-27  9:38       ` Nicolas Cannasse
2004-08-27 13:09         ` John Goerzen
2004-08-27 13:44           ` Brian Hurt
2004-08-27 13:58           ` skaller
2004-08-27 20:48           ` Nicolas Cannasse
2004-08-27 21:03             ` Benjamin Geer
2004-08-30 16:40             ` John Goerzen
2004-08-27 19:49         ` Blair Zajac
2004-08-27 22:18           ` Richard Jones
2004-08-27 23:38             ` Yamagata Yoriyuki
2004-08-28 16:40               ` Basile Starynkevitch [local] [this message]
2004-08-28 17:03                 ` [Caml-list] (GC issues) " Nicolas Cannasse
2004-08-28 20:45                   ` [Caml-list] " Basile Starynkevitch [local]
2004-08-29  2:31                     ` skaller
2004-08-29  5:04                       ` Brandon J. Van Every
2004-08-29 12:58                         ` John Goerzen
2004-08-29 15:06                           ` Brian Hurt
2004-08-29 15:22                             ` Radu-Mihail Obada
2004-08-29 10:12                     ` Nicolas Cannasse
2004-08-30 12:23                       ` Basile Starynkevitch [local]
2004-08-30 13:17                         ` Nicolas Cannasse
2004-08-26 16:04 ` [Caml-list] " =?unknown-8bit?Q?=A3ukasz?= Dobrek

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=20040828164012.GA6420@bourg.inria.fr \
    --to=basile.starynkevitch@inria.fr \
    --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