<div dir="rtl"><div dir="ltr">Isn't there anything we can do about it?<br></div><div dir="ltr">We can open issues at the Django issue tracker if some code slows down execution in PyPy.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div dir="ltr">2015-02-08 12:17 GMT+02:00 Maciej Fijalkowski <span dir="ltr"><<a href="mailto:fijall@gmail.com" target="_blank">fijall@gmail.com</a>></span>:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tin<br>
<br>
I have a bit sad news for you, but essentially from what I looked at<br>
profling, the answer seems to be "don't use django, it has not been<br>
written with performance in mind". For example here (which features in<br>
django admin quite prominently, some stuff calls lazy() at each call):<br>
<a href="https://github.com/django/django/blob/master/django/utils/functional.py#L48" target="_blank">https://github.com/django/django/blob/master/django/utils/functional.py#L48</a><br>
<br>
What does it, per call that pypy does not like:<br>
<br>
* redefines classes<br>
<br>
* walks the class __mro__ and defines tons of new methods<br>
<br>
* proxies everything through a not so efficietn mechanisms<br>
<br>
Those things quite defy the purpose of the JIT - you're making tons of<br>
very dynamic things that pypy generally assumes is "static enough", if<br>
you wanted to do the same thing in C++, you would need to call gcc<br>
with each request, that would not be so much fun.<br>
<br>
If you really care about performance, consider swapping your web<br>
framework to something more performance-oriented where JIT compilation<br>
can help.<br>
<br>
As a side note, we (me and my company, not to be confused with PyPy<br>
open source project) do offer looking at proprietary code for<br>
benchmarking purposes as a commercial service, look at<br>
<a href="http://baroquesoftware.com" target="_blank">baroquesoftware.com</a><br>
<br>
Cheers,<br>
fijal<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Sat, Feb 7, 2015 at 1:12 AM, Tin Tvrtković <<a href="mailto:tinchester@gmail.com">tinchester@gmail.com</a>> wrote:<br>
> Hello, PyPy folks!<br>
><br>
> While trying to speed up one of my Django sites, I noticed a new version of<br>
> PyPy<br>
> had just been released. So I grabbed a fresh download of PyPy 3 (since this<br>
> is<br>
> a Python 3 codebase) and tried taking it out for a spin.<br>
><br>
> However, as far as I can see, whatever I try PyPy is consistently slower<br>
> than<br>
> CPython for this.<br>
><br>
> Since this is a proprietary site, I've basically ripped out all the code<br>
> except<br>
> my settings.py and my requirements; and am benchmarking the Django admin<br>
> index.<br>
> The results are about the same.<br>
><br>
> I've set up a small repo that can be used to reproduce the environment:<br>
> <a href="https://github.com/Tinche/PyPy-Django-Playground" target="_blank">https://github.com/Tinche/PyPy-Django-Playground</a>. There's additional info in<br>
> the README there.<br>
><br>
> These tests have been carried out on Ubuntu Trusty, 64-bit. CPython 3 is the<br>
> system Python, 3.4. PyPy has been downloaded from the official site and<br>
> unzipped.<br>
><br>
> So what I basically do is set up an admin session, and use the Django main<br>
> admin<br>
> page. 200 warmup requests, then 100 benchmarked requests, look at the mean<br>
> request time.<br>
><br>
> Some results:<br>
><br>
> Django's runserver, DEBUG mode:<br>
><br>
> PyPy3            485.389 [ms]<br>
> CPython 3.4      105.777 [ms]<br>
><br>
> Django's runserver, no debug:<br>
><br>
> PyPy3             44.661 [ms]<br>
> CPython 3.4       18.697 [ms]<br>
><br>
> Gunicorn, 1 worker, no debug:<br>
><br>
> PyPy3             28.615 [ms]<br>
> CPython 3.4       13.532 [ms]<br>
><br>
> I don't exactly claim to be an expert on benchmarking, but assuming my site<br>
> is similar to the Django admin, CPython's gonna be giving me better<br>
> performance.<br>
> Also the debug runserver performance is kinda worrying. Nobody's going to be<br>
> running this in production, but it makes development a little slower and<br>
> more<br>
> annoying than it should be.<br>
><br>
> Is there anything to make PyPy more competitive in these kinds of scenarios?<br>
><br>
> Kind regards,<br>
> Tin<br>
> _______________________________________________<br>
> pypy-dev mailing list<br>
> <a href="mailto:pypy-dev@python.org">pypy-dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/pypy-dev" target="_blank">https://mail.python.org/mailman/listinfo/pypy-dev</a><br>
_______________________________________________<br>
pypy-dev mailing list<br>
<a href="mailto:pypy-dev@python.org">pypy-dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pypy-dev" target="_blank">https://mail.python.org/mailman/listinfo/pypy-dev</a><br>
</div></div></blockquote></div><br></div>