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 UAA27789; Mon, 8 Dec 2003 20:02:34 +0100 (MET) 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 UAA27943 for ; Mon, 8 Dec 2003 20:02:32 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hB8J2T114634; Mon, 8 Dec 2003 20:02:29 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA27410; Mon, 8 Dec 2003 20:02:28 +0100 (MET) Date: Mon, 8 Dec 2003 20:02:28 +0100 From: Xavier Leroy To: Brian Hurt Cc: caml-list@inria.fr Subject: Re: [Caml-list] Object-oriented access bottleneck Message-ID: <20031208200228.A26466@pauillac.inria.fr> References: <20031208100725E.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from bhurt@spnz.org on Mon, Dec 08, 2003 at 11:51:35AM -0600 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 bottleneck:01 slower:01 slower:01 statically:01 run-time:01 powerpc:01 603:99 inlined:01 invocation:01 invocation:01 source-level:01 clarifies:01 computed:01 address:96 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > How much slower is a member function call compared to a non-member > function call? I was given the impression that it was signifigantly > slower, but you're making it sound like it isn't. In the non-member case, it depends very much whether the function being called is statically known or is computed at run-time. In the first case, a call to a static address is generated. In the latter case, a call to a function pointer is generated. Here are some figures I collected circa 1998 on a PowerPC 603 processor: type of call cost of call inlined function 0 cycles call to known function 4 cycles call to unknown function 11 cycles method invocation 18 cycles I'm pretty sure that more modern processors have a bigger gap between the "call to known function" and "call to unknown function" cases. So, as you can see, method invocation isn't much more expensive than a call to an unknown function, but is significantly more expensive than a call to a known function. In source-level terms, replacing an object by a record of functions isn't going to make a major performance difference (the applications of the functions fetched from the record fall in the "call to unknown function" case), while getting rid of dynamic dispatch entirely and just call known functions is a much bigger improvement. Hope this clarifies the issue. - Xavier Leroy ------------------- 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