-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory blocks
(say, few than 128 bytes).
But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
One time I had to use libc-malloc instead of the one from Boehm-GC. I
was mixing ATS code with some Java code. Apparently, Java-GC and
Boehm-GC do not like the presence of each other
Might I ask what happens?
I have mixed Boehm GC (via Guile) with C-Python’s reference counting
and garbage collector. I’d thought merely using finalizers for Python
objects would do the job, but it turned out I had to use weak
references, make sure the Python GC ran before the Boehm GC was shut
down, etc., etc.
Can one express in ATS the requirement that a pointer is appropriately
aligned and then have that checked statically?On Thursday, November 13, 2014 10:55:58 PM UTC-4, gmhwxi wrote:
I prefer AVL as well
For a red-black tree implementation, you could store the red/black
bit in the pointer pointing to the tree. So you could save a bit (pun).
On Thursday, November 13, 2014 8:18:15 PM UTC-5, Barry Schwartz wrote:
Evans wrote it already, so I use it. If I had had to write my own, I’d
likely have done AVL trees.
I would think Sedgwick is not the best source of a useful opinion on
the difficulty of coding of RB tree variants, due to his closeness to
the subject. One of the lessons from my signal processing education,
for instance, is you need to bring in outsiders and do blind studies
to judge the real-life quality of a telephonic system.
But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
One time I had to use libc-malloc instead of the one from Boehm-GC. I
was mixing ATS code with some Java code. Apparently, Java-GC and
Boehm-GC do not like the presence of each other
Does anyone know a simple conservative GC that can run along the side of
Java-GC?On Thursday, November 13, 2014 6:53:37 PM UTC-5, Barry Schwartz wrote:
-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to
take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory
blocks
(say, few than 128 bytes).
tcmalloc claims to have advantages for small allocations. But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
Related: Is there a way to get the ATS compiler to straightforwardly
inform you whether the program is likely to have memory leaks and so
benefit from garbage collection? Or really mainly so one can avoid
accidentally leaking memory when trying to avoid GC.
Related: Is there a way to get the ATS compiler to straightforwardly
inform you whether the program is likely to have memory leaks and so
benefit from garbage collection? Or really mainly so one can avoid
accidentally leaking memory when trying to avoid GC.
I forgot about this question until now.
No. I am not aware of a general way to do this. If there is a strong need
to ensure no leaks, I often do it by hand. That is, I replace datatypes with
linear datatypes while relying on the typechecker to guide me through this
process.On Thursday, November 13, 2014 6:53:37 PM UTC-5, Barry Schwartz wrote:
-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to
take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory
blocks
(say, few than 128 bytes).
tcmalloc claims to have advantages for small allocations. But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
Related: Is there a way to get the ATS compiler to straightforwardly
inform you whether the program is likely to have memory leaks and so
benefit from garbage collection? Or really mainly so one can avoid
accidentally leaking memory when trying to avoid GC.
But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
One time I had to use libc-malloc instead of the one from Boehm-GC. I
was mixing ATS code with some Java code. Apparently, Java-GC and
Boehm-GC do not like the presence of each other
Might I ask what happens?
I have mixed Boehm GC (via Guile) with C-Python’s reference counting
and garbage collector. I’d thought merely using finalizers for Python
objects would do the job, but it turned out I had to use weak
references, make sure the Python GC ran before the Boehm GC was shut
down, etc., etc.
On Thu, Nov 13, 2014 at 3:21 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:
When compiling an ATS program, you can use
-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to
take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory
blocks
(say, few than 128 bytes).
–
You received this message because you are subscribed to the Google
Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to ats-lang...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
memalign.sats is not made into ATS2 as it is too unwieldy to use in
practice.On Friday, December 5, 2014 11:08:12 AM UTC-5, Marko Schütz-Schmuck wrote:
Can one express in ATS the requirement that a pointer is appropriately
aligned and then have that checked statically?
On Thursday, November 13, 2014 10:55:58 PM UTC-4, gmhwxi wrote:
I prefer AVL as well
For a red-black tree implementation, you could store the red/black
bit in the pointer pointing to the tree. So you could save a bit (pun).
On Thursday, November 13, 2014 8:18:15 PM UTC-5, Barry Schwartz wrote:
Evans wrote it already, so I use it. If I had had to write my own, I’d
likely have done AVL trees.
I would think Sedgwick is not the best source of a useful opinion on
the difficulty of coding of RB tree variants, due to his closeness to
the subject. One of the lessons from my signal processing education,
for instance, is you need to bring in outsiders and do blind studies
to judge the real-life quality of a telephonic system.
I have read source code for AVL trees that assumes aligned pointers and
uses an assert for the check for every node created. This is used in ZFS
and thus in the kernel of several OSs.
Just how unwieldy in practice in memalign.sats?On Friday, December 5, 2014 12:22:49 PM UTC-4, gmhwxi wrote:
Evans wrote it already, so I use it. If I had had to write my own, I’d
likely have done AVL trees.
I would think Sedgwick is not the best source of a useful opinion on
the difficulty of coding of RB tree variants, due to his closeness to
the subject. One of the lessons from my signal processing education,
for instance, is you need to bring in outsiders and do blind studies
to judge the real-life quality of a telephonic system.
For a red-black tree implementation, you could store the red/black
bit in the pointer pointing to the tree. So you could save a bit (pun).On Thursday, November 13, 2014 8:18:15 PM UTC-5, Barry Schwartz wrote:
Evans wrote it already, so I use it. If I had had to write my own, I’d
likely have done AVL trees.
I would think Sedgwick is not the best source of a useful opinion on
the difficulty of coding of RB tree variants, due to his closeness to
the subject. One of the lessons from my signal processing education,
for instance, is you need to bring in outsiders and do blind studies
to judge the real-life quality of a telephonic system.
I could have done something really cheap: using ATS_MALLOC_linear for
allocatiing linear constructors and ATS_MALLOC_nonlinear for non-linear
ones.
In this way, if one searches for ATS_MALLOC_linear, then it is a sure sign
of
leak if no GC is involved.
I feel that this kind of “solution” is too ad hoc. There is a trove of
information
generated during compilation that can be useful to the programmer. I plan
to find
a way to export such information in, say, JSON format so that people can
write
external tools to analyze it.On Friday, November 14, 2014 9:38:50 PM UTC-5, Barry Schwartz wrote:
I asked:
Related: Is there a way to get the ATS compiler to straightforwardly
inform you whether the program is likely to have memory leaks and so
benefit from garbage collection? Or really mainly so one can avoid
accidentally leaking memory when trying to avoid GC.
No. I am not aware of a general way to do this. If there is a strong
need
to ensure no leaks, I often do it by hand. That is, I replace datatypes
with
linear datatypes while relying on the typechecker to guide me through
this
process.
The question arose because my first use of a datatype for
pattern-matching, then seeing that ATS asked for a malloc but not for
a free. So I realized I wanted a datavtype. But if I had been
supplying a malloc and free already I might not have noticed.
-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to
take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory
blocks
(say, few than 128 bytes).
tcmalloc claims to have advantages for small allocations. But I guess
the point is that on most of our systems we can just use Boehm GC like
regular malloc, perhaps with benefit (though on some systems it is
supposed to need special initialization).
Related: Is there a way to get the ATS compiler to straightforwardly
inform you whether the program is likely to have memory leaks and so
benefit from garbage collection? Or really mainly so one can avoid
accidentally leaking memory when trying to avoid GC.
-DATS_MEMALLOC_LIBC // using libc malloc/free
-DATS_MEMALLOC_GCBDW // using malloc/free provided by Bohem-GC
There is a point that some people may not be aware of.
I often use -DATS_MEMALLOC_GCBDW even if my code does not require
runtime garbage collection. For instance, my code uses linear types to take
care of memory issues. This makes sense because an action-less Bohem-GC
may actually provide faster allocation/deallocation for small memory blocks
(say, few than 128 bytes).
If I need to do it, I may try something as follows:
Say, ptr_get reads a value of type T from a given pointer:
extern
fun ptr_get{l:addr} (pf: !T @ l | p: ptr(l)): T
If I need to make sure that the given pointer is well-aligned, I can use
the following
interface for ptr_get:
extern
fun ptr_get{l:addr} (pf: !T @ l, pf2: is_aligned(l) | p: ptr(l)): T
where is_aligned is an abstract prop:
absprop is_aligned (l:addr).
Run-time checks can be added to get a proof for the ‘is_aligned’ predicate.On Mon, Dec 8, 2014 at 10:21 AM, Marko Schütz-Schmuck < markos...@googlemail.com> wrote:
I have read source code for AVL trees that assumes aligned pointers and
uses an assert for the check for every node created. This is used in ZFS
and thus in the kernel of several OSs.
Just how unwieldy in practice in memalign.sats?
On Friday, December 5, 2014 12:22:49 PM UTC-4, gmhwxi wrote:
Evans wrote it already, so I use it. If I had had to write my own, I’d
likely have done AVL trees.
I would think Sedgwick is not the best source of a useful opinion on
the difficulty of coding of RB tree variants, due to his closeness to
the subject. One of the lessons from my signal processing education,
for instance, is you need to bring in outsiders and do blind studies
to judge the real-life quality of a telephonic system.