Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slow performance with lots of spans and anchors in pre? #553

Closed
dmalan opened this issue Dec 18, 2017 · 5 comments
Closed

slow performance with lots of spans and anchors in pre? #553

dmalan opened this issue Dec 18, 2017 · 5 comments
Labels
performance Too slow renderings
Milestone

Comments

@dmalan
Copy link

dmalan commented Dec 18, 2017

In follow-up to #483, we've encountered a similar performance issue with inputs like https://gist.github.com/dmalan/22e14a769a78739dd22de7104ba46bfd, whereby quite a few span and a are inside of pre, as might happen when rendering source code. (To simplify the gist, we've removed all CSS and replaced chunks of code with just foo.) For instance, in an Ubuntu 14.04 Docker container on a Mac Pro, rendering those 399 lines takes 1m13s:

# pip show weasyprint
Name: WeasyPrint
Version: 0.41
Summary: WeasyPrint converts web documents to PDF.
Home-page: http://weasyprint.org/
Author: Simon Sapin
Author-email: simon.sapin@kozea.fr
License: BSD
Location: /opt/pyenv/versions/3.6.0/lib/python3.6/site-packages
Requires: html5lib, pdfrw, Pyphen, cssselect2, CairoSVG, cffi, cairocffi, tinycss2

# time weasyprint test.html test.pdf
/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/weasyprint/text.py:29: UserWarning: There are known rendering problems with Cairo <= 1.14.0
  warnings.warn('There are known rendering problems with Cairo <= 1.14.0')
/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/weasyprint/fonts.py:43: UserWarning: @font-face support needs Pango >= 1.38
  warnings.warn('@font-face support needs Pango >= 1.38')

real	1m13.438s
user	1m13.240s
sys	0m0.130s

Any chance there's another hot spot that 46da8b5 didn't already redress?

Many thanks!

@liZe
Copy link
Member

liZe commented Dec 18, 2017

rendering those 399 lines takes 1m13s

Shame! Shame! Shame!

Any chance there's another hot spot that 46da8b5 didn't already redress?

I hope so, I'll take a look as soon as possible.

@liZe liZe added the performance Too slow renderings label Dec 18, 2017
@dmalan
Copy link
Author

dmalan commented Dec 22, 2017

Thank you kindly!

@liZe liZe closed this as completed in 6087982 Dec 23, 2017
@liZe liZe added this to the v0.42 milestone Dec 23, 2017
@liZe
Copy link
Member

liZe commented Dec 23, 2017

I have to check twice that I didn't break anything, but that's a major improvement when there are many inlines and lots of lines in a block. Moreover, 0.42 fixes #163, this page should be perfectly rendered now.

@dmalan
Copy link
Author

dmalan commented Dec 23, 2017

Amazing, thanks so much.

@dmalan
Copy link
Author

dmalan commented Dec 26, 2017

Albeit on a different machine at the moment, down to

real	0m2.039s
user	0m1.830s
sys	0m0.090s

for the same input now. Thank you, @liZe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Too slow renderings
Projects
None yet
Development

No branches or pull requests

2 participants