pycraft icon indicating copy to clipboard operation
pycraft copied to clipboard

Benchmarks

Open olls opened this issue 9 years ago • 20 comments

@TiberiumPY

Things like render time and terrain generation speed.

olls avatar Dec 20 '16 16:12 olls

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

ghost avatar Dec 20 '16 17:12 ghost

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

olls avatar Dec 20 '16 17:12 olls

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

olls avatar Dec 20 '16 17:12 olls

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

ghost avatar Dec 20 '16 17:12 ghost

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

olls avatar Dec 20 '16 17:12 olls

@olls ah, ok

ghost avatar Dec 20 '16 17:12 ghost

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.

olls avatar Dec 20 '16 17:12 olls

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

ghost avatar Dec 20 '16 17:12 ghost

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 avatar Dec 20 '16 17:12 olls

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

olls avatar Dec 20 '16 17:12 olls

@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 avatar Dec 20 '16 17:12 ghost

But PyPy3 is not that well optimized as PyPy2 is

ghost avatar Dec 20 '16 17:12 ghost

So the 0.003 time was with PyPy?

olls avatar Dec 20 '16 17:12 olls

Yes

ghost avatar Dec 20 '16 17:12 ghost

So C is slightly faster

ghost avatar Dec 20 '16 17:12 ghost

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

olls avatar Dec 20 '16 17:12 olls

@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

ghost avatar Dec 20 '16 17:12 ghost

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.

olls avatar Dec 20 '16 17:12 olls

@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%

ghost avatar Dec 20 '16 17:12 ghost

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

olls avatar Dec 20 '16 18:12 olls