Unfortunately, the automatic garbage collection is important because of the shared structure - slices, transposes, reshapes, etc. share the content vector with the parent. They should never be circular, so a reference count method might work. But, it may not worth it.<br>
<br>At some point we would have to do the boxing to get results to/from Scheme code.<br><br><div class="gmail_quote">On Thu, Aug 13, 2009 at 9:35 PM, Robby Findler <span dir="ltr"><<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you were careful to allocate these big blobs in special places,<br>
could you use the address itself as a tag (I think that's what the<br>
bebob collectors do) and avoid the extra boxing?<br>
<br>
Robby<br>
<div><div></div><div class="h5"><br>
On Thu, Aug 13, 2009 at 10:24 PM, Doug<br>
Williams<<a href="mailto:m.douglas.williams@gmail.com">m.douglas.williams@gmail.com</a>> wrote:<br>
> Eli,<br>
><br>
> Thanks for the info. It's all useful and I put some trivial comments in-line<br>
> below.<br>
><br>
> Doug<br>
><br>
>> * However, if you're doing a lot of work *inside* Scheme, then things<br>
>> can become very inefficient. For example, say that you want to loop<br>
>> over a floating point array and multiply all of the values by a<br>
>> given factor. What will happen in this case is: each time you read<br>
>> a value, you allocate a Scheme object for the fp number, multiplying<br>
>> that allocates a new one, then saving it copies the result back to<br>
>> the array, leaving the two allocated values to be GCed. (There are<br>
>> some JIT-level optimizations for fp numbers, I don't know if it can<br>
>> save one of these allocations in this case.)<br>
><br>
> My plan would be to do the work inside of Scheme - at least for now. It<br>
> would be interesting to see if there are some JIT optimizations planned for<br>
> the future that could help.<br>
><br>
>><br>
>> * Another point to consider is huge arrays -- if you expect to have<br>
>> such arrays, then it might be better to do the allocation explicitly<br>
>> outside of the GC -- using `malloc' in 'raw mode. This will require<br>
>> registering finalizers to free them, but the benefits are:<br>
>> - You can have a huge array without worrying about the 3m GC that<br>
>> usually requires double the space that you're using.<br>
>> - Dealing with an external library that allocates an array becomes<br>
>> easy, since it's dealt with in the same way.<br>
>> - No issues with arrays moving around, for external code that keeps<br>
>> pointers to it. (I can imagine this being a real benefit if there<br>
>> are libraries that can use multiple cores and calling a callback<br>
>> function when the operation is done.)<br>
><br>
> Some applications would use large arrays.<br>
><br>
>><br>
>> * Finally, it sounds like it might be more convenient to use the<br>
>> `cvector' representation from the foreign interface: this is very<br>
>> similar to the srfi-4 representation, except that the type is stored<br>
>> in the cvector rather than having a separate type for each kind of<br>
>> vector.<br>
><br>
> I'll look into it. I already wrote a typed-vector abstraction on top of SFRI<br>
> 4 (and normal Scheme vectors), so that isn't an issue for now.<br>
><br>
><br>
><br>
</div></div>> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
><br>
><br>
</blockquote></div><br>