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 IAA20814 for caml-redistribution; Mon, 22 Sep 1997 08:57:13 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA18225 for ; Thu, 18 Sep 1997 10:41:36 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.5) with ESMTP id KAA09982; Thu, 18 Sep 1997 10:41:34 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA18220; Thu, 18 Sep 1997 10:41:33 +0200 (MET DST) From: Xavier Leroy Message-Id: <199709180841.KAA18220@pauillac.inria.fr> Subject: Re: Preinitialized executables? In-Reply-To: <9709122357.AA05419@alfard.utu.fi> from Matti Jokinen at "Sep 13, 97 02:57:41 am" To: moj@alfard.utu.fi (Matti Jokinen) Date: Thu, 18 Sep 1997 10:41:33 +0200 (MET DST) Cc: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > I have a program that needs to be initialied by building a large and > fairly complicated data structure. In Ocaml the fastest method I > have found is to save the data structure in a file with output_value > and then load it into the program with input_value, but even this way > the overhead is considerable. SML/NJ has a function named exportFn, > which saves the program together with its state into an executable file: > when the program is run from the file, control is transferred to a > function given as a parameter to exportFn. I wonder if something > similar is possible in Ocaml. It might be possible, but it would not be any faster than input_value. The loading of a bytecode executable inside the bytecode interpreter is, for the most part, performed by input_value. Same thing for SML/NJ, I believe. As for ocamlopt, there is really no portable way to dump a running program with its current state in an executable file. Recent versions of SML/NJ have abandoned this approach and explicitly load the data from a file on startup, rather than let the kernel page them in on demand. If loading time is really an issue, an alternative would be to load parts of the data structure on demand, using e.g. the DBM library. Regards, - Xavier Leroy