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 HAA21990; Wed, 4 Aug 2004 07:05:57 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA23584 for ; Wed, 4 Aug 2004 07:05:56 +0200 (MET DST) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.205]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7455smL023065 for ; Wed, 4 Aug 2004 07:05:55 +0200 Received: by mproxy.gmail.com with SMTP id 73so183708rnk for ; Tue, 03 Aug 2004 22:05:54 -0700 (PDT) Received: by 10.38.206.27 with SMTP id d27mr212577rng; Tue, 03 Aug 2004 22:05:54 -0700 (PDT) Message-ID: Date: Wed, 4 Aug 2004 01:05:54 -0400 From: John Prevost To: caml-list@inria.fr Subject: Re: [Caml-list] c is 4 times faster than ocaml? Cc: caml-list@inria.f In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <36002.60.246.254.84.1091587147.squirrel@www.ivorykite.com> X-Miltered: at nez-perce with ID 41106EB2.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; prevost:01 prevost:01 caml-list:01 gcc:01 coder:01 incrementing:01 ocaml:01 arithmetic:01 arithmetic:01 linking:02 o'caml:02 address:96 address:96 pointer:03 pointer:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Oh, one last parting thought: Part of why gcc is winning here is that it's actively working with the fact that the loop variable, the index, and the value to be inserted are the same value. O'Caml is doing extra work because it's not linking them up (it could at the very least avoid shifting a few registers around and avoid an extra sarl instruction if it did spot that.) But this is the trouble with artificial benchmarks: no real code is simply going to be copying the loop value into the array. It's going to be fetching the value from somewhere else, probably by doing pointer arithmetic on the loop value and the source address, then it will do pointer arithmetic on the loop value and the destination address. Then it will set the result. A smart C coder will do the arithmetic ahead of time, which means incrementing two values instead of one each time through the loop, but wins overall. Anyway, the short is: artificial benchmarks are bad. ------------------- 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