use as benchmark pypy vs python if you please
Attached is nqueens solver (pardon my naive algorithm), it runs: python 2.7.6: 17s pypy 2.4.0 alpha: 23s same nojit: 32s I've tried similarlooking algorithm for another problem before, and has similar results  somehow pypy was slower. feel free to investigate / tweak or even use on speed.pypy.org
Hi Dima, On Mon, Aug 4, 2014 at 5:04 PM, Dima Tisnek <dimaqq@gmail.com> wrote:
Attached is nqueens solver (pardon my naive algorithm), it runs: python 2.7.6: 17s pypy 2.4.0 alpha: 23s same nojit: 32s
I've tried similarlooking algorithm for another problem before, and has similar results  somehow pypy was slower.
feel free to investigate / tweak or even use on speed.pypy.org
So, it took us more than one year, but now I finally figured it out. The reason it is slower in PyPy is because sets recompute the items' hash much more often than in CPython. I fixed it in the branch 'keys_with_hash' (which is just too late for pypy 2.6.1). Some microbenchmarks are 2x or 3x faster now. In your code, it shows up as the _diff() function, which returns "a  b" where a and b are sets of complicated objects. Actually, there are always disjoint sets, so the original code might be a bit buggy :) But the _diff() operation is now twice faster. I get the following times on your nq.py example: python 2.7.3: 15.5s pypy 2.6.1 in keys_with_hash: 10.9s same with 'jit off': 20.3s A bientôt, Armin.
i am just testing a n_queen solver, yesterday with 2.6.1 vs Nodejs. The code i tested is from https://github.com/chaddotson/puzzles But pypy is much faster as nqueen grows . And it is 40% faster than nodejs. In smaller numbers < 10 it is slower but it has to do with JIT Warmup right? (pypycurrent)~/g/nqueenbenchmark >>> python python_n_queens_solver.py 13 NQueens Found 73712 Solutions in 94.664358s on a 13x13 board (pypycurrent)~/g/nqueenbenchmark >>> pypy python_n_queens_solver.py 13 NQueens Found 73712 Solutions in 5.488652s on a 13x13 board (pypycurrent)~/g/nqueenbenchmark >>> node javascript_n_queens_solver.js 13 ⏎ NQueens Found 73712 solutions in 7.112s on a 13x13 board On Tue, Sep 1, 2015 at 5:58 PM, Armin Rigo <arigo@tunes.org> wrote:
Hi Dima,
On Mon, Aug 4, 2014 at 5:04 PM, Dima Tisnek <dimaqq@gmail.com> wrote:
Attached is nqueens solver (pardon my naive algorithm), it runs: python 2.7.6: 17s pypy 2.4.0 alpha: 23s same nojit: 32s
I've tried similarlooking algorithm for another problem before, and has similar results  somehow pypy was slower.
feel free to investigate / tweak or even use on speed.pypy.org
So, it took us more than one year, but now I finally figured it out. The reason it is slower in PyPy is because sets recompute the items' hash much more often than in CPython. I fixed it in the branch 'keys_with_hash' (which is just too late for pypy 2.6.1). Some microbenchmarks are 2x or 3x faster now.
In your code, it shows up as the _diff() function, which returns "a  b" where a and b are sets of complicated objects. Actually, there are always disjoint sets, so the original code might be a bit buggy :) But the _diff() operation is now twice faster. I get the following times on your nq.py example:
python 2.7.3: 15.5s pypy 2.6.1 in keys_with_hash: 10.9s same with 'jit off': 20.3s
A bientôt,
Armin. _______________________________________________ pypydev mailing list pypydev@python.org https://mail.python.org/mailman/listinfo/pypydev
Forgot to add , they are different code and there is no Set operation , so might not be related.
PyPy warmup is quite slow, so very very likely On Fri, Sep 11, 2015 at 12:26 PM, Phyo Arkar <phyo.arkarlwin@gmail.com> wrote:
i am just testing a n_queen solver, yesterday with 2.6.1 vs Nodejs.
The code i tested is from https://github.com/chaddotson/puzzles
But pypy is much faster as nqueen grows . And it is 40% faster than nodejs.
In smaller numbers < 10 it is slower but it has to do with JIT Warmup right?
(pypycurrent)~/g/nqueenbenchmark >>> python python_n_queens_solver.py 13 NQueens Found 73712 Solutions in 94.664358s on a 13x13 board (pypycurrent)~/g/nqueenbenchmark >>> pypy python_n_queens_solver.py 13 NQueens Found 73712 Solutions in 5.488652s on a 13x13 board (pypycurrent)~/g/nqueenbenchmark >>> node javascript_n_queens_solver.js 13 ⏎ NQueens Found 73712 solutions in 7.112s on a 13x13 board
On Tue, Sep 1, 2015 at 5:58 PM, Armin Rigo <arigo@tunes.org> wrote:
Hi Dima,
On Mon, Aug 4, 2014 at 5:04 PM, Dima Tisnek <dimaqq@gmail.com> wrote:
Attached is nqueens solver (pardon my naive algorithm), it runs: python 2.7.6: 17s pypy 2.4.0 alpha: 23s same nojit: 32s
I've tried similarlooking algorithm for another problem before, and has similar results  somehow pypy was slower.
feel free to investigate / tweak or even use on speed.pypy.org
So, it took us more than one year, but now I finally figured it out. The reason it is slower in PyPy is because sets recompute the items' hash much more often than in CPython. I fixed it in the branch 'keys_with_hash' (which is just too late for pypy 2.6.1). Some microbenchmarks are 2x or 3x faster now.
In your code, it shows up as the _diff() function, which returns "a  b" where a and b are sets of complicated objects. Actually, there are always disjoint sets, so the original code might be a bit buggy :) But the _diff() operation is now twice faster. I get the following times on your nq.py example:
python 2.7.3: 15.5s pypy 2.6.1 in keys_with_hash: 10.9s same with 'jit off': 20.3s
A bientôt,
Armin. _______________________________________________ pypydev mailing list pypydev@python.org https://mail.python.org/mailman/listinfo/pypydev
_______________________________________________ pypydev mailing list pypydev@python.org https://mail.python.org/mailman/listinfo/pypydev
participants (4)

Armin Rigo

Dima Tisnek

Maciej Fijalkowski

Phyo Arkar