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 RAA00788; Thu, 12 Aug 2004 17:22:39 +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 RAA01151 for ; Thu, 12 Aug 2004 17:22:38 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7CFMamL021333 for ; Thu, 12 Aug 2004 17:22:37 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i7CFMVJ24210; Thu, 12 Aug 2004 10:22:31 -0500 (CDT) Date: Thu, 12 Aug 2004 10:30:18 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: "Bauer, Christoph" cc: caml-list@inria.fr Subject: Re: [Caml-list] The tag bit In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 411B8B3C.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 bauer:01 caml-list:01 floats:01 unboxed:01 vaguely:01 slows:01 slows:01 ocaml:01 ocaml:01 garbage:01 garbage:01 int:01 int:01 arithmetic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 12 Aug 2004, Bauer, Christoph wrote: > Hello Caml-list, > > why is the tag bit for a int/pointer is stored in and not next to a > int/pointer. Isn't it possible to divide the memory in blocks of 33 (65 > on 64 bit machines) Words and the first Word contains all the tag bits? > Then we can enjoy an extra bit, some arithmetic operations could be done > faster and all floats could be unboxed. > > Of couse this is just a naive idea, but please tell me why ;-) My understanding: 1) The "extra overhead" of the tag bit is less than you might think in most code. Yeah, you have to do an instruction or two to adjust for the tag bit in some cases- but Ocaml is pretty good at omitting them when they're not needed (when a variable is stored in a register, for example). And the cost of these extra instructions is not great- especially compared to other costs you might hit without knowing it. They cost one, maybe two, clock cycles (assuming they aren't executed in parallel with other stuff, in which case they cost less than one clock cycle). A mispredicted branch costs 12-30 clock cycles. An L2 cache *hit* costs 20-30 clock cycles, and a cache *miss* that has to go to main memory 100-300 clock cycles. You can no longer even vaguely predict performance by counting instructions with modern CPUs. 2) Moving the tag bit out of the word slows down the garbage collector, according to experiments the maintainers did. It slows down the garbage collector by more than omitting the tag bit handling instructions speeds up the rest of the code. 3) Moving the tag bit out of word complicates handling variables of unknown type. Currently, Ocaml can just move whole words, and be sure the type information (int vr.s pointer) the GC needs moves with the word. With the tag bits stored elsewhere, moving a value of unknown type becomes a lot more complicated, as you have to move the tag bits seperately. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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