ラベル pypy の投稿を表示しています。 すべての投稿を表示
ラベル pypy の投稿を表示しています。 すべての投稿を表示

2015年8月18日火曜日

pypy はえー

(2011/05/04 18:30公開、2015/08/18 2:45 更新)

名前が素敵な PyPy
http://sourceforge.jp/magazine/11/05/02/064241

MacPorts に早速 1.5 来てたので入れて、下記を実行
ここから拝借した)

import sys
import timeit

print (sys.version)
t = timeit.Timer("test.pystone.main()", "import test.pystone")
t.timeit(10)


・Python 2.7.1
2.7.1 (r271:86832, Dec 31 2010, 13:54:06)
[GCC 4.2.1 (Apple Inc. build 5664)]
Pystone(1.1) time for 50000 passes = 0.693661
This machine benchmarks at 72081.3 pystones/second
Pystone(1.1) time for 50000 passes = 0.6901
This machine benchmarks at 72453.3 pystones/second
Pystone(1.1) time for 50000 passes = 0.700685
This machine benchmarks at 71358.7 pystones/second
Pystone(1.1) time for 50000 passes = 0.69343
This machine benchmarks at 72105.3 pystones/second
Pystone(1.1) time for 50000 passes = 0.686145
This machine benchmarks at 72870.9 pystones/second
Pystone(1.1) time for 50000 passes = 0.696792
This machine benchmarks at 71757.4 pystones/second
Pystone(1.1) time for 50000 passes = 0.695822
This machine benchmarks at 71857.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.685601
This machine benchmarks at 72928.7 pystones/second
Pystone(1.1) time for 50000 passes = 0.700942
This machine benchmarks at 71332.6 pystones/second
Pystone(1.1) time for 50000 passes = 0.699862
This machine benchmarks at 71442.7 pystones/second


・PyPy 1.5
2.7.1 (?, May 03 2011, 16:48:00)
[PyPy 1.5.0-alpha0 with GCC 4.0.1]
Pystone(1.1) time for 50000 passes = 0.267667
This machine benchmarks at 186799 pystones/second
Pystone(1.1) time for 50000 passes = 0.068037
This machine benchmarks at 734894 pystones/second
Pystone(1.1) time for 50000 passes = 0.067261
This machine benchmarks at 743373 pystones/second
Pystone(1.1) time for 50000 passes = 0.067966
This machine benchmarks at 735662 pystones/second
Pystone(1.1) time for 50000 passes = 0.067146
This machine benchmarks at 744646 pystones/second
Pystone(1.1) time for 50000 passes = 0.067497
This machine benchmarks at 740774 pystones/second
Pystone(1.1) time for 50000 passes = 0.067191
This machine benchmarks at 744147 pystones/second
Pystone(1.1) time for 50000 passes = 0.07886
This machine benchmarks at 634035 pystones/second
Pystone(1.1) time for 50000 passes = 0.068004
This machine benchmarks at 735251 pystones/second
Pystone(1.1) time for 50000 passes = 0.068635
This machine benchmarks at 728491 pystones/second


現実的なアプリケーションだとどのくらいになるのだろうね。
ここみると、Django は 8倍高速らしい。

2015/8/18 現在は以下 
2.7.10 (default, May 28 2015, 02:30:16)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
Pystone(1.1) time for 50000 passes = 0.452571
This machine benchmarks at 110480 pystones/second
Pystone(1.1) time for 50000 passes = 0.455215
This machine benchmarks at 109838 pystones/second
Pystone(1.1) time for 50000 passes = 0.449152
This machine benchmarks at 111321 pystones/second
Pystone(1.1) time for 50000 passes = 0.450072
This machine benchmarks at 111093 pystones/second
Pystone(1.1) time for 50000 passes = 0.439352
This machine benchmarks at 113804 pystones/second
Pystone(1.1) time for 50000 passes = 0.453671
This machine benchmarks at 110212 pystones/second
Pystone(1.1) time for 50000 passes = 0.451542
This machine benchmarks at 110732 pystones/second
Pystone(1.1) time for 50000 passes = 0.450634
This machine benchmarks at 110955 pystones/second
Pystone(1.1) time for 50000 passes = 0.45061
This machine benchmarks at 110961 pystones/second
Pystone(1.1) time for 50000 passes = 0.461482
This machine benchmarks at 108347 pystones/second

3.4.3 (default, May 25 2015, 18:48:21)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)]
Pystone(1.2) time for 50000 passes = 0.550403
This machine benchmarks at 90842.5 pystones/second
Pystone(1.2) time for 50000 passes = 0.535997
This machine benchmarks at 93284.1 pystones/second
Pystone(1.2) time for 50000 passes = 0.533127
This machine benchmarks at 93786.3 pystones/second
Pystone(1.2) time for 50000 passes = 0.527765
This machine benchmarks at 94739.1 pystones/second
Pystone(1.2) time for 50000 passes = 0.536051
This machine benchmarks at 93274.7 pystones/second
Pystone(1.2) time for 50000 passes = 0.54033
This machine benchmarks at 92536 pystones/second
Pystone(1.2) time for 50000 passes = 0.535856
This machine benchmarks at 93308.7 pystones/second
Pystone(1.2) time for 50000 passes = 0.534745
This machine benchmarks at 93502.5 pystones/second
Pystone(1.2) time for 50000 passes = 0.524912
This machine benchmarks at 95254.1 pystones/second
Pystone(1.2) time for 50000 passes = 0.531086
This machine benchmarks at 94146.7 pystones/second

3.5.0rc1 (default, Aug 16 2015, 06:23:26)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)]
Pystone(1.2) time for 50000 passes = 0.506479
This machine benchmarks at 98720.7 pystones/second
Pystone(1.2) time for 50000 passes = 0.508563
This machine benchmarks at 98316.2 pystones/second
Pystone(1.2) time for 50000 passes = 0.511506
This machine benchmarks at 97750.5 pystones/second
Pystone(1.2) time for 50000 passes = 0.501795
This machine benchmarks at 99642.3 pystones/second
Pystone(1.2) time for 50000 passes = 0.49656
This machine benchmarks at 100693 pystones/second
Pystone(1.2) time for 50000 passes = 0.49607
This machine benchmarks at 100792 pystones/second
Pystone(1.2) time for 50000 passes = 0.478405
This machine benchmarks at 104514 pystones/second
Pystone(1.2) time for 50000 passes = 0.482465
This machine benchmarks at 103634 pystones/second
Pystone(1.2) time for 50000 passes = 0.491406
This machine benchmarks at 101749 pystones/second
Pystone(1.2) time for 50000 passes = 0.484606
This machine benchmarks at 103177 pystones/second

2.7.9 (295ee98b69288471b0fcf2e0ede82ce5209eb90b, Jun 02 2015, 07:48:49)
[PyPy 2.6.0 with GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)]
Pystone(1.1) time for 50000 passes = 0.044237
This machine benchmarks at 1.13028e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.011606
This machine benchmarks at 4.30812e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.011401
This machine benchmarks at 4.38558e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.010419
This machine benchmarks at 4.79893e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.011264
This machine benchmarks at 4.43892e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.012208
This machine benchmarks at 4.09567e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.01142
This machine benchmarks at 4.37828e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.013389
This machine benchmarks at 3.73441e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.010013
This machine benchmarks at 4.99351e+06 pystones/second
Pystone(1.1) time for 50000 passes = 0.011098
This machine benchmarks at 4.50532e+06 pystones/second

PyPy 関連

ぐぐってみただけ。

そうだ! EuroPython 2011へ行こう - #3 PyPyについての講演,ハンズオン,スプリント
http://gihyo.jp/news/report/01/europython2011/0003

PyPyに関する論文、というのはこれかな?
Tracing the meta-level: PyPy's tracing JIT compiler
http://dl.acm.org/citation.cfm?id=1565827

DjangoAndPyPy
https://code.djangoproject.com/wiki/DjangoAndPyPy
↑からリンクあるけども Django のテンプレートエンジンでの性能比較
http://speed.pypy.org/timeline/?ben=django

PyPy Compatibility
https://bitbucket.org/pypy/compatibility/wiki/Home


Django のドキュメントでは、どうも1.7からは topicsに Performance and optimization というのが設けられ、 Alternative software implementations 項に PyPy についての記述があるようだ。1.7 は 2014年9月にでてた。

記載されてるくらいなので、今利用することはそれほど奇をてらったものではないのかな。

https://docs.djangoproject.com/en/1.7/topics/

https://docs.djangoproject.com/en/1.7/topics/performance/#alternative-software-implementations


2015年8月10日月曜日

PyPy

本番に導入した事例があるようだ。

前勤めていた会社でも Python やら Django やらつかっていて、技術的に濃いところを知ってるプログラマさんが「PyPy どうだろうねー」と言っていたことがあった(2011~2012年くらい)。

その基本構成は 2009年末頃からさほど変わっていなかったので、「ウェブオペレーション」にもある




"常に5年後の計画を作るということだ。「今のソリューションは5年後も大丈夫か?」と自問自答しよう(以下略"

という教訓の通り、今もなおその構成が健在かつトラフィックが増してるなどして性能がプアで悩ましい状況が生まれていたとしたらちょうどいい解決策かも、と思った。
(まぁちゃんと計画してるんなら別の言語にしてるのだろうが・・・)

なので興味津津。

当時の PyPy, PyMySQL, uWSGI の状況は覚えてないけども「ちょっくらためしてみるか」と思えるほど整ってなかったかな。

2.5倍とかくと「おぉ〜」と思い、250%とかくと「まじで!?すごーーーーい」と思える。なんとなく。

PyPy's Speed Center
みると The geometric average of all benchmarks is 0.14 or 7.1 times faster than CPython とある。
 
感想としては
・お手伝い先の中の人の経験値になってるのかはなんとなく気になる(まるっとお手伝い元さんの成果だと評価されないんだろうな、とか今後の改善つらいのかなとか、その後の運用とかとか)
・開発環境はどうしてるかしら
・プロファイリングや種々の取り組み方などなどもきになる
・「Python アプリと言っても JSON 受け取ったり戻したりするウェブアプリなので、たいした構成では無い。」
から
「かなり複雑で巨大なWebアプリケーション、ユーザ数は 100 万以上。」となってるので、当初から適用箇所かわったのかな。

とか、

・Instagram や Pinterest のその後の構成が気になってきた
Pinterest は 2011年では 'heavyly-modified' Django だったり Tornado つかってたりする。
http://www.quora.com/What-is-the-technology-stack-behind-Pinterest-1
Instagram 3年前は: http://instagram-engineering.tumblr.com/post/13649370142/what-powers-instagram-hundreds-of-instances
Disqus もたしか Django 使っている(いた?)ような。 
・Dropbox の pyston どうなってるのかしら
・同じノリ(?)でクックパッドさんが Rubinius にしたらどうなるのか
(そもそも PyPy の目指すところと Rubinius の目指すところが似てるのかすら知らないけど)

ちょいとぐぐってみると Quora が PyPy 使ってたらしき記事をみたけど、その後使わなくなってた。今は不明。http://www.quora.com/Is-Quora-still-running-on-PyPy
"The main reason for not switching to PyPy is its performance: in our case CPython + Cython version is noticeably faster (at least currently)." と。Django 絡んでなさそうな気がする。

そういやちょっと前に Cython 本、日本語版でてたね。