[NTG-context] [font-syn.lua] remove call to fontloader.to_table()
Hi all, calling fontloader.to_table() appears to be redundant when extracting font names, see the attached patch. On my system I measured 42 (patched) vs 59 (vanilla) seconds for rebuilding the entire index: mtxrun --script fonts --reload --force The resulting index is -- except for the uuid, naturally -- identical in both cases. Best, Philipp --- /home/phg/base/font-syn.lua 2013-10-25 00:01:04.0 +0200 +++ font-syn.lua2013-11-09 18:30:33.540364371 +0100 @@ -266,8 +266,21 @@ function fontloader.fullinfo(...) -- check with taco what we get / could get local ff = fontloader.open(...) if ff then -local d = ff and fontloader.to_table(ff) -d.glyphs, d.subfonts, d.gpos, d.gsub, d.lookups = nil, nil, nil, nil, nil +local fields = table.tohash (fontloader.fields (ff), true) +local d = { +names = fields.names and ff.names, +familyname = fields.familyname and ff.familyname, +fullname= fields.fullnameand ff.fullname, +fontname= fields.fontnameand ff.fontname, +weight = fields.weight and ff.weight, +italicangle = fields.italicangle and ff.italicangle, +units_per_em= fields.units_per_emand ff.units_per_em, +design_range_bottom = fields.design_range_bottom and ff.design_range_bottom, +design_range_top= fields.design_range_topand ff.design_range_top, +design_size = fields.design_size and ff.design_size, +italicangle = fields.italicangle and ff.italicangle, +pfminfo = fields.pfminfo and ff.pfminfo, +} fontloader.close(ff) return d else pgpACw5YFizX4.pgp Description: PGP signature ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()
On 11/9/2013 6:45 PM, Philipp Gesang wrote: Hi all, calling fontloader.to_table() appears to be redundant when extracting font names, see the attached patch. On my system I measured 42 (patched) vs 59 (vanilla) seconds for rebuilding the entire index: mtxrun --script fonts --reload --force The resulting index is -- except for the uuid, naturally -- identical in both cases. Okay. In fact this fullinfo was meant as temporary hack because fontloader.info should return these values (and might at some time). In the meantime delayed loading was introduced which is why: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then return ff else return nil, error in loading font end end also could work ok (in fact, the explicit glyphs = nil in the current variant assumes the old loader and has the speed impact you notice because it now first loads all glyphs and next discards them) Okay, in practice we need something like this: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then local d = { } -- ff is userdata so [1] or # fails on it setmetatable(d, { __index = ff }) return d else return nil, error in loading font end end because I check for [1] or # in case of a ttc font which fails on the ff userdata table. This variant is somewhat more in tune with the 'full' aspect. Thanks for noticing, Hans - 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()
···date: 2013-11-09, Saturday···from: Hans Hagen··· On 11/9/2013 6:45 PM, Philipp Gesang wrote: Hi all, calling fontloader.to_table() appears to be redundant when extracting font names, see the attached patch. On my system I measured 42 (patched) vs 59 (vanilla) seconds for rebuilding the entire index: mtxrun --script fonts --reload --force The resulting index is -- except for the uuid, naturally -- identical in both cases. Okay. In fact this fullinfo was meant as temporary hack because fontloader.info should return these values (and might at some time). In the meantime delayed loading was introduced which is why: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then return ff else return nil, error in loading font end end also could work ok (in fact, the explicit glyphs = nil in the current variant assumes the old loader and has the speed impact you notice because it now first loads all glyphs and next discards them) Okay, in practice we need something like this: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then local d = { } -- ff is userdata so [1] or # fails on it setmetatable(d, { __index = ff }) return d else return nil, error in loading font end end Aren’t you allocating fonts without freeing them? With this approach you need fontloader.close() somewhere inside check_names() which isn’t straightforward if you hide the font data inside the metatable. Btw. calling fontloader.info() first yields a table for ttcs and is unnoticable performance-wise. Best, Philipp pgpDLLknNrBhp.pgp Description: PGP signature ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()
···date: 2013-11-09, Saturday···from: Philipp Gesang··· ···date: 2013-11-09, Saturday···from: Hans Hagen··· On 11/9/2013 6:45 PM, Philipp Gesang wrote: Hi all, calling fontloader.to_table() appears to be redundant when extracting font names, see the attached patch. On my system I measured 42 (patched) vs 59 (vanilla) seconds for rebuilding the entire index: mtxrun --script fonts --reload --force The resulting index is -- except for the uuid, naturally -- identical in both cases. Okay. In fact this fullinfo was meant as temporary hack because fontloader.info should return these values (and might at some time). In the meantime delayed loading was introduced which is why: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then return ff else return nil, error in loading font end end also could work ok (in fact, the explicit glyphs = nil in the current variant assumes the old loader and has the speed impact you notice because it now first loads all glyphs and next discards them) Okay, in practice we need something like this: function fontloader.fullinfo(...) -- lazy loading anyway local ff = fontloader.open(...) if ff then local d = { } -- ff is userdata so [1] or # fails on it setmetatable(d, { __index = ff }) return d else return nil, error in loading font end end Aren’t you allocating fonts without freeing them? Scratch that, I just did some tests and memory consumption seems to be the same. Thanks for revealing this feature! Best, Philipp pgpjI__CuoJg1.pgp Description: PGP signature ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()
On 11/9/2013 8:42 PM, Philipp Gesang wrote: Aren’t you allocating fonts without freeing them? With this approach you need fontloader.close() somewhere inside check_names() which isn’t straightforward if you hide the font data inside the metatable. Btw. calling fontloader.info() first yields a table for ttcs and is unnoticable performance-wise. i assume that the loader automatically closes when the userdata is garbage collected (just like file handlers are) .. it doesn't seem to be a problem when generating the database Hans - 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()
On 11/9/2013 8:48 PM, Philipp Gesang wrote: Scratch that, I just did some tests and memory consumption seems to be the same. Thanks for revealing this feature! fyi: it's one of the reasons why the overhead in terms of memory of the initial loading of large fonts (pre-caching) became less (already a few years ago now) Hans - 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___