[Dev-luatex] luafontloader virtual access (bug #404, #448)

Hans Hagen pragma at wxs.nl
Tue Sep 7 22:45:24 CEST 2010

On 7-9-2010 8:12, Paweł Jackowski wrote:
> [...]
>> The reason for this message is this: what are items that need to be
>> virtualized, and which ones can easily be left alone?
>> For example
>> <glyph>.boundingbox
>> returns an array of 4 integer numbers. It seems to me that it makes
>> not that much sense to write a dedicated userdata object for such
>> boundingboxes: the method call overhead will probably outweigh the
>> gain from using less memory.
>> On the other hand,
>> <glyph>.kerns
>> can be enormous (as it is in the punknova.kern case) and should probably
>> be converted.
>> Does anybody want to think about a shortlist of such items?
> Wow! Thank you for preserving objects access interface; it seems I don't
> need to change anything.

It all depends on usage ... I need to change a lot (to more ugly code 
actually) and we're only talking of a partial userdata -)

> Among glyph.kerns I'd vote to virtualize glyph.lookups, as this is the
> _most_ scary part, especially in non-latin fonts. Possibly also
> glyph.anchors

it doesn't make it less scary, does it?

> Regarding mappings, I think that every of the following
> loaded_font.map.map
> loaded_font.map.backmap
> loaded_font.map.enc

I've experimented a lot with these things (mem consumption, speed, eyc) 
and and there is quite a trade-off

- accessing them as userdata each time needed takes a function call and 
is slower than accessing a table

- most tables are not that large data and hardly give overhead

- as soon as you would like to have the data at the lua end more 
permanently you have to do quite some (inefficient) table construction

- there is no gain in for instance the map tables, and if one needs them 
one often needs the whole table and unless you make a copy you then need 
to keep the font object in memory

it all depends on how you use fonts ...

(1) just consult then ... the current userdata saves much mem as one can 
access selectively

(2) construct a tex font (tfm table) ... one stepwise fills the tfm data 
structure, and keeps whatever needed around, and then closes the 
fontloader object

(3) idem but keeping the object open

in case 2 there will be the penalty of constructing tables from userdata 
but we win in less memory consumption of glyph data (if not used at the 
lua end); in case 3 you basically loose the gain as you need to keep the 
whole font in mem anyway, ok, not in table form, but one will probably 
also cache some info so that duplicates and the gain gets lost

the advantage of the userdata for glyphs and the root tables is that one 
delays table conversion but eventually one will need much of the data 
but at least it can be fetched selectively; the userdata keeps the 
memory footprint low in the sense that less intermediate data is needed

so, it's kind of a mix ... partial userdata helps, but too much of it 
works against us


                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl

More information about the dev-luatex mailing list