caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
To: Christophe Raffalli <Christophe.Raffalli@univ-savoie.fr>
Cc: Jon Harrop <jon@jdh30.plus.com>, caml users <caml-list@inria.fr>,
	Damien Doligez <damien.doligez@inria.fr>
Subject: Re: Array.init (was [Caml-list] Gripes with array)
Date: Mon, 13 Sep 2004 09:02:20 +0200	[thread overview]
Message-ID: <414545FC.3090009@univ-savoie.fr> (raw)
In-Reply-To: <41414200.40509@univ-savoie.fr>

[-- Attachment #1: Type: text/plain, Size: 2454 bytes --]

Christophe Raffalli wrote:
> 
>>
>>>> Also, can Array.init be made to fill the elements only once?
>>>
>>>
>>> No, that's impossible without breaking the GC invariants.
>>
>>
> 
> This is not true if the runtime maintains a list of array in 
> construction with the current position of the index. This list will stay
> rather small, but each addresse read by the GC will have to be checked 
> for membership in the list. If the list is rather small it will be in 
> the cache, but still I am afraid it will slow down noticably the GC.
> 
> Did someone tried to implement such a list of partially initialized 
> objects in the GC ? (I do not think it is worth it ?)

> 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.
> 
> 
This second solution is only for non copying GC, so not for OCaml

And yet another solution would have to have a tag with the total size + 
the number of non pointers at the end of the block. This would be 
usefull not only for Arrays. It just makes again a (too) strong limit on 
the size of arrays.

I am now wondering why the structure of a block does not allow a second 
tag word (and even a third tag word) for the tag in case of big objects 
? A cons cell keeps a tag of only one word (that's still too much :-), 
but an array (or even only an array of size > 2^n) uses a bigger tag. 
Moreover this extra tag word could be at address (p-1) if p is the 
address of the object so that some code like unsafe.get do not need to 
access it.

The Gc and few other function like Array.length, Array.get in the bound 
check,.. would have an extra test to do, but the GC would have less 
memory to scan (because it would have to scan not all word in a block).


-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature
---------------------------------------------

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

  parent reply	other threads:[~2004-09-13  7:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-09  2:10 [Caml-list] Gripes with array Jon Harrop
2004-09-09  5:08 ` Ville-Pertti Keinonen
2004-09-09  7:17 ` Jean-Christophe Filliatre
2004-09-09  8:23   ` Richard Jones
2004-09-09  9:08     ` Olivier Andrieu
2004-09-09 12:08       ` Basile Starynkevitch [local]
2004-09-09 12:31         ` Damien Doligez
2004-09-09 10:42     ` Gerd Stolpmann
2004-09-09  9:37 ` Damien Doligez
2004-09-09 10:34   ` Jean-Christophe Filliatre
2004-09-09 12:15     ` Igor Pechtchanski
2004-09-09 13:01   ` Brian Hurt
2004-09-09 20:08     ` [Caml-list] 32-bit is sticking around Brandon J. Van Every
2004-09-09 21:04       ` Jon Harrop
2004-09-11 15:30         ` Lars Nilsson
2004-09-11 16:24           ` [off topic] " David MENTRE
2004-09-11 17:52             ` Lars Nilsson
     [not found]           ` <200409111656.11952.jon@jdh30.plus.com>
2004-09-11 17:47             ` Lars Nilsson
2004-09-09 16:58   ` [Caml-list] Gripes with array Jon Harrop
2004-09-10  5:56     ` Array.init (was [Caml-list] Gripes with array) Christophe Raffalli
2004-09-10  8:53       ` Richard Jones
2004-09-10 14:50         ` Damien Doligez
2004-09-13  7:02       ` Christophe Raffalli [this message]
2004-09-10 13:45     ` [Caml-list] Gripes with array Damien Doligez
2004-09-11  1:43       ` skaller
2004-09-11  3:16         ` skaller
2004-09-11 14:36       ` Jon Harrop
2004-09-11 20:53         ` Damien Doligez
2004-09-12 15:33           ` Jon Harrop
2004-09-12 16:07             ` Basile Starynkevitch [local]
2004-09-10 23:48 ` brogoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=414545FC.3090009@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    --cc=damien.doligez@inria.fr \
    --cc=jon@jdh30.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).