The r300 program compiler has some parts in which we dynamically allocate 
structures to represent values and value accesses. The memory usage pattern is 
as follows:

. Many small allocations
. Allocations live only during compilation
. While quite a few allocations could be freed early, it would be rather 
cumbersome to determine exactly when freeing them is legal

In other words, the pattern is quite typical of some arguments in favour of 
garbage collection. The good thing about the compiler is, however, that we 
know that *everything* can be freed once compilation is finished.

To make life easier, I have written a memory_pool structure which supports 
this type of usage pattern: One can quickly and dynamically allocate small 
structures. This is achieved at the cost of being able to free those 
structures dynamically. Instead, all allocations can be freed in one big sweep 
at the end of the operation.

I would imagine that such a memory pool could be beneficial to other users in 
Mesa. Right now, the code is in my branch in the driver itself, but I wonder 
whether I should move it outside into a generally accessible location and if 
so, where. It doesn't really fit under either src/mesa nor src/gallium since 
both might want it.

Right now, the code is here:
http://cgit.freedesktop.org/~nh/mesa/tree/src/mesa/drivers/dri/r300/compiler?h=r300-
compiler

Feedback is most welcome!

cu,
Nicolai

------------------------------------------------------------------------------
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to