Tuesday, 29 December 2009

Developer Journal 2

I disabled the glReadPixels() part but kept the array copying part:

agent.UpdateBrain() // 27%
- brain.Update() // 13%

This indicated that there was something expensive happening inside agent.UpdateBrain() that was taking up 14% of processing time. For a while, I thought that the 14% was due to the array copying part in agent.UpdateBrain(). However, I had misread the profiling information.

To get the figure, 13%, for brain.Update(), I took the processing time taken up by children functions of brain.Update() and divided by the total processing time. However, I accidentally left out the processing time by brain.Update() itself.

I re-enabled the array copying part, but this time I made sure to read the profiling information correctly:

agent.UpdateBrain() // 39%
- brain.Update() // 37%

I disabled the array copying part just to make sure:

agent.UpdateBrain() // 39%
- brain.Update() // 37%

I could now be sure that the array copying part in agent.UpdateBrain() was taking up very little time.

index   time   self   children   called   name

[4] 40.1 0.23 167.77 10001 TSimulation::UpdateCritters()

  • 'index' is the identification number of your function
  • 'time' is the percentage of time your program spends in your function
  • 'self' is the number of seconds your program spends in your function, not counting the number of seconds in children functions
  • 'children' is the number of seconds your program spends in children functions
  • 'name' is the name of your function
So now that I could move past looking at the array copying part, I could profile the code with the glReadPixels() part re-enabled.

[6] 39.8 0.04 5.18 35327 critter::UpdateBrain() [6]
2.51 2.67 35327/35327 brain::Update(float) [7]

glReadPixels() occurs in critter::UpdateBrain(). I've been thinking for a while that glReadPixels() was causing a lot of slow down but really the slow down was because of brain::Update().

So that leaves 3 places for improving performance: neural network update, drawing and agent communication.

Simple ways to improve drawing performance are to use a frustum and to switch from display lists to vertex buffers.

A simple way to improve agent communication is to use a spatial data structure.

No comments:

Post a Comment