Game development studying Whole by Maxim Zavadskiy: Game Programming Basics 2 : week 4: Profiling using SlimTune

week 4: Profiling using SlimTune

Posted by Maxim Zavadskiy on 14 January 2012, 10:04 PM

14.01

21:14

The topic of 4th week seems to be more or less interesting, I think I have never done this in my programmer's experience. Also a note about video game optimization attracts me. So let's see what's there!

Video lecture

Introduction: From there I got that it's quite useful this profiling. I think it's especially good for optimization of big projects with big resource consuming. I'm remembering my ACM-contest that are about algorithms and data structures. There things is that not only the time(usually 2s) of execution but also memory was limited but the inputs were huge. So clever data structures and algos are needed to fit these limitations. Well actually I have never used profiling there though some of competitors do.

Hm If I'm not wrong in the definition of profiling given on the lecture debugging  also fits. Should it?

Ways of doing profile: well for me that's quite evident that we can use both. Or some tools offer one only? And yes, why we simply cant output needed info, e.g. memory use, all the time? We could use that during testing phase, when we play the game we develop and see at which moment it ates the memory.

Why profiling?: Good reasons were provided but for me it would be also strong argument that we should use this in case of big resource-consuming cases. oh Well actually many of modern games are such:)

When to profile?: I see the time that profiling takes is nothing compared to time to fix all the problems found. But first of all the developer should do the project from the beginning in such way that no optimization will be needed. I don't have enough experience if it can be in real live but at lest everyone should try. It's easier to do smth while it's hot and not e.g select non-efficient algorithms because efficient one is easier to implement and then to hope that it all will work fine. The same situation was described on Source code documenting.

Why profiling? I didn't understand why we need the program to be balanced in a way that frequency of each method call should be about the same? Probably I just didn't get it right what the lecturer says. Also can we actually see how frequently each method/object is used with dynamic call trees/graphs?

Calling context trees: So for the same function we have there separate node for each call of it. But won't it be inconvenient to see which nodes are related to the same function. At all, what kind of picture/info we get as an output from the profiling tool for those trees/graphs? Would be nice to look at it in the lecture but I hope I will have an opportunity when I will do my task.

Execution statistics: So these statistics can be collected during the run of the program? Then we have to get memory use and time use at each moment of execution. It differs from those two ways that were given in Introduction. Does this way have it's own name?

Execution flow: So how it's different from e.g. call graph? Do we get here just a list of function called?

Event-based profiler: C++ was not in the list of languages that have a profiler build-in. And I haven't seen that in C++ standard. But I am sure that some profiles exist with support of C++.

Statistical providers: Yes I was things about the fact that profiles can consume themselves a lot of resources. How they work actually? Should the profiler usually be built-in the project in order to work? But then the would be difficulties with memory and performance monitoring because the profiler use the memory and CPU too. Or it's probably is run as a separate process which interacts with the process of the program. But anyway I think the interaction will decrease the performance of the program so we won't get real results. It would be interesting to understand how it's actually done to get the correct results.

Simulators: so yes now I see that there're two ways: either to inject the profiler in the code or to run it separately. But Simulators I suspect is from another categorization that e.g. statistical provider. Statistical provider e.g. can be simulator, right?

Hm. but where is practical lecture that was mentioned in the end of the lecture? I haven't found anything. OK, I will see tomorrow.

22:47

19.01

15:43

Reading Articles

I found two interesting looking articles in the Material section of this week. I will go through them..

1."The Top 10 Myths of Video Game Optimization" (http://www.gamasutra.com/view/feature/1879/the_top_10_myths_of_video_game_.php?print=1)

The language used there is quite uneasy to read but the article seems to be helpful. The first myth touched interesting problem - when to optimize? Probably I remember not clear the lecture since 5 days passed but there was probably mentioned that the optimization is usually done in the end,But I read from the article that the optimization of micro level(amount lines of code) should be done closer to the end but not of Application and System levels. In the article wasn't explained that much why it is good to do so but one of the reason I got is that these last two levels are about hardware and class - structure so it's related also to design phase.

The article was a bit too professional for me to be honest and there were used such concepts that I haven't hear about. But the article worths reading. There was mentioned all the way that the main purpose of VGO is to increase Frame Rate. I'm not sure if that's true. Firstly the FR can differ from one moment of the game to another and at one moment it might be really slow and at another - really fast. I am sure that it's better to try to have monotonous FR during the game but that is not that related to the question. But what about game/level load time vs FR? I am not sure that all people would like the game that loads for 30 minutes but have extremely low FR. Well, probably I know to few about CPU and GPU work in Games to discuss that. But the good thing in that article is that the myths were related also to optimization in general.

2. " Profiling, Data Analysis, Scalability, and Magic Numbers: Meeting the Minimum Requirements for Age of Empires II: The Age of Kings" - http://www.gamasutra.com/view/feature/3137/profiling_data_analysis_.php

Should be interesting - real example of well known game! But to my embarassing I never played that game though many advised it much. I should certainly do that because I like good stategies. I hope the AI will be good enough.

" In these cases, we fixed the problem by capping the number of times the code could be called by other systems or by capping the amount of time the code could spend executing. " - here I was confused. How it is possible to limit e.g. number of times of function call by the system? If in some code that function must be called say 5 times how it is possible to force it to call it 3 times without affecting that code?

"And since performance profiling and logging significantly slowed game play, analyzing recorded games was a much better solution from the tester's perspective." - yes, I got a partial answer for my question raised during the lecture. At least at those times profilers deacresed the game perfomance significantly which caused some difficulties during optimization.

"While we were able to improve the pathing system for AoK, enhancing the unit-class hierarchy system was a much more onerous task. The unit-class hierarchy system from AoE couldn't be changed easily since so many game systems and so much functionality relied on the old implementation" - I guess that it was the problem of not good Object oriented design when AoE was being designed:). That again awaked a wish to study seriously OOD. At Savonia UAS there are no special courses about this. Probably it would be a good idea to ask my tutor teacher to run it there. Or maybe it is possible to run it as an online course like GPB2? E.g. "OOD in Games" or even beeter at first just general "OOD". But probably this topic is not that comvenirent to run online as I feel it will require a lot of discussions with teacher and student.

"VTune is great because you don't need to compile a special version of your program, it doesn't slow your program down while it runs, and it lets you see the amount of time the CPU spent executing processes besides your own." - Wow, nice! I think I will extend my knowledges got from the lecture quite a lot in this article. On example it's much more easy to understand differences between different profilers types.

Perfect, the article was amazing and I learned quite many things. Now I know roughly how optimization is done in real projects and what difficulties/solutions I can face/apply.

17:45

21.01

16:10

Ok, now I go to the assignment. I haven't found that practical lecture but it will be even more challenging and interesting maybe.

I installed the app and downloaded exercise app to profile which is a simple game like aero hockey where my opponent is a computer. Now launched the profiler which seems to be a light and not powerful one but let's see how it actually will do it's job. The good thing is that I don't need to recompile the app to profile in with SlimTune.

The input dialog of the profiler is simple but intuitive enough, from the first attempt I get things done. I played the game for about 10 sec and lost to the stupid AI:). The profiler generated statistical data based on sampling on each 5 milliseconds. Now I am analysing this info.

1. Per-Thread Call Trees Visualizer


Well to understand what is going on from that tree it would be good to examine the code at first but I don't see such task. From the screenshot1 it can bee seen that the app has 3 threads during it's run2 of them are some system functions in which I am not interested, they are called with frequency of about 1% and the Main thread with about 99%. Stop! That's wrong. It doesn't show the frequency of calling but just what relative amount of the time was spent in functions. So 99% of time during the app run was running Main thread and 1% - two other. two together.

Amoung functions called in Main the picture is slitly different. We see that Run method is used most of the time (91,57%). Other methods are some kind of initializers, like InitializeGraphics so they are called usually at app's start up. That's why the are not used much. I extended the Run function to check for the situation there and again noticed the method that is used most. I continued recursively to the very end. At the end it was PresentInternal method which belongs to DirectX3D library I suppose. 81,47 % of all samples were taken when that function was running. That makes me feel that this function is also uses CPU most, or hm.. GPU? I even don't know what is the actual situation. OKk anyway if the app is slow then I would certainly look at updateScreen function to optimize things. This is app's own method that make calls to DirectX to draw graphics I suppose.

2. Function Details Visualizer


I am confused a bit with this part of the task."Explain the function details from the program's own functions and library functions that are used extensively during the program execution. " - to do that I need to take several screenshots not one. But probably it's needed just to describe the situation with Main? I did in this way. The picture I got can be seen from screenshot2. I think this visualizer is a bit useless I get much more detailed and convenient info from Thread Calls visualizer. But it would be nice to have integrated function details diagram when I click on some method in previous visualizer(Thread calls). Sadly this feature is not available:(. Ok from that diagram I see that the Main method itselfs does not that much the most of work is done by Run method which Main calls. Some time is spent to initialize things, e.g. graphics(blue).

3.NProf-Style Treeview Visualizer


 In Tree View tab I get two trees of function calls. There're two of them probably because there were two threads running parallely. But where is that 3rd thread which was shown in the first part of the task? Hm.. yeah the input shown on the screenshot3 is not that clear for me. When I extend 47,Main()(I suppose this is the first function called in this thread) I get other function called in Main in their order of call and the first one is with id 265. But also after Main() this function is again present! I think that here two formats are integrated: I can extend some function to get a tree look what is called inside and also in the list form, if I won't extend anything. I feel it might be done in better way but can't say in which:). It's easier to use tree feature in this tab to find the info only about app's own methods(the task is such), From what I see.... Firstly the Run function is called and only after that initializers!! I don't know why it is so. Maybe a bug:)? Also that in that Run function some thread should be runned because it's calling tree is not big and I don't see there that updateScreen function that is called most of all. From the call tree I see that after Run() the graphics, sound is initializing and Window is drawing.

After the task is done I got a general impression what the profiler is and what to expect from it. I actually expected some more complicated output of information, probably more graphics, visualized graphs and that stuff. But that is a simple program I see and it doesn't do that much. Probably in most cases it is enough. But I am not sure if big companies will use such tool.

From this topic I got a lot of knowledges. I understood what the profiler is and why it is useful and also in which cases it is useful. I had a look at how games are optimized though reading that article about AoK optimization. But the main thing is that I now know that there profilers(I didn't know that):) that VGO is a big part of project.

I was missing a task about Lerpz platformer but nothing prevents me from do the task that I will invent! Of course it might be difficult to imagine some things about the game.

19:30

Total time spent: 6:50

Feedback

anonymous profile picture
PeterMorton
It was somewhat demoralizing at first, however, I chose to proceed on my execution at any rate, since I would not like to miss the learning knowledge. https://www.assignmentland.co.uk/do-my-assignment
anonymous profile picture
Martin Stone
This is now an initial beta, but it is fully useful and careful ready for use in most cases. Certified releases are obtainable and feedback is comfortable. Both x86 and x64 boards are reinforced, but only selection based profiling is obtainable in the current release.  http://www.bestassignmentservice.com/help-me-write-my-essay
anonymous profile picture
Ethan
Great share. You have explained it so well with proper point. As the competition is getting tougher day by day, the top gaming industries are focusing on the user behaviours and using the latest tools like unreal, cry engine, etc tools.  You can also earn through develop a unique game application by take help of the professionals.
https://emarketingblogger.com/top-best-game-developers-in-india/
https://rvtechnologies.com/mobile-game-development-company/
anonymous profile picture
robertsmith
Thanks for providing informative content.

To make your strong position in the competitive world, Every business should have a website and every business owner should have a basic understanding of the benefits of SEO and hiring the SEO companies. But one should always pick the SEO companies that actually provide solutions. SEO experts company tops the list of best SEO companies:

https://seoexpertscompanyindia.com/
https://emarketingblogger.com/seo-companies-india-best-top-10-list/
anonymous profile picture
hailiehills
I appreciate that you try to care about your customers. It's an important key in making business. Our team https://greatdissertation.com/personal-business-letter.html also tries to be perfect for our young customers. To set up my own successful business is my biggest dream. I hope that soon it'll come true.
anonymous profile picture
Jessicawatson
<a href="https://300writers.com/test-takers-for-hire.html">this</a> writing service will save your precious college time and guarantee you exceptional grades. You can use some of your time for more important things like part-time jobs, your family and friends.
anonymous profile picture
KeithVub

Kudos! Quite a lot of advice!

canadian pharmacies-24h
<a href="https://www.pharmacyonline-canadian.com//">canadian pharcharmy</a>
online canadian pharmacy
<a href="https://www.safeonlinecanadian.com//">canadian viagra</a>
canadian pharmacies-24h - http://canadianpharmacyntv.com/

<a href="http://movieroom.net/11045-pisma-k-dzhulette.html">canadian pharmacy cialis Ot</a> 08e00c0
anonymous profile picture
Michaelsobby
You actually explained it very well.
northwestpharmacy
<a href="https://www.canadianpharmacycom.com//">online pharmacies of canada</a>
canadian online pharmacies legitimate
<a href="https://www.safeonlinecanadian.com//">online canadian pharmacy</a>
best non prescription online pharmacies - https://www.canadianonlinepharmacytrust.com/

<a href="https://russianjustice.com/?p=787&lang=ru#comment-332127">international pharmacies that ship to the usa Bub</a> 0358ff6
anonymous profile picture
Dennisdet

Awesome posts, With thanks!

coupons for cialis viagra levitra
<a href="http://viaonlinebuyntx.com/">viagra and cocaine</a>
my viagra did not work
<a href=http://viaonlinebuyntx.com/>http://viaonlinebuyntx.com/</a>
anonymous profile picture
RobertFus
You explained it effectively!

cialis dailies
<a href="http://ciaonlinebuymsn.com/">cialis pills</a>
cialis controindicazioni con altri farmaci
<a href=http://ciaonlinebuymsn.com/>tudo sobre cialis</a>