From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA28696; Sat, 11 Sep 2004 16:40:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 QAA29487 for ; Sat, 11 Sep 2004 16:40:27 +0200 (MET DST) Received: from ptb-relay01.plus.net (ptb-relay01.plus.net [212.159.14.212]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8BEeQY8030165 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 11 Sep 2004 16:40:27 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay01.plus.net with esmtp (Exim) id 1C6939-000Jto-W6 for caml-list@inria.fr; Sat, 11 Sep 2004 14:40:24 +0000 From: Jon Harrop To: caml users Subject: Re: [Caml-list] Gripes with array Date: Sat, 11 Sep 2004 15:36:10 +0100 User-Agent: KMail/1.6.2 References: <200409090310.29295.jon@jdh30.plus.com> <200409091758.05679.jon@jdh30.plus.com> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200409111536.10902.jon@jdh30.plus.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41430E5A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 damien:01 2004:99 raffalli:01 runtime:01 extensible:01 damien:01 initialising:01 inlining:01 43%:99 inlining:01 ocamlopt:01 arbitrarily:01 arrays:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday 10 September 2004 14:45, Damien Doligez wrote: > Not without implementing such horrors as Christophe described. I don't > much > like the idea of introducing lots of bugs while slowing down the whole > GC, > even for programs that don't use arrays. Yes indeed. I like Christophe's last idea though: On Friday 10 September 2004 06:56, Christophe Raffalli wrote: > You could also lie in the tag about the size of array (if the way the > runtime finds free block of memory does not use it). It will cost an > increment of integer at each step in the initialisation process which > should not be much since the beginning of array may stay in the cache if > the initialisation function is simple and this will be neggligeable if not. What is the trickiest/most-error-prone part of doing this and could this be used to implement amortised extensible arrays within the compiler? I would like to see such a thing in the compiler (not that I distrust Markus ;-). On Friday 10 September 2004 14:45, Damien Doligez wrote: > An intermediate solution would > be to make a "Array.unsafe_make" primitive, which would use memset > instead > of initialising the array properly. If you enter this as a feature wish > in the BTS, I'll look into it. No, I don't think the performance improvement would justify your time or the loss of safety. Could you add a memset to String.create though? :-) > That would confirm my intuition that the calls to f dominates the > initialisation time. In the case of Array.init, yes. From my array_init, inlining and type-specialisation decrease the time taken by ~43% and, hence, these would be the most productive optimisations. An array_init2 function which specialises the array type but uses an external "f" function betters the time taken by Array.init by ~36% (perhaps not significantly different): let array_init2 l f = if l = 0 then [||] else let x : int = f 0 in let res = Array.make l x in for i = 1 to pred l do Array.unsafe_set res i (f i) done; res I'm not sure what the impact of the type-specialisation on inlining is though. I'd imagine that doing such partial specialisations in ocamlopt is arbitrarily dodgy because you don't get any feedback on the benfits of your results. Perhaps this is a challenge for Basile's JIT? :-) Cheers, Jon. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners