Closed claudep closed 2 years ago
This does not resolve the performance regression for me. Here's a profile of my (admittedly far from minimal) case using this branch:
Sat May 14 08:28:24 2022 pdfgen.prof
68571541 function calls (60673417 primitive calls) in 417.654 seconds
Ordered by: internal time
List reduced from 9286 to 20 due to restriction <20>
ncalls tottime percall cumtime percall filename:lineno(function)
60067 254.892 0.004 254.892 0.004 {method 'poll' of 'select.poll' objects}
90093 50.078 0.001 50.078 0.001 {built-in method posix.read}
15016 41.077 0.003 41.077 0.003 {built-in method _posixsubprocess.fork_exec}
791892/261374 2.729 0.000 3.625 0.000 svglib.py:173(findAttr)
849194 2.345 0.000 2.345 0.000 {built-in method posix.stat}
15016 2.032 0.000 98.412 0.007 subprocess.py:1663(_execute_child)
21532 1.838 0.000 197.603 0.009 svglib.py:1342(applyStyleOnShape)
626738 1.786 0.000 3.845 0.000 attrmap.py:99(validateSetattr)
1008191 1.524 0.000 2.459 0.000 posixpath.py:71(join)
30044 1.521 0.000 9.022 0.000 ttfonts.py:145(TTFOpenFile)
15016 1.356 0.000 260.523 0.017 subprocess.py:1928(_communicate)
8244450/8244430 1.351 0.000 1.456 0.000 {built-in method builtins.isinstance}
6250695/520643 1.261 0.000 1.434 0.000 basic.py:2028(_preorder_traversal)
3406254/3406189 1.165 0.000 1.253 0.000 {built-in method builtins.getattr}
7504 1.014 0.000 385.925 0.051 svglib.py:1038(convertText)
219409 1.013 0.000 1.013 0.000 {method 'split' of 'str' objects}
15016 0.987 0.000 2.823 0.000 subprocess.py:1207(_close_pipe_fds)
60729 0.921 0.000 0.923 0.000 {built-in method io.open}
15016 0.878 0.000 365.387 0.024 fonts.py:77(use_fontconfig)
362903 0.826 0.000 0.826 0.000 {built-in method reportlab.lib._rl_accel.fp_str}
Do I have to use svglib in a specific way to take advantage of the caching?
Ah yes, sorry. I see my patch does improve things for unknown fonts, but in this case, there is another branching scenario where registering the font fails with a TTFError
. I'll work on improving this.
Could you please test the result now?
Works for me now. This makes a 20x speed difference in my case. Thanks for fixing it so quickly!
Thanks a lot @claudep for fixing that one and to @salistha-shakya and @karlb for reporting it!
Fixes a performance regression in 83d2ec043e094562f.