Game Development Reference
In-Depth Information
Management.
The EventManager::VUpdate() takes in a maxMillis parameter
that only lets the Event Manager process for that amount of time. If it goes over that
amount, the rest of the events are queued for the next frame, but it helps ensure that
the Event Manager doesn
(for example, take a particularly long amount of
time, causing a hitch in the frame rate). The cost is that events don
'
t
spike
'
t always get pro-
cessed on the frame they are sent. Most of the time, this isn
t a big deal, but it
becomes possible to starve the Event Manager of CPU time. If you consistently
push more events to the Event Manager than it can handle, the delay between events
will grow until it ' s unmanageable and the poor Event Manager can ' t catch up!
'
Sims Are a Bit More Thoughtful
One of the big spikes in TheSimsMedievalwas the AI update tick. If you had a
Sim in an area with a large amount of expensive objects, the AI tick could cause
the game to visibly hitch. We fixed this issue by spreading the update across
multiple frames, which got rid of the spikes but caused Sims to stand around
and do nothing for a few frames. This was only noticeable on really low-end
machines with a single-core processor and a lot of Sims in the world. The Sims
appeared more
thoughtful,
as if they were considering their actions.
Over-Optimization
Optimization must be done in a triage fashion. Just because you can make an algorithm
10 times faster doesn
'
'
tshowing
up in your profiles. If the algorithm only takes 0.01ms, making it take 0.001ms won ' tdo
you much good. You should only concentrate on the top two or three issues at a time
because those will give you the biggest overall performance gain.
Most of the time when you first run your game through the profiler, you
t mean that you should, especially if this algorithm isn
ll be sur-
prised at which algorithms show up the most. You might be calling an innocent get-
ter function that
'
s doing an inefficient search, or you might be calculating something
in a large loop that you can easily cache. You can often make a big difference in per-
formance with small changes.
The point is, you have to profile your game to see where the performance issues are
and only concentrate on the biggest ones.
'
Parting Thoughts
An important thing to keep in mind when debugging is that computers are at their
core deterministic entities. They don
t do things unless instructions are loaded into
the CPU. This should give you hope, since the bug you seek is always findable.
'
 
 
 
Search WWH ::




Custom Search