Game Performance Optimization Interview

This question has been raised:

You are looking for bottlenecks in your game, but nothing that you change makes the game faster, whether it be something in the GPU or CPU pipeline. Nothing is striking, and slowness seems to be spreading everywhere. What will you do next?

I was embarrassed. Is this a trick? When I fix performances, I always assume that this is the moment when you need to scale everything. I do not think that this is mem alloc, as this manifests itself in the perf processor.

+6
source share
4 answers

I would ask for more information. Slow is a poor indicator of poor performance and is a classification of the symptom, not the symptom itself. For example, you can describe "slow" as:

  • Low frame rate
  • Poor input response
  • High responsiveness and a smooth frame rate, but slow game mechanics (i.e. the player and objects move smoothly, but very slowly).
  • In the case of network games, the apparent network lag

All these problems have different potential causes and solutions:

  • A low but consistent frame rate may be caused by inefficiencies in your game cycle. Just starting your favorite profiler may indicate that a large amount of time is being spent on one particular piece of code. In a game I wrote, for example, I found that low FPS was the result of a bad loop that calculated distances between objects several times without caching. In another game, I found that the data structure that I used to perform a relief search was O(N) , not O(1) (python stdlib ... ick). You cannot diagnose a problem that you do not see, and profiling is the first line of defense.
  • Poor responsiveness can be due to a number of things. If the FPS is high, but the controls are sluggish, the API you use to access the controls can be just bad. Some controllers may have crappy drivers that can kill responsiveness. It could even be your game loop: you can simply not check the input from the controller often enough (you may not check every tick). In one of the above games, I had a problem when certain actions had a delayed effect: you would use an element and the game would respond half a second or so later. It turned out that the problem was caused by the fact that the client made a full round on the server in order to perform the action, make sure that this happened, and wait for the server to broadcast back that this element was used. Simple behavior occurs instantly on the client, eliminating the problem.
  • Slow game mechanics may indicate that game constants are simply not set high enough. If everything is smooth and beautiful, but everything just moves very slowly, it is possible that the default speeds or accelerations were not sufficiently raised.
  • Network latency can be caused by any number of things: the router you are connected to may be unsuccessful, the VPS you are developing may be on a host that is DDoSed, you can use a protocol that is overly (but evenly) chatty, or you just send too much data over the wire. In the part of the modeling software that I wrote in college, the calculations were done on some thick computers in the lab, and the visualizations were done on my MBP in my dorm. It turned out that the huge amount of data that I sent from the laboratory computers to my hostel was enough to overload the cheap network switches in the building and pack the packets, which led to a terrible delay, but a very reasonable output protocol.

So, I think the answer here is for the interviewer to describe the symptoms more fully. @ The answer is very large, but it may be that there is a more subtle problem that requires some persuasion for diagnosis.

+3
source

Perhaps we are talking about more efficient algorithms. Micro-optimization has its limits; you can perfectly optimize the sorting of bubbles, for example, but to get real great acceleration, you invented another sorting algorithm.

In addition, in games you can enter various kinds of adjustable quality / speed factors (or accuracy / speed). Usually in all games there are some settings that change the level of graphic detail.

0
source

You are looking for bottlenecks in your game, but nothing you change makes the game faster, be it something in the GPU pipeline or processor. Nothing dives, and slowness appears to be distributed everywhere.

This is pretty much like the definition of a Uniformly Slow Code . Suppose this really means this (and not some I / O bottleneck or creating unnecessary objects in a loop or some bad choice for data structures or algorithms, etc.).

To make a slow, slow code faster, you usually need to go against good practices, and therefore I usually stop optimizing my code when it is uniformly slow. (I believe that β€œstop optimizing” is not a good response to the interview ...)

One way to speed things up is to determine the appropriate sequence of small operations, put them together in one place, and then manually improve things; sort of "manually inserting" these operations, and then performing simplified simplifications of the code that appears. This requires good intuition, where it can cost, and an excellent understanding of the code involved. This answer calls it grouping and horizontal optimization.

Another thing worth paying attention to if you really have a single, slow code is Andrei Alexandrescu Optimization Tips .

0
source

anecdotal:

I can tell you what the problem is, not knowing the answer to the question, p

inactive directx calls. too many objects. especially bad in some old dx9 games, since dx9 needed to create a new directdraw call for each object. or something like that, the story goes. basically led to the fact that the CPU was expecting downtime for gpu to process all messages.

although it is not a solution to every problem, although it is worth mentioning as an interesting piece of information, p did not see it in other comments.

it almost looks like too many pixel shaders, except that at least gpu works at 100% with mass: D is well suited for frying omelets. (also using occlusion to save performance and then adding a ton of pixel shaders to this model is BAD's idea)

Hope you can see the humor in this, p

0
source

All Articles