|
List Info
Thread: "ocaml_beginners"::[] About weak things...
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-09 16:55:36 |
vincent.aravantinos wrote:
> What I have understood is that a weak value may be
collected at any
> time, ok ?
Any time it is not in use; in general, probably "a
while" after it
becomes unused. I haven't studied the source code, but I
*think* the
members of a weak structure are treated by the GC just as if
they were
standalone values, i.e., whenever a given member is no
longer explicitly
referenced anywhere in the program, it becomes eligible for
garbage
collection at the normal interval.
> So this means
> that I should permanently have a mean to recompute or
get back that
> value, right ?
Right. So typically, weak data structures are used to store
things that
are likely (but not certain) to be reused, and that are
expensive to
store. Think "caching."
--
Matt Gushee
: Bantam - lightweight file manager :
matt.gushee.net/software/bantam/ :
: RASCL's A Simple Configuration Language :
matt.gushee.net/rascl/ :
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-09 22:38:41 |
On Sat, 9 Sep 2006, Matt Gushee wrote:
> vincent.aravantinos wrote:
>
>> What I have understood is that a weak value may be
collected at any
>> time, ok ?
>
> Any time it is not in use; in general, probably
"a while" after it
> becomes unused. I haven't studied the source code, but
I *think* the
> members of a weak structure are treated by the GC just
as if they were
> standalone values, i.e., whenever a given member is no
longer explicitly
> referenced anywhere in the program, it becomes eligible
for garbage
> collection at the normal interval.
>
>> So this means
>> that I should permanently have a mean to recompute
or get back that
>> value, right ?
>
> Right. So typically, weak data structures are used to
store things that
> are likely (but not certain) to be reused, and that are
expensive to
> store. Think "caching."
I'd rather not use a weak hash table for caching, because
you have
absolutely no guarantee on how many unused items are being
kept, and
for how long.
One use of weak hash tables is for sharing constants such as
strings in
order to save memory: a given string s coming from some
input would be
replaced by the identical string s' found in the table if
it exists, or
added to the table otherwise. Therefore s' is shared, while
the original s
will be discarded.
The weak hash table ensures that strings which become unused
disappear
from the table, like other data that should be
garbage-collected.
--
Martin Jambon, PhD
http://martin.jambon.fre
e.fr
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-09 23:34:17 |
Martin Jambon wrote:
> On Sat, 9 Sep 2006, Matt Gushee wrote:
>
> > vincent.aravantinos wrote:
> >> So this means
> >> that I should permanently have a mean to
recompute or get back that
> >> value, right ?
> >
> > Right. So typically, weak data structures are
used to store things that
> > are likely (but not certain) to be reused, and
that are expensive to
> > store. Think "caching."
>
> I'd rather not use a weak hash table for caching,
because you have
> absolutely no guarantee on how many unused items are
being kept, and
> for how long.
Oh, boy, wrong again. I guess I should just shut up, since
everything I
think I know turns out to be wrong.
One question, though: why do you need a guarantee as to how
many unused
items are kept, etc.? As I understand it, the whole point of
caching is
to reduce the number of calls to external data sources
and/or operations
to recreate objects. Of course there are cases where you
want to be able
to fine-tune it, but wouldn't a naive cache using Weak.* be
better in
many situations than no cache at all? If you can't trust
the garbage
collector to do the right thing, then it must not be a very
good garbage
collector.
--
Matt Gushee
: Bantam - lightweight file manager :
matt.gushee.net/software/bantam/ :
: RASCL's A Simple Configuration Language :
matt.gushee.net/rascl/ :
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-10 00:12:07 |
On Sat, 9 Sep 2006, Matt Gushee wrote:
> Martin Jambon wrote:
>
>> On Sat, 9 Sep 2006, Matt Gushee wrote:
>>
>> > vincent.aravantinos wrote:
>
>> >> So this means
>> >> that I should permanently have a mean to
recompute or get back that
>> >> value, right ?
>> >
>> > Right. So typically, weak data structures are
used to store things that
>> > are likely (but not certain) to be reused, and
that are expensive to
>> > store. Think "caching."
>>
>> I'd rather not use a weak hash table for caching,
because you have
>> absolutely no guarantee on how many unused items
are being kept, and
>> for how long.
>
> Oh, boy, wrong again. I guess I should just shut up,
since everything I
> think I know turns out to be wrong.
>
> One question, though: why do you need a guarantee as to
how many unused
> items are kept, etc.?
Because you want to use both CPU and memory in a balanced
fashion so that
you achieve the best speed possible.
> As I understand it, the whole point of caching is
> to reduce the number of calls to external data sources
and/or operations
> to recreate objects. Of course there are cases where
you want to be able
> to fine-tune it, but wouldn't a naive cache using
Weak.* be better in
> many situations than no cache at all?
You can try, but the results would be different for each
program,
depending on the activity of the GC.
> If you can't trust the garbage
> collector to do the right thing, then it must not be a
very good garbage
> collector.
The role of the GC is to eliminate unused memory, and the
role of a weak
hash table is to mark some items as unused unless they are
used somewhere
else. So basically if you use the weak hash table as a
cache, it's like
marking your cached data as trash, which is pretty much the
opposite.
Martin
--
Martin Jambon, PhD
http://martin.jambon.fre
e.fr
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-10 03:54:31 |
In <Pine.LNX.4.64.0609091644100.2944 droopy>, Martin Jambon <martin_jambon emailuser.net> typed:
> Because you want to use both CPU and memory in a
balanced fashion so that
> you achieve the best speed possible.
Ok, I've read that five times, and I'm still not convinced
it's
english. Or CS jargon. Could you please explain it? Perhaps
provide
examples?
Thanks,
<mike
--
Mike Meyer <mwm mired.org> http://www.mired
.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more
information.
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-10 05:59:45 |
On Sat, 9 Sep 2006, Mike Meyer wrote:
> In <Pine.LNX.4.64.0609091644100.2944 droopy>, Martin Jambon <martin_jambon emailuser.net> typed:
>> Because you want to use both CPU and memory in a
balanced fashion so that
>> you achieve the best speed possible.
>
> Ok, I've read that five times, and I'm still not
convinced it's
> english. Or CS jargon. Could you please explain it?
Perhaps provide
> examples?
It is certainly not CS jargon, probably just bad English.
In French it would be: « parce que l'on veut utiliser le
processeur et la
mémoire de façon équilibrée de sorte à obtenir la meilleure
vitesse
possible. »
There is nothing really related to OCaml here, so let's
just drop it.
Martin
--
Martin Jambon, PhD
http://martin.jambon.fre
e.fr
[Non-text portions of this message have been removed]
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-10 20:12:12 |
--- In ocaml_beginners@yahoogroups.com, Matt Gushee
<matt ...> wrote:
>
> vincent.aravantinos wrote:
>
> > What I have understood is that a weak value may be
collected at any
> > time, ok ?
>
> Any time it is not in use; in general, probably
"a while" after it
> becomes unused. I haven't studied the source code, but
I *think* the
> members of a weak structure are treated by the GC just
as if they were
> standalone values, i.e., whenever a given member is no
longer explicitly
> referenced anywhere in the program, it becomes eligible
for garbage
> collection at the normal interval.
Sorry I don't understand, to my eyes you are exactly
describing a GC. What are the
differences ?
If I understand well, the difference between a normal
hashtbl and a weak hashtbl is :
If one elt is in a normal hashtbl, it will not be collected
(since it is referenced by the
hastbl).
But if an elt is in a weak hashtbl, the fact that it can be
collected or not is defined by the
fact that things _other than the hashtbl itself_ are
refering to it, am I wrong ?
>
> > So this means
> > that I should permanently have a mean to recompute
or get back that
> > value, right ?
>
> Right. So typically, weak data structures are used to
store things that
> are likely (but not certain) to be reused, and that are
expensive to
> store. Think "caching."
^^^^^ didn't you mean "compute" ?
>
> --
> Matt Gushee
> : Bantam - lightweight file manager :
matt.gushee.net/software/bantam/ :
> : RASCL's A Simple Configuration Language :
matt.gushee.net/rascl/ :
Sorry for my slow understanding, and thanx for your patience
Vincent
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
| "ocaml_beginners"::[] About
weak things... |

|
2006-09-10 20:16:36 |
--- In ocaml_beginners@yahoogroups.com, Martin Jambon
<martin_jambon ...> wrote:
>
> On Sat, 9 Sep 2006, Matt Gushee wrote:
>
> > vincent.aravantinos wrote:
> >
> >> What I have understood is that a weak value
may be collected at any
> >> time, ok ?
> >
> > Any time it is not in use; in general, probably
"a while" after it
> > becomes unused. I haven't studied the source
code, but I *think* the
> > members of a weak structure are treated by the GC
just as if they were
> > standalone values, i.e., whenever a given member
is no longer explicitly
> > referenced anywhere in the program, it becomes
eligible for garbage
> > collection at the normal interval.
> >
> >> So this means
> >> that I should permanently have a mean to
recompute or get back that
> >> value, right ?
> >
> > Right. So typically, weak data structures are used
to store things that
> > are likely (but not certain) to be reused, and
that are expensive to
> > store. Think "caching."
>
> I'd rather not use a weak hash table for caching,
because you have
> absolutely no guarantee on how many unused items are
being kept, and
> for how long.
>
> One use of weak hash tables is for sharing constants
such as strings in
> order to save memory: a given string s coming from some
input would be
> replaced by the identical string s' found in the table
if it exists, or
> added to the table otherwise. Therefore s' is shared,
while the original s
> will be discarded.
> The weak hash table ensures that strings which become
unused disappear
> from the table, like other data that should be
garbage-collected.
Okay, this comforts my just-written post :
An elt of a weak hastbl can be GC'd as soon as no _other
reference that the one needed for
the weakhastbl mechanisms_ remains. On the contrary that a
normal hastbl would never
see its elts GC'd because the hastbl itself is refering to
it.
Am I right ?
> --
> Martin Jambon, PhD
> http://martin.jambon.fre
e.fr
>
Vincent
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|
|
[1-8]
|
|