|
|
> So, I would be happy for any option (I agree it should not be the
> default) that trades memory usage for time usage in a reasonable way.
Just having that choice available would be nice, yeah.
I was thinking of a general memory saving algorithm that
might apply to some of the structures POV-Ray creates,
but it's utility stems from being broadly applicable
to apps that dynamically create arbitrary objects that
would save memory if they could be shared. The p-code is:
while parsing the input file
parse the object
parse its attributes
create the attribute structures
for each attribute type
do a bsearch into the related attribute struct list
if the struct already exists
have the object point to the existing copy
else
insert the struct to the list to keep it sorted
endif
next
wend
If we treat the contents of an attribute struct as
just a big number, then we can easily qsort on them.
One example is the Object->Trans member. It's not a
good example, because POV-Ray already shares this
struct when it can. But the above code would let
you declare objects any way you wanted, and any
identical Trans structures would automatically
collapse down to a single instance. If we knew ahead
of time (from a previous parsing pass) that the
number of such truly unique instances was below
2^32, then we could use 32-bit handles instead
of 64-bit pointers (or maybe even 24- or 16-bit handles).
Handles are easy because we refactor the list to
occupy a linear memory block and then the mapping
of handle to pointer is just an array index.
Scripters already do this manually, by declaring
shared objects/attributes explicitly. The above
would be more for people who wanted to not bother,
and let the computer figure it out. Ideally, what
would be nice is if the computer would not only
do that, but then emit the script that the user
should have written ("oh, you've redundantly
duped these items. Here, let me make the #declare
statements and organize the script better for you...")
Ray
Post a reply to this message
|
|