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

Optimize world.py using Cython. #36

Merged
merged 1 commit into from
Apr 7, 2013
Merged

Conversation

BertrandBordage
Copy link
Collaborator

Voilà, some static typing.

I chose to do this on world.py because this file contains what consumes most CPU (apart from pyglet).

According to cProfile, during the same in-game time (60 seconds of rendered game), and on the same (large) world, while flying on different directions to force hundreds of sectors to load and unload, and with VISIBLE_SECTORS_RADIUS = 16 and DRAW_DISTANCE = 120.0:

what was taking time:

  • pyglet.graphics.Batch.add
  • World.add_block during initialization
  • World.is_exposed during game

Model.initialize:

  • took 17 seconds, with 11.5 seconds taken by World.add_block
  • now takes 10 seconds, with 4.7 seconds taken by World.add_block

during game:

  • pyglet.graphics.Batch.add took and still takes 23 seconds.
  • World.is_exposed took 25 seconds
  • World.is_exposed now takes 19 seconds
  • Displaying 3D, labels, and sleeping takes 80% of the rest of the time

For now, I think that the main part of the game is enough optimized. Of course, there is still some little annoying freezes, but they are mainly due to a bad synchronization between the rendering and the queue. I'll work on that later.

So this is good news, because even when asking hundreds/thousands of chunks updates to the game in one minute, we still have 8.5 % of the time that is spent sleeping.

When doing nothing, 57 % of the time is spent sleeping!

So have fun and develop lots of outstanding features, performance will follow :)

@boskee boskee merged commit d0abf8a into boskee:master Apr 7, 2013
@BertrandBordage BertrandBordage mentioned this pull request Apr 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants