What's Causing my Frame Rate to Drop? - Unreal Engine 5 Stat Profiling Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so when I started working with fire I knew that this was the real test of the game and why in a word performance and if you watch my FPS in the top right so right now it's a stable 40 to 45 FPS and for about 10 seconds this fire was spreading FPS was totally fine and then about 10 20 seconds into it and boom suddenly we got a 15 FPS drop all of a sudden for no reason what's going on and every time an FPS drop like that happens my heart sinks because quite frankly I don't know the best ways to often troubleshoot certain things but I'm going to show you what I do know so with any FPS drop the first thing we want to do is we want to turn on detailed stats so you can find that in the top left corner and then under engine select detail and what this is going to allow us to see is everything from frame down to GPU and even memory it's going to show us okay what's the bottleneck that's really holding up performance all right so here we are again and we see the spike in performance down there in the bottom left corner and in the top right we can see that red that's our game thread so in my mind that's actually good news because I was worried it's all GPU that the fire something our GPU is not going to be able to handle but the game thread that really means blueprints or it means something that's running on the CPU not necessarily blueprints but because everything I'm doing is blueprints it's probably blueprints so now that we know it's the game thread what I'm going to do is under stat Advanced I can enable if we scroll down there's a lot of stats here game and what this is going to allow us to see is one level deeper like what within that game thread is actually taking up the most time right now those bars are very small because nothing's going on but let's start things up again thank you So within my level loading there's always this initial Spike and it's going to settle down because yeah it's basically physics The Rock's getting settled foliage spawning all that fun stuff everything's normalizing and then we can see what's up and there's that giant Spike again so it's all in the blueprint time you see there so something in blueprints is causing a serious problem so what's our next step doing some searches I stumbled upon this really useful blog post by Unreal Engine and I know it was written all the way back in 2014 but it holds up really well so I'll post a link to it in the description below and you can check out the entire article but what it recommends that we do next is use the tilde key to open up the command console and entering stat start file and that's what actually starts recording data for the profile and it says let it run for at least 10 seconds or so to get a nice average over many frames and then we can stat stop file to actually end it alright so we wait for the giant Spike again and here we go so tilde and we're going to do stat start file one word if I could spell there we go and in the top left corner now we've got our stats file and it says duration six seconds seven seconds eight seconds you only need a few seconds of this and then you should be good especially if you've got a stable issue now if you have periodic spikes in your frame rate you probably want to record for a longer period of time so you can see what's going on with those spikes I have some little spikes but predominantly it's just overall frame rate spikes through the roof and then stat stop file all right we can exit out so we got our profile snapshot but how do we look at that so for that we got to go to tools and then we can go to session front end here and then we need to navigate over to the profiler Tab and we need to load in the last file that we just recorded So we go to load and you're probably going to have to navigate to this folder but it's under your unreal projects you go into your main folder saved and then into this folder called profiling under unreal stats there you'll find the file so it's in here and it'll probably just take a few seconds to load depending on how long the recording was so now we get into the more interesting stuff so you can either here select a single frame or you can click and drag and select multiple frames then you could look at an average over that period of time if you select just a single frame then it'll be just one frame if you select an overall period of time you could actually look at the maximum which is helpful to look at those spikes but in our case I just want to look at the average because I want to see what's going on generally speaking and then we start coming down here to the events and the first thing I'm looking at is the background thread pool so that's not going to tell us anything because it's just waiting for some something else to happen so what we really want to do is we want to take what we identified in the first couple of steps which is that it's the game thread and we want to expand that part of the profile so game thread and I know my head is blocking here so let me just readjust this slightly so now with the game thread we can see that that's taking up 35 milliseconds per tick which is quite a lot and most of that is frame time so we're going to expand frame time and then we can expand here frame time in the world tick time that's what's taking the most so we'll expand that one take time pre-physics here expand that release tick group so basically you keep digging deeper here and looking at the most expensive basically the highest millisecond tasks and then finally we get to tick function tasks and wow so ground foliage hierarchical instant static mesh that I've set up that's taking 18 milliseconds and under blueprints it's actually a function within the blueprints and not only that I can see the specific function on the blueprint it's this on fire check function that's killing me and so at this point point you would go into that blueprint and start troubleshooting and it took me a little while to figure it out but it really was pretty obvious in retrospect so if I go into my foliage hism here so this on fire check function that I created basically it's taking every single instance of the static meshes and it's checking every single instance every single tick whether or not it's on fire obviously that's not a good way to handle it because there could be thousands of those instances and really we only care about those that are on fire so what I ended up doing is I ended up creating a brand new array where I store the ones that are on fire it's a much smaller number [Music] the end result is perfectly fine performance even with a ton of foliage on fire [Music] so I hope this was helpful and uh hope to see you guys in the next episode [Music]
Info
Channel: NumenBrothers
Views: 5,583
Rating: undefined out of 5
Keywords:
Id: nQdsY2a-Fn8
Channel Id: undefined
Length: 6min 9sec (369 seconds)
Published: Sat Nov 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.