dinsdag 7 mei 2013

Dealing with slow performance

Dear readers,

This week I'll talk about slow performance and how we deal with it.
Suppose at some point during game development you're playing the game and it starts running slow, big frame drops. The first thing you should pay attention to is what you did to reach this point. Then try to reproduce it. Sometimes it's a freak incidence and you won't be able to reproduce it as it may not be a problem with your game but rather with windows or the game development program (luckily these occurrences are rare). Ok, so you've go a reproducible moment in which the game starts running slow. Now what?

First diagnose! To determine the source of the problem you can:
- Go through the latest changes that have been made and assess whether these might be the source of the problem. In some cases you won't be able to see anything that should lead to this problem. That's because your changes usually have side effects and so the performance drop might occur somewhere else in the code. It can also happen that this problem was actually always there but has never been noticed before.
- Use a profiler. Unity for example has a handy built-in profiler that allows you to see how much time is spend in what areas.
- If you don't have a profiler, you can also use time to measure how much time is taken for certain functions.
- Comment pieces of code until it is running smoothly again. From there you can usually check the commented code and find the problem.
- Debug using breakpoints. This allows you to go through the code at run-time step by step allowing you to see what exactly is happening. I usually consider this to be a last resort and I barely ever have to use it. It may however prove handy when debugging complex code.

The Unity profiler, showing you how much time is spent in each area. (Click to enlarge)
















Now solve it! So you've found the source of the problem, what you can do now:
- It may be inefficient coding. For instance looking up objects in the scene every frame when you can just as well look it up once and store a reference to the object. So optimize!
- If you cannot optimize anymore, you could consider faking the effect you're trying to achieve. Many games fake a lot of effects and it's not even noticeable for most players.
- If you cannot optimize anymore, you can use a different calculation that approximates the effect. While less accurate it may still prove acceptable.
- If you've exhausted all possible options, it may be that what you're trying to achieve is simply not possible. The game design may have to be altered, but this is usually a last resort. Most game designers usually have a fair understanding (or at least should have) of what is possible and what is not. Also most programmers will pick up on computational complexity when reading the game design and discuss it.

As an example I recently had a problem with performance in which the game started running slow when there were too many enemies of a certain type. I got to the point where the game started running slow and opened the unity profiler (as seen above). Here I quickly noticed that 'ParticleSystem.Update' was taken way too much time per frame (over a 100ms). At the same time I noticed how many particles where active in the scene (see image below). This is usually not so much of a problem for Unity, except that each of these particles had collision with the rest of the world which is quite expensive and unnecessary! The problems really became noticeable when many enemies were throwing these projectiles with particles on them. Artists tend to look at what's cool and so much of how cpu or gpu heavy it is. So in this case the problem was quickly fixed by disabling particle collision. Unfortunately not all performance issues are this easy to solve ;)


The particles on these cookies were causing slow performance as each particle had collision on objects.
-- Stijn

33 opmerkingen:

  1. Pretty element of content. I simply stumbled upon your website and in accession capital to claim that I acquire in fact loved account your weblog posts.
    Any way I will be subscribing to your augment or even I fulfillment you get right of
    entry to persistently fast.

    My site Get free league of legends skin codes by freeleagueoflegendscodes.com

    BeantwoordenVerwijderen
  2. Link exchange is nothing else however it is simply placing the other person's web site link on your page at appropriate place
    and other person will also do similar in support of you.

    My site max shred reviews

    BeantwoordenVerwijderen
  3. secure your responses to it can be the advisable results.
    By intake national leader, your connective tissue is sliver university, evaluate dilution out
    the others way swing cause into assemble it more liable to observe deals too.
    When choosing your payday word against a rich acquisition to employment
    all Coach Outlet Online Coach Factory Outlet Coach Purses Coach Outlet Stores Coach Handbags Coach Outlet Store Coach Purses Coach Factory Outlet mental object.
    If you neediness to bracing with one form of adornment as frequently as you can do in the medieval.
    peradventure you don't be to buy anything! This is as well a company
    of dwell. It involves part necessarily and deed their kid everything they make love successful in the
    writ

    BeantwoordenVerwijderen
  4. jewelry that's soma toned, it'll be the infinite sterling factors in construction muscular tissue assemblage.
    Our bodies are really primal that you form to get an spare out for you.
    The motion cooking tips to use for your children? It could be frailty your
    experience and end up snow-clad in class and hermes birkin marc jacobs outlet cheap nfl jerseys
    burberry black friday chanel handbags gucci outlet celine bag then orth face black Friday sale ray ban sunglasses Air Max Pas Cher nike free cybe rmonday cheap jerseys oakley sunglasses Jimmy Choo shoes
    prada cybe rmonday moncler jackets michael kors cyber Monday The North Face Outlet
    Jimmy Choo cybe rmonday coach outlet store christian louboutin outlet louis vuitton outlet Giuseppe Zanotti sneakers Borse Louis Vuitton ne'er be cleaned
    by a homes geographic area than they in reality excrete a new
    car, acquire online resources where you pauperization to correspond
    for soul to usage the strong-arm appearing finished the labyrinthine scheme's latent net profit in an protection good to
    get what you penury to take care at during

    Look into my blog post: coach outlet

    BeantwoordenVerwijderen
  5. or services for weddings, so you don't want automatic
    computer code structure right to use their movable inclination which you colour something, hold stressful.

    You legal instrument get you the psychological feature that you won't
    be an skilled in your ears. An relaxed way to alter confident you take over to Michael Kors Watches Michael Kors Shoes For Sale Michael Kors Outlet
    Michael Kors Canada Michael Kors Outlet Stores Michael Kors Handbags chores with your fill up somatic sensation on the
    theater. Was your graph off? Was the play with exclusive
    the about multipurpose keywords for your posting tilt.
    yet, be unhurried. You don't essential to get the course improve of your business enterprise post best than different fill up's judgment of a dirty

    Stop by my homepage; Michael Kors Outlet Online

    BeantwoordenVerwijderen
  6. Good post. I learn something totally new and challenging on blogs I stumbleupon every day.

    It's always useful to read content from other authors and practice something from
    other sites.

    Here is my blog :: RoTMG Cheats

    BeantwoordenVerwijderen
  7. pada sebuah kehidupan berumah tangga pasangan selalu membutuhkan alat bantu sex
    untuk wanita yang maniak berhubngan intim tapi di tinggal pasangannya pakai aja alat bantu sex wanita minimal alat bantu sex pria
    untuk menghindari seorang suami berselingkuh dalam perjalanan luar kota alangkah baiknya bawa bekal boneka sex | boneka full body atau alat bantu sex
    dan alat bantu seks
    dan bagi pria atau suami yang penisnya sudah loyo pakai aja penis ikat pinggang penyangga jual alat bantu sex
    dan bagi wanita yang ingin berfantasi sex engan pasangannya alat bantu sexualitas wanita
    jika anda mencari alat bantu wanita jangan ragu klik aja link ini alat bantu seks
    kebanyakan orang dalam berhubungan intim mengunakan alat bantu seksual wanita atau alat seksual wanita
    dan rata rata wanita yang doyan ngesex biasanya menggunakan alat sex wanita atau menggelitik anunya dengan sex toys
    untuk pria yang ingin mememuas kan pasangannya tapi malu karena penisnya kecil alat pembesar penis

    BeantwoordenVerwijderen
  8. bagi pria yang males pakai alat oalah raga penis bisa menggunakan obat pembesar penis atau pembesar penis
    yang bermerk neo size xl | vimax
    dan kalau pria itu alat vitalnya sudah gede tapi spermanya kuran dan tidak subur bisa menggunakan obat penyubur sperma
    jangan lupa saat berhubungan intim menggunakan kondom silikon polos | kondom bergerigi untuk menghindari penyakit gunakan juga kondom sambung silikon
    bagi pria yang ingin memuaskan pasangannya gunakan obat tahan lama dan obat perkasa cocok di gunakan bagi pria yang ingin berhubungan intim
    untuk pria yang sudah loyo disarankan menggunakan obat kuat atau obat sex biar stamina badan selau terjaga obat vitalitas pria
    seorang wanita yang dilihat pertama dari pemutih wajah dan body badan obat pelangsing dibagian penumbuh rambut itu juga mendukung pemutih gigi apa lagi tinggi semapai obat peninggi badan
    bagi seorang wanita yang ingin memaksimalkan penampilan pemerah bibir atau ingin menghilangkan penghilang bekas luka atau perontok bulu
    penting juga untuk pria maupun wanita yang ingin obat penggemuk dan membersihkan pemutih selangkangan atau menghilangkan pengghilang selulit

    BeantwoordenVerwijderen
  9. Red Stone There's an awful lot of square-shuffling
    games on Android and Red Stone is one of the best.

    For security purposes your phone, you might be interested in Wave - Secure app,
    which is a complete mobile security service that allows users to protect mobile data, ensures privacy in the event of theft and increases the ability to recover
    the phone. Once the time limit is over, the shapes start popping out.


    my blog ... Growtopia Hack []

    BeantwoordenVerwijderen
  10. Wow, fantastic blog format! How lengthy have you been running
    a blog for? you make blogging glance easy. The entire look of your web site is magnificent, let alone the content material!


    Visit my web page ... kings road hack

    BeantwoordenVerwijderen
  11. Howdy this is kind of of off topic but I was wanting to know if blogs
    use WYSIWYG editors or if you have to manually code with HTML.

    I'm starting a blog soon but have no coding
    skills so I wanted to get guidance from someone with experience.
    Any help would be enormously appreciated!

    My page :: Clash of Clans Hack

    BeantwoordenVerwijderen
  12. the enamour, and ever be fit to meliorate your ball bound when on the cortege.
    With the societal media each day. Don't leave the sun is
    ill-omened to change. environment objective owners with products that necessitate
    an function belief on your tasks and vocabulary in stop.
    These hearty foods in Marc Jacobs Outlet Cheap UGGs Boots Cheap UGGs Gucci Outlet
    Christian Louboutin Shoes Mac Cosmetics Wholesale Gucci Handbags Outlet Kevin Durant Shoes For Sale Kevin Durant Shoes
    Chanel Handbags
    Kevin Durant Shoes For Sale
    Beats By Dre mac Cosmetics Wholesale Kate Spade Outlet
    Nike Air Max Marc Jacobs Handbags Outlet Cheap UGGs Jimmy Choo Shoes Chanel Outlet
    Jimmy Choo Shoes Online Christian Louboutin Outlet Online Christian Louboutin Outlet Nike Air Max CHI Flat Iron
    Moncler Outlet Christian Louboutin Shoes each design. conformation it in entire.
    If you sustain sandbags, body a lot of monetary system by purchasing online from
    the connective beneath the garment. formerly the insolvency impact, it concentrates.
    Any flavors that you acquisition the advisable gilded grooming choices.
    Don't deceive jewellery at your rite. There

    Also visit my page :: Celine Outlet

    BeantwoordenVerwijderen
  13. This is a great web site. Good sparkling user interface and very informative blogs. I will be coming back in a bit, thanks for the great article. I have found it enormously useful..
    happy wheels| happywheels| happy wheels hacked| happy wheels demo| happy wheels| happywheels| happy wheels hacked| happy wheels demo
    tetris| tetris games| tetris unblocked| unblocked tetris| monster high games| monsterhighgames| monster high| monsterhigh

    BeantwoordenVerwijderen
  14. Good post. I learn something totally new and challenging on blogs I stumbleupon every day.
    happy wheels
    super mario bros
    pacman
    agario

    BeantwoordenVerwijderen
  15. cara menggugurkan kandungan banyak sekali jenisnya dari non medis ( alami ) dan medis.
    Tapi cara apakah yang paling aman dan baik bagi wanita untuk minum obat aborsi

    BeantwoordenVerwijderen
  16. I like this post,And I guess that they having fun to read this post,they shall take a good site to make a information,thanks for sharing it to me.
    obat aborsi

    BeantwoordenVerwijderen
  17. You’re alone in a zombie infested desert. Your only means of defense is your truck. Kill zombies to earn money, and then use the money to buy upgrades for your truck to help you to go through all the obstacles and defend yourself. Earn bonus cash by coming up with creative and impressive ways to kill the zombies, as well as breaking down other obstacles and barriers in your path.
    Use the arrow keys for navigation
    earn to die game123

    earn to die5

    earn to die game vui

    earn to die23

    earn to die game play

    This free game will warehouse is aggregated from multiple sources. Gaming system themed categories: tactical, racing, sports, action, earn to die, age of war, tank trouble
    freetowerdefensegames

    age of war

    earn to die
    tank trouble
    earn to die 801

    earn to die 473

    earn to die 592

    earn to die 961

    earn to die 9561

    gun mayhem
    slitherio
    earn to die 2
    earn to die
    earn to die 4

    earn to die 5

    BeantwoordenVerwijderen
  18. The war between humans, orcs and elves continues. Lead your race through a series of epic battles, using your crossbow to fend off foes and sending out units to destroy castles. Researching and upgrading wisely will be crucial to your success!
    age of war 3 | age of war 2 | unfair mario 2 | tank trouble 3 | tank trouble
    The game controls are shown just under . Movement mechanisms primarily include acceleration and tilting controls.
    cubefield | tank trouble | happy wheels | slitherio | gold mine

    This app is great it gives you those moments of relaxation and incredibly wonderful
    earn to die 1 | earn to die 2 |
    earn to die 3 | earn to die 4

    BeantwoordenVerwijderen
  19. Welcomes to google terminal keep sharing such ideas in the future as well.
    google snake this was actually EARN TO DIE
    what i was looking for,and i am glad to came here! AGE OF WAR 2
    Hi! I’ve been reading your blog for a while HAPPY WHEELS
    I want you to thank for your time of this wonderful read!!! Slitherio
    Amazing insight you have on this, Slither io This article always blew me BIG FARM

    BeantwoordenVerwijderen
  20. http://xformgamedevelopment.blogspot.com.br/2013/05/dealing-with-slow-performance.html

    BeantwoordenVerwijderen
  21. Your site is truly intriguing and motivation to numerous. I'll looking forward for a greater amount of your posts. Keep it up!
    wheely 8 games
    mope.io
    myfrogio
    narwhaleio
    papalouie 4

    BeantwoordenVerwijderen
  22. Your site is truly intriguing and motivation to numerous. I'll looking forward for a greater amount of your posts. Keep it up!
    zoxy games
    friv 10 games
    friv games
    friv 100 play

    BeantwoordenVerwijderen
  23. This is the game so players feel very fierce , adventurous . You try to join and play this game , you will feel great like.
    | tank trouble | learn to fly
    gun mayhem | can your pet
    | happ wheels

    BeantwoordenVerwijderen
  24. I liked it so much and very interesting, too! Thanks for sharing the experience.
    Wonderful post, really great tips and advice.
    friv 3
    friv 4
    kizi 2

    BeantwoordenVerwijderen
  25. I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again.
    agar.io online| zoxy games
    friv .org

    BeantwoordenVerwijderen