Why do frame rate drop in games?

Started by
7 comments, last by SuperG 10 years, 8 months ago

Does it necessarily depend on the platform(console, pc, handheld), the optimizing algorithm is not efficient enough or just the amount of object currently on the screen is too much for the platform too handle?

Just wanted to ask in case, I worked with a different language with a new api where I might run into this issue.

How do I improve frame rate in a game? How many factors is taken into consideration to improve the frame rate.

Advertisement

In general, it is either because:

1. You're doing too much work (rendering or other work) each time around the rendering / or logic loop

OR

2. There are single "slow" actions which are causing one-off slow frames which makes the game jitter in an unpleasant way.

Fixing 1) normally means doing less stuff, i.e. either reducing the complexity of the game, doing better culling, using more efficient drawing (e.g. objects with fewer primitives) or some other optimisation.

Fixing 2) can mean doing some "clever" macro-optimisations such as preloading resources, or doing complex tasks in "chunks" and splitting them between several ticks, to avoid slowing down your main processing.

In general, it is either because:

1. You're doing too much work (rendering or other work) each time around the rendering / or logic loop

OR

2. There are single "slow" actions which are causing one-off slow frames which makes the game jitter in an unpleasant way.

Fixing 1) normally means doing less stuff, i.e. either reducing the complexity of the game, doing better culling, using more efficient drawing (e.g. objects with fewer primitives) or some other optimisation.

Fixing 2) can mean doing some "clever" macro-optimisations such as preloading resources, or doing complex tasks in "chunks" and splitting them between several ticks, to avoid slowing down your main processing.

Interesting answer. Thanks for the heads-up, markr!


Does it necessarily depend on the platform(console, pc, handheld), the optimizing algorithm is not efficient enough or just the amount of object currently on the screen is too much for the platform too handle?

as mentioned above the game can just do too much for the hardware (run slow all the time),or you can have momentary slowdowns during a slow operation, such as paging a resource off disk.

both of these can happen on any platform with any language and any tools. its all caused by you telling the computer to do more than it can do in the time allotted.

momentary slow operations can be split up over multiple frames (think streaming terrain chunks off disk) to spread out the work load over time to avoid the momentary stall.

although its possible to do simulation that slows things down, its usually trying to draw too much on the screen that's the culprit. in some cases it both: graphics plus some contribution from AI that's eating up all your processing power.

the key to improving frame rate, is to do less.

this can be done by:

1. optimization: doing things more efficiently.

2. pre-processing: doing things ahead of time (before release, at load time, etc).

3. splitting slow tasks over multiple frames (streaming terrain chunks, using multiple frames to calculate long A* paths, etc).

4. actually doing less. for example, in a FPS title, design levels so there's never too many bad guys active at once to draw on the screen at 60 fps. if your game engine can only draw 10 bad guys at 60fps, you design the levels so there's never more than say eight active at once. that way you guarantee you're never over-taxing the hardware.


How many factors is taken into consideration to improve the frame rate.

while there are multiple causes (slow CPU, slow hard drive, slow GPU, slow code), the only thing you really care about is elapsed time.

so the first tool in any code optimizer's bag of tricks, after simply inspecting the code for obvious inefficiencies, is a high resolution timer to measure the elapsed time of a section of code in milliseconds, microseconds, or frequency counter ticks.

slow hardware is a challenge to be worked around.

slow code is a problem that needs to be fixed.

simply trying to do to much is a design flaw that should have been identified by means of a rapid prototype to test the scope and requirements of the game vs the target platform's capabilities.

here's a good approach to use for optimization:

1. start with straight forward algos, unless you KNOW it'll be too slow.

2. if you think an algo may be too slow, test it first (rapid prototype). this can be as simple as a little test routine you add to the game to try out this or that to see if it runs fast enough.

3. always think in terms of efficiency (code that runs fast) when coding. try to avoid slow code in time critical areas. if you code with speed in mind, you tend to write more efficient code from the get-go and require less optimization later.

4. when the frame rate drops, break out the timers (or a profiler), and use a divide and conquer strategy to identify bottlenecks. with a profiler, you can time pretty much everything at once and instantly see where all your clock cycles go.

5. once you've identified bottlenecks, optimize that code. the goal is to reduce the time required, both to execute the code, and to move it and the data into and out of the CPU/GPU/RAM/hard drive. this is where things like "cache freindly code" come into play. As a highly specialized type of engineer, gamedevs, like any good engineer, will go to great lengths to attempt to find an engineering solution to the challenge of too much game and too little hardware. at the high end, optimizations can become rather complex, and can required a fair amount of R&D (research and development) work. if you can find it, Michael Abrash's lecture on the optimization of the quake engine at CGDC '96 is quite interesting - all the things they tried.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Because games are or can be very dynamic and event driven. Some events could trigger a compute intensive task.

Experience game devs could take a CPU cycle budged and avoid these extreems. LOD it down as a compromise and optimize it so far they can in time given.

Or some go for a fixed FPS rate. And tweak there game for it. avoid to extreme events.

Example a event a explosion yield some GFX and particle and sound. But if destruction is involved it could scale up depending on generic finegrain physics computing task to teraflops.

You could go from lightweight 200fPS or on fixed 60fps more idle situation. To a slide show.

That's why destruction in games was limited but with each nextgen of games they do it a limited steps each gen a bit more of it.


Because games are or can be very dynamic and event driven. Some events could trigger a compute intensive task.

this is actually the most common cause of slowdowns seen by the end user.

the game only runs slow when things get REALLY busy. so you design the game so things never get too busy for too long.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Thanks guys on the answers

How do I improve frame rate in a game? How many factors is taken into consideration to improve the frame rate.

There is a huge amount of factors that can slow down your performance in a game and it is very hard to catch all of them in a large sized project.

I liked something that the authors of "Game Engine Architecture" said on this subject. "Optimizing 10 percent of your code can give you a boost of 90 percent performance" or something like that (Can't remember the exact thing they said on the subject ;p). Basically what they were saying is if you optimize whatever code is taking the most time to run in your game you can increase your games performance by a huge factor.

So the best way in my mind to find out what you should optimize is to use a good profiler on your game and determine what functions or whatever are taking the most performance. Then start that the bottom (Whatever is clogging down your performance the most) and work your way upwards until you hit your desired performance. Just doing this on t he bottom 10% of your code can have a drastic improvement on your performance.

In my opinion there really is no use trying to optimize all your code to the maximum(Not to be read as you can do things inefficiently) because that would just increase the dev time way to much. Instead just use a profiler and determine where the worst offenders are and optimize them until you get your desired performance.

Well I've read some frases like that. But it also in what contex.
10% how do you choose. I think they also would mention code within the critical path. Also they won't guess but profile so they start with code that is resposible for taking to much time.
It is also in the contex of often dev do not have the time to fully optimise. So they get as much doable within that time.

On frase sounds like this. The fasted code is code that isn't executed.

So after optimizing. If you want to have a steady FPS you make your dynamical load as light to fit in your FPS target. This means that you avoid features in scale that make your proscesing unit to busy.

Wich means if you develop a twitchy FPS shooter gamers don't wont to dip below 60fps in the heat of close combat but even prefere a 3D monitor 120 or 144FPS not using the 3D but the 120 or 144 FPS and trim the settings down to achieve this frame rate without deep dips. More arena sized maps. Coridor games.

Those games wont stand out in the latest GFX and very deep interaction. But they run easier a solid fps target.

While most games with fancy GFX huge worlds deep feature set lot of interaction tend to dip.

Dev can make choice of how dynamical the game computing load can be. Depends on the type of game they are making.

This topic is closed to new replies.

Advertisement