English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: ocaml inlining
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1997-04-01 (10:47)
From: Xavier Leroy <xleroy@p...>
Subject: Re: ocaml inlining
>    Doing things in this fashion seems to prevent functions
> in the standard library from being inlined (other than with
> the default level).  It would seem that there could be many
> advantages to inlining functions such as List.iter.

As you found out yourself, List.iter is never inlined because it's

> Is there any way to get around this limitation without
> recompiling & reinstalling the standard library or compiling
> private versions of the standard library modules?

Given the current inlinng technology, I strongly doubt there is any
standard library function that could usefully be inlined and which is
not marked inlined at level 1 (the default inlining level). Actually,
level 1 inlining already does a number of useless inlinings.

> Unfortunately, no matter how large an inlining level was
> used, the map function would not be inlined.  When I looked
> at the compiler sources, I found that "let rec" expressions
> are never inlined.  Is there a reason for this?

It's much harder than inlining simple functions. Basically, a local
copy of the recursive function must be made, and then subject to
constant propagation and elimination of unused function arguments
(e.g. to get rid of the function parameter of List.iter). None of
these transformations, especially elimination of unused arguments, is
performed by the current compiler.

> With varying levels of inlining, I
> compiled, linked, and stripped all of Ensemble, and then
> printed the size of the resulting executable.

And what kind of speedups did you get in return? On my tests,
the default inlining level gives about 5% speedup for a 5% increase in
code size; higher levels increase code size, but have no noticeable
impact on speed.

- Xavier Leroy