Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmarks #127

Open
olls opened this issue Dec 20, 2016 · 20 comments
Open

Benchmarks #127

olls opened this issue Dec 20, 2016 · 20 comments

Comments

@olls
Copy link
Member

olls commented Dec 20, 2016

@TiberiumPY

Things like render time and terrain generation speed.

@ghost
Copy link

ghost commented Dec 20, 2016

@olls but for pypy you don't want to use cProfile..
I'll change it to profile myself.

@olls
Copy link
Member Author

olls commented Dec 20, 2016

I'm not sure what you mean, I'm using the timeit module.

@olls
Copy link
Member Author

olls commented Dec 20, 2016

Use environment variable PYCRAFT_BENCHMARKS=True to enable timings, then also use PYCRAFT_LOGGING_MODES=\[\"benchmarks\"\]

@ghost
Copy link

ghost commented Dec 20, 2016

@olls
cProfile.runctx('game(server_obj, settings, render_c, benchmarks)', globals(), locals(), filename='game.profile')
or it's only for C module?

@olls
Copy link
Member Author

olls commented Dec 20, 2016

The cProfile part was already there. See my last comment to enable the timeit timings.

@ghost
Copy link

ghost commented Dec 20, 2016

@olls ah, ok

@olls
Copy link
Member Author

olls commented Dec 20, 2016

On my machine I get around 0.05 seconds with python renderer, and 0.015 seconds with the C renderer. Which is promising, as there is a lot more space for optimisations in the C.

@ghost
Copy link

ghost commented Dec 20, 2016

@olls and where's resulting log will be located?

@olls
Copy link
Member Author

olls commented Dec 20, 2016

The results are output to pycraft.log, the easiest way to view them is to run tail -f pycraft.log in a second terminal side by side with Pycraft.

@olls
Copy link
Member Author

olls commented Dec 20, 2016

We'll document all this at some point...

@ghost
Copy link

ghost commented Dec 20, 2016

@olls I get render call time ~0.003 seconds
On CPython 3.5 with C module:
0.0025 - 0.0015

So PyPy is actually not that slow compared to C

@ghost
Copy link

ghost commented Dec 20, 2016

But PyPy3 is not that well optimized as PyPy2 is

@olls
Copy link
Member Author

olls commented Dec 20, 2016

So the 0.003 time was with PyPy?

@ghost
Copy link

ghost commented Dec 20, 2016

Yes

@ghost
Copy link

ghost commented Dec 20, 2016

So C is slightly faster

@olls
Copy link
Member Author

olls commented Dec 20, 2016

I don't know much about PyPy, can you not run the C extension in it?

@ghost
Copy link

ghost commented Dec 20, 2016

@olls I can, but it will be slower than on CPython. You want to use CFFI on PyPy instead (it has some parts inside PyPy).
Writing C code in CFFI - just writing C code without Python C API.
CFFI will do primitive types convertation

@olls
Copy link
Member Author

olls commented Dec 20, 2016

OK, it might not be too much work to port our C renderer to CFFI then, we don't use much of the Python API, just to get the data in.

@ghost
Copy link

ghost commented Dec 20, 2016

@olls this is JIT log (you can even see PyPy generated JIT codes and ASM codes):
http://vmprof.com/#/a65c90bc1580025e1383d86a734ac1ce/traces
actually JIT has sped up only 38%

@olls
Copy link
Member Author

olls commented Dec 20, 2016

OK, I'll have to look into PyPy some more. Thanks for your interest in the project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant