You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: posts/2017/10/how-to-make-your-code-80-times-faster-1424098117108093942.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@
72
72
Generation 4: ... [population = 500] [33.75 secs]
73
73
</pre>
74
74
Ouch! We are ~5.5x slower than CPython. This was kind of expected: numpy is
75
-
based on cpyext, which is infamously slow. (Actually, <aclass="reference external" href="https://morepypy.blogspot.it/2017/10/cape-of-good-hope-for-pypy-hello-from.html">we are working on
75
+
based on cpyext, which is infamously slow. (Actually, <aclass="reference external" href="https://pypy.org/posts/2017/10/cape-of-good-hope-for-pypy-hello-from-3656631725712879033.html">we are working on
76
76
that</a> and on the <ttclass="docutils literal"><spanclass="pre">cpyext-avoid-roundtrip</span></tt> branch we are already faster than
77
77
CPython, but this will be the subject of another blog post.)<br>
turned out that those things then have to be implemented, which can be called
186
186
the first thing we learned: if you promise something to the EU, you'll have to
187
187
actually go do it (After the funding ended, a lot of these features were
188
-
actually removed from the project again, at a <aclass="reference external" href="https://morepypy.blogspot.com/2007/11/sprint-pictures.html">cleanup sprint</a>).</p>
188
+
actually removed from the project again, at a <aclass="reference external" href="https://www.pypy.org/posts/2007/11/sprint-pictures.html">cleanup sprint</a>).</p>
feedback. Runtime feedback is most commonly used to know something about which
330
330
concrete types are used by a program in practice. Promote is basically a way to
331
331
easily introduce runtime feedback into the JIT produced by the JIT generator.
332
-
It's an <aclass="reference external" href="https://morepypy.blogspot.com/2011/03/controlling-tracing-of-interpreter-with_15.html">annotation</a> the implementer of a language can use to express their wish
332
+
It's an <aclass="reference external" href="https://www.pypy.org/posts/2011/03/controlling-tracing-of-interpreter-with_15.html">annotation</a> the implementer of a language can use to express their wish
333
333
that specialization should happen at <em>this</em> point. This mechanism can be used to
334
-
express <aclass="reference external" href="https://morepypy.blogspot.com/2011/03/controlling-tracing-of-interpreter-with_21.html">all kinds of</a> runtime feedback, moving values from the interpreter
334
+
express <aclass="reference external" href="https://www.pypy.org/posts/2011/03/controlling-tracing-of-interpreter-with_21.html">all kinds of</a> runtime feedback, moving values from the interpreter
335
335
into the compiler, whether they be types or other things.</p>
336
336
</div>
337
337
@@ -387,7 +387,7 @@ <h1><a class="toc-backref" href="#id28">2007: RSqueak and other languages</a></h
387
387
machine in RPython, and at the end of the week we'd gotten surprisingly far with
388
388
that goal. Basically most of the bytecodes and the Smalltalk object system
389
389
worked, we had written an image loader and could run some benchmarks (during the
390
-
sprint we also regularly updated a <aclass="reference external" href="https://pypysqueak.blogspot.com/">blog</a>, the success of which led us to <aclass="reference external" href="https://morepypy.blogspot.com/2007/10/first-post.html">start</a>
390
+
sprint we also regularly updated a <aclass="reference external" href="https://pypysqueak.blogspot.com/">blog</a>, the success of which led us to <aclass="reference external" href="https://www.pypy.org/posts/2007/10/first-post.html">start</a>
observing and logging the execution of the running program. This yields a
455
455
straight-line trace of operations, which are then optimized and compiled into
456
456
machine code. Of course most tracing systems mostly focus on tracing loops.</p>
457
-
<p>As we discovered, it's actually quite simple to <aclass="reference external" href="https://morepypy.blogspot.com/2009/03/applying-tracing-jit-to-interpreter.html">apply a tracing JIT to a generic
457
+
<p>As we discovered, it's actually quite simple to <aclass="reference external" href="https://www.pypy.org/posts/2009/03/applying-tracing-jit-to-interpreter.html">apply a tracing JIT to a generic
458
458
interpreter</a>, by not tracing the execution of the user program directly, but by
459
459
instead tracing the execution of the interpreter while it is running the user
460
460
program (here's the <aclass="reference external" href="https://foss.heptapod.net/pypy/extradoc/-/blob/branch/default/default/talk/icooolps2009/bolz-tracing-jit-final.pdf">paper</a> we wrote about this approach).</p>
members had other sources of funding). But again, while we did the work it
498
498
became clear that to get an actually working fast PyPy with generated JIT we
499
499
would need actual funding again for the project. So we applied to the EU again,
500
-
this time for a much smaller project with less money, in the <aclass="reference external" href="https://morepypy.blogspot.com/2010/12/oh-and-btw-pypy-gets-funding-through.html">Eurostars</a>
500
+
this time for a much smaller project with less money, in the <aclass="reference external" href="https://www.pypy.org/posts/2010/12/oh-and-btw-pypy-gets-funding-through.html">Eurostars</a>
501
501
framework. We got a grant for three participants, <aclass="reference external" href="https://merlinux.eu/">merlinux</a>, <aclass="reference external" href="https://www.openend.se/">OpenEnd</a> and Uni
502
502
Düsseldorf, on the order of a bit more than half a million euro. That money was
503
503
specifically for JIT development and JIT testing infrastructure.</p>
@@ -574,7 +574,7 @@ <h1><a class="toc-backref" href="#id36">2010: Implementing Python Objects with M
574
574
Javascript objects, in that you can add arbitrary attributes to them at runtime.
575
575
Originally Python instances were backed by a dictionary in PyPy, but of course
576
576
in practice most instances of the same class have the same set of attribute
577
-
names. Therefore we went and implemented <aclass="reference external" href="https://morepypy.blogspot.com/2010/11/efficiently-implementing-python-objects.html">Self style maps</a>, which are often
577
+
names. Therefore we went and implemented <aclass="reference external" href="https://www.pypy.org/posts/2010/11/efficiently-implementing-python-objects.html">Self style maps</a>, which are often
578
578
called <aclass="reference external" href="https://richardartoul.github.io/jekyll/update/2015/04/26/hidden-classes.html">hidden classes</a> in the JS world to represent instances instead. This
579
579
has two big benefits, it allows you to generate much better machine code for
580
580
instance attribute access and makes instances use a lot less memory.</p>
observation about how those are used is that in a significant percentage of
590
590
cases they contain type-homogeneous data. As an example it's quite common to
591
591
have lists of only integers, or lists of only strings. So we changed the list,
592
-
dict and set implementations to use something we called <aclass="reference external" href="https://morepypy.blogspot.com/2011/10/more-compact-lists-with-list-strategies.html">storage strategies</a>. With
592
+
dict and set implementations to use something we called <aclass="reference external" href="https://www.pypy.org/posts/2011/10/more-compact-lists-with-list-strategies.html">storage strategies</a>. With
593
593
storage strategies these data structures use a more efficient representations if
594
594
they contain only primitives of the same type, such as ints, floats, strings.
595
595
This makes it possible to store the values without boxing them in the underlying
@@ -626,7 +626,7 @@ <h1><a class="toc-backref" href="#id39">JIT Status 2011</a></h1>
626
626
<p>So, here we are at the end of the Eurostars project, what's the status of the JIT? Well, it
627
627
seems this meta-tracing stuff really works! We finally started actually
628
628
believing in it, when we reached the point in 2010 where self-hosting PyPy was
629
-
actually <aclass="reference external" href="https://morepypy.blogspot.com/2010/11/snake-which-bites-its-tail-pypy-jitting.html">faster</a> than bootstrapping the VM on CPython. Speeding up the
629
+
actually <aclass="reference external" href="https://www.pypy.org/posts/2010/11/snake-which-bites-its-tail-pypy-jitting.html">faster</a> than bootstrapping the VM on CPython. Speeding up the
630
630
bootstrapping process is something that Psyco never managed at all, so we
631
631
considered this a quite important achievement. At the end of
632
632
Eurostars, we were about 4x faster than CPython on our set of benchmarks.</p>
@@ -641,17 +641,17 @@ <h1><a class="toc-backref" href="#id40">2012-2017: Engineering and Incremental P
641
641
Conservancy</a> and contracts of various sizes from companies to implement various
642
642
specific features, often handled by <aclass="reference external" href="https://baroquesoftware.com/">Baroque Software</a>. Over the next couple of
643
643
years
644
-
we revamped various parts of the VM. We improved the GC in <aclass="reference external" href="https://morepypy.blogspot.com/2013/10/incremental-garbage-collector-in-pypy.html">major</a> ways. We
645
-
optimized the implementation of the JIT compiler to improve <aclass="reference external" href="https://morepypy.blogspot.com/2015/10/pypy-memory-and-warmup-improvements-2.html">warmup</a><aclass="reference external" href="https://morepypy.blogspot.com/2016/04/warmup-improvements-more-efficient.html">times</a>. We
646
-
implemented backends for various CPU architectures (including <aclass="reference external" href="https://morepypy.blogspot.com/2015/10/powerpc-backend-for-jit.html">PowerPC</a> and
647
-
<aclass="reference external" href="https://morepypy.blogspot.com/2016/04/pypy-enterprise-edition.html">s390x</a>). We tried to reduce the number of performance cliffs and make the JIT
644
+
we revamped various parts of the VM. We improved the GC in <aclass="reference external" href="https://www.pypy.org/posts/2013/10/incremental-garbage-collector-in-pypy.html">major</a> ways. We
645
+
optimized the implementation of the JIT compiler to improve <aclass="reference external" href="https://www.pypy.org/posts/2015/10/pypy-memory-and-warmup-improvements-2.html">warmup</a><aclass="reference external" href="https://www.pypy.org/posts/2016/04/warmup-improvements-more-efficient.html">times</a>. We
646
+
implemented backends for various CPU architectures (including <aclass="reference external" href="https://www.pypy.org/posts/2015/10/powerpc-backend-for-jit.html">PowerPC</a> and
647
+
<aclass="reference external" href="https://www.pypy.org/posts/2016/04/pypy-enterprise-edition.html">s390x</a>). We tried to reduce the number of performance cliffs and make the JIT
648
648
useful in a broader set of cases.</p>
649
649
<p>Another strand of work was to push quite significantly to be more
650
650
compatible with CPython, particularly the Python 3 line as well as extension
651
651
module support. Other compatibility improvements we did was making sure that
652
-
virtualenv <aclass="reference external" href="https://morepypy.blogspot.com/2010/08/using-virtualenv-with-pypy.html">works with PyPy</a>, better support for distutils and setuptools and
652
+
virtualenv <aclass="reference external" href="https://www.pypy.org/posts/2010/08/using-virtualenv-with-pypy.html">works with PyPy</a>, better support for distutils and setuptools and
653
653
similar improvements. The continually improving performance as well better
654
-
compatibility with the ecosystem tools led to the <aclass="reference external" href="https://morepypy.blogspot.com/2014/10/couchbase-contribution-to-pypy.html">first few</a><aclass="reference external" href="https://baroquesoftware.com/blog#interview-with-roberto_de_ioris">users</a> of PyPy in
654
+
compatibility with the ecosystem tools led to the <aclass="reference external" href="https://www.pypy.org/posts/2014/10/couchbase-contribution-to-pypy.html">first few</a><aclass="reference external" href="https://baroquesoftware.com/blog#interview-with-roberto_de_ioris">users</a> of PyPy in
that a lot of people need specific C-extension modules at least in some parts of
664
664
their program, and telling them to reimplement everything in Python is just not
665
665
a practical solution. Therefore we worked on CPyExt, an emulation layer to make
666
-
it possible to run <aclass="reference external" href="https://morepypy.blogspot.com/2010/04/using-cpython-extension-modules-with.html">CPython C-extension modules</a> in PyPy. Doing that was a very
666
+
it possible to run <aclass="reference external" href="https://www.pypy.org/posts/2010/04/using-cpython-extension-modules-with.html">CPython C-extension modules</a> in PyPy. Doing that was a very
667
667
<aclass="reference external" href="https://www.youtube.com/watch?v=qH0eeh-4XE8">painful process</a>, since the CPython extension API leaks a lot of CPython
668
668
implementation details, so we had to painstakingly emulate all of these details
669
669
to make it possible to run extensions. That this works at all remains completely
670
670
amazing to me! But nowadays CPyExt is even getting quite good, a lot of the big
671
-
numerical libraries such as Numpy and <aclass="reference external" href="https://morepypy.blogspot.com/2017/10/pypy-v59-released-now-supports-pandas.html">Pandas</a> are now supported (for a while
671
+
numerical libraries such as Numpy and <aclass="reference external" href="https://www.pypy.org/posts/2017/10/pypy-v59-released-now-supports-pandas.html">Pandas</a> are now supported (for a while
672
672
we had worked hard on a reimplementation of Numpy called NumPyPy, but
673
673
eventually realized that it would never be complete and useful enough).
674
674
However, calling CPyExt modules from PyPy can still be very slow,
675
675
which makes it impractical for some applications
676
-
that's why we are <aclass="reference external" href="https://morepypy.blogspot.com/2017/10/cape-of-good-hope-for-pypy-hello-from.html">working</a> on it.</p>
676
+
that's why we are <aclass="reference external" href="https://www.pypy.org/posts/2017/10/cape-of-good-hope-for-pypy-hello-from.html">working</a> on it.</p>
677
677
<p>Not thinking about C-extension module emulation earlier in the project history
678
678
was a pretty bad strategic mistake. It had been clear for a long time that
679
679
getting people to just stop using all their C-extension modules was never going
focus of the last couple of years has been to catch up with the CPython 3 line.
692
692
Originally we had ignored Python 3 for a little bit too long, and were trailing
693
-
several versions behind. In 2016 and 2017 we had a <aclass="reference external" href="https://morepypy.blogspot.com/2016/08/pypy-gets-funding-from-mozilla-for.html">grant</a> from the Mozilla open
693
+
several versions behind. In 2016 and 2017 we had a <aclass="reference external" href="https://www.pypy.org/posts/2016/08/pypy-gets-funding-from-mozilla-for.html">grant</a> from the Mozilla open
694
694
source support program of $200'000 to be able to catch up with Python 3.5. This
695
695
work is now basically done, and we are starting to target CPython 3.6 and will
0 commit comments