Re: [NTG-context] [font-syn.lua] remove call to fontloader.to_table()

2013-11-09 Thread 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

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()

2013-11-09 Thread 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? 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()

2013-11-09 Thread Philipp Gesang
···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()

2013-11-09 Thread Hans Hagen

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()

2013-11-09 Thread Hans Hagen

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
___