Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: John Prevost <prevost@maya.com>
Cc: Edwin Young <edwiny@entropic.co.uk>,
	"'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: Re: 32 bit integers
Date: Fri, 22 Oct 1999 11:42:50 +0200	[thread overview]
Message-ID: <19991022114250.57637@pauillac.inria.fr> (raw)
In-Reply-To: <m33dv4tgc3.fsf@isil.maya.com>; from John Prevost on Thu, Oct 21, 1999 at 08:00:12PM -0400

> I found this implementation to be terribly slow (even slower than the
> bignum stuff in many cases.)  Any idea why this is?  Is it just
> because of the extra dereference, or is it because the compiler uses
> better code for "primitive" type operations like int addition than it
> does for other types?

Both, actually.  Boxing is always expensive, not so much because of
the extra dereference, but mostly because of the extra heap allocations.
(There are good reasons why the "int" type is tagged instead of boxed
in OCaml...)  On top of that, all operations on Int32.t are
implemented by C functions, and calling a C function from Caml is
expensive -- more expensive than calling a Caml function, and much
more expensive than open-coding the operations.

> (This second was my guess.)  Is there any way
> to make this kind of extension work better?

There is a way, but it involves modifying the compiler itself
to add special code generation rules for the primitive operations on
the new integer type.

- Xavier Leroy




  reply	other threads:[~1999-10-25 15:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-18 14:47 Edwin Young
1999-10-21 14:24 ` Xavier Leroy
1999-10-21 19:17   ` Scott Alexander
1999-10-22  0:00   ` John Prevost
1999-10-22  9:42     ` Xavier Leroy [this message]
1999-10-21 18:13 Manuel Fahndrich
1999-10-29 21:28 Juergen Pfitzenmaier

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=19991022114250.57637@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=edwiny@entropic.co.uk \
    --cc=prevost@maya.com \
    /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