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

Performance penalty for large pages #9

Open
jkuczm opened this issue Sep 14, 2013 · 0 comments · May be fixed by #10
Open

Performance penalty for large pages #9

jkuczm opened this issue Sep 14, 2013 · 0 comments · May be fixed by #10

Comments

@jkuczm
Copy link

jkuczm commented Sep 14, 2013

When PhasedRenderMiddleware is turned on, rendering time grows very fast with size of the content that is outside of phased block.

For simple page that results in ~100 kB of HTML:

  • without PhasedRenderMiddleware in MIDDLEWARE_CLASSES is rendered below 0.1 second
  • with PhasedRenderMiddleware it takes over 20 seconds on my machine to render.

This slowdown is reproducible in many environments:

  • devserver; python 2.7.3; django 1.4.6, 1.5.2
  • apache 2.2.22; mod_wsgi 3.3; python 2.7.3; django 1.5.2
  • apache 2.2.15; mod_wsgi 3.2; python 2.6.6; django 1.5.2

Steps to reproduce this problem:

  1. setup example project from django-phased repository
  2. add long text to base.html template, outside phased block
    e.g. {% for _ in ""|ljust:"10000" %} some text {% endfor %} just after <div id="body">
  3. visit any page using base.html template e.g. /blog/
  4. wait for page to appear
jkuczm added a commit to jkuczm/django-phased that referenced this issue Sep 14, 2013
Before this commit `utils.second_pass_render` tried to unpickle stashed
context from all bits of content resulting from splitting of template by
`PHASED_SECRET_DELIMITER`. Only odd bits are results of `phased` block
rendering, so only those bits contain stashed context. Even bits can't
contain stashed context and since they are results of first pass
rendering they can be arbitrary long and even for content of sane length
searching for regular expression match done in `unpickle_context` can
take insanely long time.  

Fixed by unpickling context only from odd bits.

Fixes: codysoyland#9
@jkuczm jkuczm linked a pull request Sep 14, 2013 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant