John
2018-12-07 13:30:48 UTC
My site <https://www.morphmarket.com/> has a navbar with an advanced search
widget (beside the search field), which renders on every page. For each
request, a context_processor creates the form so it can be available on
that page in the navbar. This form has about a dozen selects with a total
of several hundred options. Most of those options are for the currency and
country selects, along with about 80 other options. There is an even larger
list for "stores" but it is loaded via AJAX so it should not be a factor
here.
Performance was fine on Django 1.8, but after upgrading to 1.11 I noticed
with NewRelic that over 500 ms are now being used on my most frequent
request between the following:
- Render/django/forms/widgets/select_option.html
- Render/django/forms/widgets/select.html
- Render/django/forms/widgets/attrs.html
[image: xDE2A.png]
This seems to be related to 1.11's change to Template-based Widget Rendering
<https://code.djangoproject.com/ticket/15667> (docs
<https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#djangotemplates>),
however the only pages I could find talking about related problems were
about Django Toolbar which I do not run in production.
I am and already using the Cached Template Loader (which is now default),
however I don't know if this helps here. I cannot easily cache this form
because as you can see in the code, I set a number of defaults based on the
request.
Why is my form suffering so badly from this change? Eliminating two of the
bigger selects helps, but surely several hundred options should not take
this long to render so it seems to me there is an underlying problem that
the quantity is merely exacerbating.
Here are links to to code for the full form and html. (I will include
snippets in the question later when we identify the problem, for future
readers).
- Search Form
<https://gist.github.com/jplehmann/b75379c12a37a6064f1face208d7dc88#file-search-py-L223>
- Search HTML
<https://gist.github.com/jplehmann/44872ab2c02da89080e9a199aed349ae>
- Live Site <http://www.morphmarket.com/>
Thank you in advance for your help!
widget (beside the search field), which renders on every page. For each
request, a context_processor creates the form so it can be available on
that page in the navbar. This form has about a dozen selects with a total
of several hundred options. Most of those options are for the currency and
country selects, along with about 80 other options. There is an even larger
list for "stores" but it is loaded via AJAX so it should not be a factor
here.
Performance was fine on Django 1.8, but after upgrading to 1.11 I noticed
with NewRelic that over 500 ms are now being used on my most frequent
request between the following:
- Render/django/forms/widgets/select_option.html
- Render/django/forms/widgets/select.html
- Render/django/forms/widgets/attrs.html
[image: xDE2A.png]
This seems to be related to 1.11's change to Template-based Widget Rendering
<https://code.djangoproject.com/ticket/15667> (docs
<https://docs.djangoproject.com/en/1.11/ref/forms/renderers/#djangotemplates>),
however the only pages I could find talking about related problems were
about Django Toolbar which I do not run in production.
I am and already using the Cached Template Loader (which is now default),
however I don't know if this helps here. I cannot easily cache this form
because as you can see in the code, I set a number of defaults based on the
request.
Why is my form suffering so badly from this change? Eliminating two of the
bigger selects helps, but surely several hundred options should not take
this long to render so it seems to me there is an underlying problem that
the quantity is merely exacerbating.
Here are links to to code for the full form and html. (I will include
snippets in the question later when we identify the problem, for future
readers).
- Search Form
<https://gist.github.com/jplehmann/b75379c12a37a6064f1face208d7dc88#file-search-py-L223>
- Search HTML
<https://gist.github.com/jplehmann/44872ab2c02da89080e9a199aed349ae>
- Live Site <http://www.morphmarket.com/>
Thank you in advance for your help!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/113ef86c-7be2-45da-9b57-d56b773195d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/113ef86c-7be2-45da-9b57-d56b773195d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.