Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: possible fix for skin buffer issues

possible fix for skin buffer issues

From: Jonathan Gordon <jdgordy_at_gmail.com>
Date: Sun, 9 Oct 2011 23:37:30 +1100

Braindump for someone to pick up to fix the skin buffer memory
allocation "issue".

The "problem" is that The vast majority of the skin buffers static
allocation goes to the struct skin_element which is allocted for every
single item in the skin file. Every line, tag, subline, comment, etc.
on e200 this comes out to 41KB (going from memory). The next biggest
allocation is struct skin_token, which is 20x smaller in total than
skin_element.

So obviously there is no point doing anything except move skin_element
onto buflib.
This is *problematic* because they are used, well everywhere.

My braindump fix is this:
1) give the lib a callback which will allocated 1000 skin_element
structs in a block (we obviously dont want 600 allocations for this)
2) in skin_alloc_element() allocate from the above array instead of
the skin_buffer (when it is full allocate another 1000 or so)
3) in skin_render_viewport() (and a few other places) lock all those handles
4) in the move callback, walk the entire skin tree (this means every
tree loaded) and update each pointer. This is going to be slow and
crap, but hopefully not done often.

I *think* those items are only used when traversing the tree so it is
possible the pointer updating could even be done delayed (so store the
diff somewhere and update the first time it is traversed after the
move - Though this could be very dangerous, actually yeah, dont do
this. hidden viewports are ignored at render time).

I'm not sure what the alternatives are, this is a pretty nasty
solution. Hopefully someone comes up with a better one (or implements
this as I don't particularly have interest in doing it right now, but
thought it would be good to explain the issue and a solution.)

Jonathan
Received on 2011-10-09


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa