From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA06480 for caml-redistribution; Tue, 1 Apr 1997 12:47:42 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA03776; Tue, 1 Apr 1997 11:23:05 +0200 (MET DST) From: Xavier Leroy 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) Cc: caml-list@pauillac.inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > 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