caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
To: Nicolas Cannasse <ncannasse@motion-twin.com>
Cc: Christophe Raffalli <raffalli@univ-savoie.fr>,
	Brian Hurt <bhurt@spnz.org>,
	caml-list@inria.fr
Subject: Re: [Caml-list] Obj or not Obj
Date: Mon, 28 Nov 2005 10:27:18 +0100	[thread overview]
Message-ID: <438ACD76.5060200@univ-savoie.fr> (raw)
In-Reply-To: <438AC2AE.3040200@motion-twin.com>

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

Nicolas Cannasse a écrit :
>> Just a small word about one of my bad experiment with Obj about tail rec
>> map ... it is easy to get a tail
>> rec map using Obj to make ocaml's list mutable ... it is just slower
>> that the original map and using roughly the same
>> amount of memory, because every cons cell  you gain ... is now in the
>> list of grey val as soon as your list does not
>> fit in the minor heap anymore !! So even writing you own mutable_list
>> type would be as bad !
>>
>> Explanation: the list of grey val is a list of pointers from the major
>> heap to the minor heap which
>> are created when using mutable data structure and which would break
>> incremental GC if each minor GC did not scan
>> the list of grey val) ...
> 
> This is not correct.
> When you're building a mutable list you're allocating first in the minor
> heap, then all cons go into the major heap at once, so only the "last"
> cons before a GC cycle is greyed. It is indeed true that for short
> lists, using the stack is better than using mutable structures.
> 
> But using the stack is getting speed against correctness, since it will
> overflow for big lists.
> 

I did timing for big lists with mutation using object and rev +  rev_map
and the later was faster ...

If the list is big, and there is allocating computation for the car of
each list in map, then I think a lot of cons cells can be greyed once
... even all if each computation in the car triggers at least one minor
collection ... but then the complexity of map does not matter ... so my
explanation for the observed timing was wrong ...

may be this is just the test to know if one have to grey the cons-cell
that's costly ?

any way I now think rev + rev_map is better than dirty Obj for that pb.

remark: I only tested on my athlon 32 ...



> Nicolas


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

  reply	other threads:[~2005-11-28  9:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-25 23:53 Efficency of varient types Michael D. Adams
2005-11-26  0:31 ` [Caml-list] " Nicolas Cannasse
2005-11-26  1:22   ` Brian Hurt
2005-11-26  9:39     ` Nicolas Cannasse
2005-11-28  0:17     ` Obj or not Obj Christophe Raffalli
2005-11-28  8:41       ` [Caml-list] " Nicolas Cannasse
2005-11-28  9:27         ` Christophe Raffalli [this message]
2005-11-28  9:33         ` skaller
2005-11-28  8:43       ` Alain Frisch
2005-11-26  2:54   ` [Caml-list] Efficency of varient types skaller
2005-11-27  5:06   ` Michael D. Adams
2005-11-27  5:45     ` Brian Hurt
2005-11-27 10:02       ` Nicolas Cannasse
2005-11-27 15:35       ` Michael D. Adams
2005-11-27 18:08         ` Brian Hurt
2005-12-02 15:07           ` Michael D. Adams
2005-11-26  1:18 ` Jon Harrop
2005-11-27 14:57 ` Lukasz Stafiniak
2005-11-27 15:47   ` Lukasz Stafiniak
2005-11-28  8:14   ` Christophe Raffalli
2005-11-28  7:24 ` David Baelde
2005-11-28  7:49   ` Jacques Garrigue
2005-11-28 10:01     ` Jon Harrop
2005-11-28 10:26       ` Luc Maranget
2005-11-28  7:53   ` Ville-Pertti Keinonen
2005-12-01 17:05 ` Stefan Monnier
2005-12-02 15:07   ` [Caml-list] " Michael D. Adams

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=438ACD76.5060200@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=ncannasse@motion-twin.com \
    --cc=raffalli@univ-savoie.fr \
    /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).