Re: ocaml inlining

From: Xavier Leroy (xleroy@pauillac.inria.fr)
Date: Tue Apr 01 1997 - 11:23:05 MET DST


From: Xavier Leroy <xleroy@pauillac.inria.fr>
Message-Id: <199704010923.LAA03776@pauillac.inria.fr>
Subject: Re: ocaml inlining
In-Reply-To: <199703272021.PAA01643@gulag.cs.cornell.edu> from Mark Hayden at "Mar 27, 97 03:21:34 pm"
To: hayden@cs.cornell.edu (Mark Hayden)
Date: Tue, 1 Apr 1997 11:23:05 +0200 (MET DST)

> 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
recursive.

> 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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:10 MET