<div dir="ltr">FWIW, I've definitely seen and worked on Django sites that got major improvements out of PyPy -- both the templates and ORM are both sped up substantially by it. I think we should try to fix issues as we see them, before writing it off.<div><br></div><div>FWIW: lazy does not create a new class per call of a function, it's only one class per decorated function.</div><div><br></div><div>Alex</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 8, 2015 at 6:59 AM, Maciej Fijalkowski <span dir="ltr"><<a href="mailto:fijall@gmail.com" target="_blank">fijall@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't know :-( not sure if fixing those issues one by one is the way<br>
to go, it's not like *this* particular code is a problem, it's the<br>
culture that breeds those sort of things<br>
<div class="HOEnZb"><div class="h5"><br>
On Sun, Feb 8, 2015 at 2:09 PM, Omer Katz <<a href="mailto:omer.drow@gmail.com">omer.drow@gmail.com</a>> wrote:<br>
> Isn't there anything we can do about it?<br>
> We can open issues at the Django issue tracker if some code slows down<br>
> execution in PyPy.<br>
><br>
> 2015-02-08 12:17 GMT+02:00 Maciej Fijalkowski <<a href="mailto:fijall@gmail.com">fijall@gmail.com</a>>:<br>
>><br>
>> 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>
>><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>
>><br>
>><br>
>><br>
>> On Sat, Feb 7, 2015 at 1:12 AM, Tin Tvrtković <<a href="mailto:tinchester@gmail.com">tinchester@gmail.com</a>><br>
>> wrote:<br>
>> > Hello, PyPy folks!<br>
>> ><br>
>> > While trying to speed up one of my Django sites, I noticed a new version<br>
>> > of<br>
>> > PyPy<br>
>> > had just been released. So I grabbed a fresh download of PyPy 3 (since<br>
>> > 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<br>
>> > info in<br>
>> > the README there.<br>
>> ><br>
>> > These tests have been carried out on Ubuntu Trusty, 64-bit. CPython 3 is<br>
>> > 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<br>
>> > main<br>
>> > admin<br>
>> > page. 200 warmup requests, then 100 benchmarked requests, look at the<br>
>> > 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<br>
>> > 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<br>
>> > 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<br>
>> > 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>
><br>
><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><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)<br>"The people's good is the highest law." -- Cicero<br><div>GPG Key fingerprint: 125F 5C67 DFE9 4084</div></div></div>
</div>