From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 0BF2EBC57 for ; Mon, 29 Mar 2010 17:34:32 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.51,329,1267398000"; d="scan'208";a="47984184" Received: from macadam.inria.fr ([128.93.8.130]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA; 29 Mar 2010 17:34:32 +0200 Subject: Re: [Caml-list] no_scan_tag and int array Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Damien Doligez In-Reply-To: <20100306112645.a74bb0c4.ygrekheretix@gmail.com> Date: Mon, 29 Mar 2010 17:34:32 +0200 Cc: caml-list@inria.fr Content-Transfer-Encoding: quoted-printable Message-Id: <46634FDA-8BCD-4B1E-AD9C-819146A4BF56@inria.fr> References: <20100306112645.a74bb0c4.ygrekheretix@gmail.com> To: ygrek X-Mailer: Apple Mail (2.1077) X-Spam: no; 0.00; damien:01 damien:01 integers:01 arrays:01 ocaml:01 compiler:01 run-time:01 26,:98 polymorphic:01 doligez:01 doligez:01 wrote:01 abstract:01 abstract:01 caml-list:01 Hello, On 2010-03-06, at 10:26, ygrek wrote: > So, as expected, setting No_scan_tag on the array of integers prevents = GC from uselessly=20 > scanning the huge chunk of memory. Looks like polymorphic array = functions still work fine and > GC correctly reclaims array memory when it is not referenced anymore. > Apparantly this trick is not allowed for float array as they have a = special tag set. The trick is not needed for float arrays, the GC already doesn't scan them. > The question is - how safe is this? It's safe, and will be in the forseeable future. BUT: you should use Abstract_tag and not No_scan_tag. Abstract_tag = means "don't make assumptions about the contents of this block", while No_scan_tag is just the min of all the tags that the GC is not supposed to scan. Right now they are equal, but a future version of OCaml might have No_scan_tag =3D Double_array_tag, which would break your code. > And even more, could the compiler itself set this tag? This is a bit tricky because you have to make sure that the static type of the array is "int array". Unlike floats, a run-time test at allocation will not work. You should enter this as a feature wish in the BTS. -- Damien