caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] variable sharing
@ 2011-03-07  1:49 Kihong Heo
  2011-03-07  2:07 ` Yitzhak Mandelbaum
  0 siblings, 1 reply; 6+ messages in thread
From: Kihong Heo @ 2011-03-07  1:49 UTC (permalink / raw)
  To: caml-list

Dear caml-list.

I want to know how ocaml compiler make variable sharing.
I believe the compiler do good job, but sometime memory consumption
of my program does not make sense. 
So I am curious about what the compiler did or how to make program memory efficiently.

If you know some good notes or web pages for that issue, please let me know.

Thank you.

- Kihong Heo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] variable sharing
  2011-03-07  1:49 [Caml-list] variable sharing Kihong Heo
@ 2011-03-07  2:07 ` Yitzhak Mandelbaum
  2011-03-07  2:24   ` Kihong Heo
       [not found]   ` <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>
  0 siblings, 2 replies; 6+ messages in thread
From: Yitzhak Mandelbaum @ 2011-03-07  2:07 UTC (permalink / raw)
  To: Kihong Heo; +Cc: caml-list

Kihong,

Could you elaborate on what you mean by "variable sharing" and what specifically is not happening as expected? Perhaps you could provide a small example that demonstrates the problem you're seeing?

Cheers,
Yitzhak


On Mar 6, 2011, at 8:49 PM, Kihong Heo wrote:

> Dear caml-list.
> 
> I want to know how ocaml compiler make variable sharing.
> I believe the compiler do good job, but sometime memory consumption
> of my program does not make sense. 
> So I am curious about what the compiler did or how to make program memory efficiently.
> 
> If you know some good notes or web pages for that issue, please let me know.
> 
> Thank you.
> 
> - Kihong Heo
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 

-----------------------------
Yitzhak Mandelbaum





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] variable sharing
  2011-03-07  2:07 ` Yitzhak Mandelbaum
@ 2011-03-07  2:24   ` Kihong Heo
  2011-03-07 10:19     ` Daniel Bünzli
  2011-03-07 10:39     ` Julien Signoles
       [not found]   ` <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>
  1 sibling, 2 replies; 6+ messages in thread
From: Kihong Heo @ 2011-03-07  2:24 UTC (permalink / raw)
  To: Yitzhak Mandelbaum; +Cc: caml-list

Sorry. It's my mistake. 
not variable sharing, but "value sharing" which means alias.

For example, there is a big set and I want to make many subset of it.
In my thought, if the aliases are made efficiently, the memory explosion does not make sense.
I don't know exactly what's the problem (my programming style, data type, or it is a natural result, etc..).
So I want to know the principle.

Thank you.
Kihong

2011. 3. 7., 오전 11:07, Yitzhak Mandelbaum 작성:

> Kihong,
> 
> Could you elaborate on what you mean by "variable sharing" and what specifically is not happening as expected? Perhaps you could provide a small example that demonstrates the problem you're seeing?
> 
> Cheers,
> Yitzhak
> 
> 
> On Mar 6, 2011, at 8:49 PM, Kihong Heo wrote:
> 
>> Dear caml-list.
>> 
>> I want to know how ocaml compiler make variable sharing.
>> I believe the compiler do good job, but sometime memory consumption
>> of my program does not make sense. 
>> So I am curious about what the compiler did or how to make program memory efficiently.
>> 
>> If you know some good notes or web pages for that issue, please let me know.
>> 
>> Thank you.
>> 
>> - Kihong Heo
>> 
>> -- 
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa-roc.inria.fr/wws/info/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>> 
> 
> -----------------------------
> Yitzhak Mandelbaum
> 
> 
> 

--
허 기 홍 드림
khheo@ropas.snu.ac.kr
서울대학교 프로그래밍 연구실



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] variable sharing
  2011-03-07  2:24   ` Kihong Heo
@ 2011-03-07 10:19     ` Daniel Bünzli
  2011-03-07 10:39     ` Julien Signoles
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Bünzli @ 2011-03-07 10:19 UTC (permalink / raw)
  To: Kihong Heo; +Cc: caml-list

Value sharing will not depend on the compiler but on your programing
style (and the style of the libraries you use).

When you code you should always ask yourself whether you are recycling
the values you manipulate or whether you are doing new copies of the
same data.

You may also be interested in implementing hash consing [1] for your
data structures.

Best,

Daniel

[1] http://www.lri.fr/~filliatr/ftp/publis/hash-consing.ps.gz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] variable sharing
       [not found]   ` <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>
@ 2011-03-07 10:24     ` Fabrice Le Fessant
  0 siblings, 0 replies; 6+ messages in thread
From: Fabrice Le Fessant @ 2011-03-07 10:24 UTC (permalink / raw)
  To: caml-list

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

let a = ...
let b = Some a
let c = b (* b and c share the same value *)
let d = Some a (* d = b,  but d != b, i.e. b and d don't share the same
value in memory *)

If you want b and d to share the same value, you have to use some kind
of h-consing, but the runtime won't do it for you by default.

--Fabrice
INRIA -- OCamlPro

On 03/07/2011 03:25 AM, Kihong Heo wrote:
> Sorry. It's my mistake. 
> not variable sharing, but "value sharing" which means alias.
> 
> For example, there is a big set and I want to make many subset of it.
> In my thought, if the aliases are made efficiently, the memory explosion does not make sense.
> I don't know exactly what's the problem (my programming style, data type, or it is a natural result, etc..).
> So I want to know the principle.
> 
> Thank you.
> Kihong
> 
> 2011. 3. 7., 오전 11:07, Yitzhak Mandelbaum 작성:
> 
>> Kihong,
>>
>> Could you elaborate on what you mean by "variable sharing" and what specifically is not happening as expected? Perhaps you could provide a small example that demonstrates the problem you're seeing?
>>
>> Cheers,
>> Yitzhak
>>
>>
>> On Mar 6, 2011, at 8:49 PM, Kihong Heo wrote:
>>
>>> Dear caml-list.
>>>
>>> I want to know how ocaml compiler make variable sharing.
>>> I believe the compiler do good job, but sometime memory consumption
>>> of my program does not make sense. 
>>> So I am curious about what the compiler did or how to make program memory efficiently.
>>>
>>> If you know some good notes or web pages for that issue, please let me know.
>>>
>>> Thank you.
>>>
>>> - Kihong Heo
>>>
>>> -- 
>>> Caml-list mailing list.  Subscription management and archives:
>>> https://sympa-roc.inria.fr/wws/info/caml-list
>>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>>
>>
>> -----------------------------
>> Yitzhak Mandelbaum
>>
>>
>>
> 
> --
> 허 기 홍 드림
> khheo@ropas.snu.ac.kr
> 서울대학교 프로그래밍 연구실
> 
> 
> 

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 397 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;Projet OCamlPro
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] variable sharing
  2011-03-07  2:24   ` Kihong Heo
  2011-03-07 10:19     ` Daniel Bünzli
@ 2011-03-07 10:39     ` Julien Signoles
  1 sibling, 0 replies; 6+ messages in thread
From: Julien Signoles @ 2011-03-07 10:39 UTC (permalink / raw)
  To: Kihong Heo; +Cc: Yitzhak Mandelbaum, caml-list

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

Hello,

2011/3/7 Kihong Heo <khheo@ropas.snu.ac.kr>

> Sorry. It's my mistake.
> not variable sharing, but "value sharing" which means alias.
>
> For example, there is a big set and I want to make many subset of it.
> In my thought, if the aliases are made efficiently, the memory explosion
> does not make sense.
> I don't know exactly what's the problem (my programming style, data type,
> or it is a natural result, etc..).
> So I want to know the principle.
>

As Daniel and Fabrice said, I guess you need hash-consing. You may use the
Filliâtre's Hashcons/Hset/Hmap modules (
http://www.lri.fr/~filliatr/software.en.html) described in [1]. If you want
to know details about interaction between hashconsing and ocaml (especially
its GC), [2] may be of some interest to you.

[1] Sylvain Conchon and Jean-Christophe Filliâtre. Type-Safe Modular
Hash-Consing. ML Workshop'06.
[2] Pascal Cuoq and Damien Doligez, Hashconsing in an incrementally
garbage-collected system: a story of weak pointers and hashconsing in ocaml
3.10.2. ML Workshop'08.

Hope this helps,
Julien



> 2011. 3. 7., 오전 11:07, Yitzhak Mandelbaum 작성:
>
> > Kihong,
> >
> > Could you elaborate on what you mean by "variable sharing" and what
> specifically is not happening as expected? Perhaps you could provide a small
> example that demonstrates the problem you're seeing?
> >
> > Cheers,
> > Yitzhak
> >
> >
> > On Mar 6, 2011, at 8:49 PM, Kihong Heo wrote:
> >
> >> Dear caml-list.
> >>
> >> I want to know how ocaml compiler make variable sharing.
> >> I believe the compiler do good job, but sometime memory consumption
> >> of my program does not make sense.
> >> So I am curious about what the compiler did or how to make program
> memory efficiently.
> >>
> >> If you know some good notes or web pages for that issue, please let me
> know.
> >>
> >> Thank you.
> >>
> >> - Kihong Heo
> >>
> >> --
> >> Caml-list mailing list.  Subscription management and archives:
> >> https://sympa-roc.inria.fr/wws/info/caml-list
> >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> >> Bug reports: http://caml.inria.fr/bin/caml-bugs
> >>
> >
> > -----------------------------
> > Yitzhak Mandelbaum
> >
> >
> >
>
> --
> 허 기 홍 드림
> khheo@ropas.snu.ac.kr
> 서울대학교 프로그래밍 연구실
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

[-- Attachment #2: Type: text/html, Size: 3990 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-07 10:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-07  1:49 [Caml-list] variable sharing Kihong Heo
2011-03-07  2:07 ` Yitzhak Mandelbaum
2011-03-07  2:24   ` Kihong Heo
2011-03-07 10:19     ` Daniel Bünzli
2011-03-07 10:39     ` Julien Signoles
     [not found]   ` <1856328280.452099.1299464703924.JavaMail.root@zmbs4.inria.fr>
2011-03-07 10:24     ` Fabrice Le Fessant

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).