On 9-9-2010 9:07, Paweł Jackowski wrote:
Taco Hoekwater wrote: [...]
Hans and I just did some tests, and it seems that the userdata access is useful if *but only if* you are very low on memory. In other cases, it just adds extra objects to be garbage collected, which makes the collector slower. That is on top of extra time spent on the actual calls, and even worse: those extra gc objects tend to be scattered around in memory, resulting in extra minor page faults (cpu cache misses) and all that has a noticeable effect on run speed: the metatable-based access is 20-30% slower than the old massive to_table.
Interesting. As you said, much depends on how one uses / tests. I made some tests with translating fontforge font structure directly into the luatex font table without an intermediate form. This gives bests results, but obviously requires too many simplifications.
That is indeed where there can be some gain (no intermediate table but compensated by function calls) but as soon as you start keeping some extra info around (not passed to tex or manipulated inbetween) it quickly gets worse due to the mentioned scattering. Then there can be a smaller mem footprint at the cost of some extra runtime. On the other hand, using the traditional method (table) and invoking the garbage collector every now and then gives an equally low memory footprint but a sweep takes some time as well. Interesting is that on some test runs I can get about twice the performance using tables but it's not that easy to figure out why. Btw, in the table approach one can manipulate the font before conversion, something that is less easy in the userdata variant. Anyhow, what we provide now is a nice compromise 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 -----------------------------------------------------------------