Performance Bottlenecks in My Game Engine
Support and get Hazel ► / thecherno
Threads ► threads.net/@thecherno
Instagram ► / thecherno
Twitter ► / thecherno
Discord ► / discord
Hazel ► hazelengine.com
🕹️ Play our latest game FREE (made in Hazel!) ► studiocherno.itch.io/saving-c...
🌏 Need web hosting? ► hostinger.com/cherno
💰 Links to stuff I use:
⌨ Keyboard ► geni.us/T2J7
🐭 Mouse ► geni.us/BuY7
💻 Monitors ► geni.us/wZFSwSK
#Hazel
Пікірлер: 72
Haha yea who isn't addicted to speed!
@rapidstress2008
10 ай бұрын
"That's what she said" - A wise businessman, maybe
@Th3Y4nnix
10 ай бұрын
You can't sleep as a developer
14:00 ohhh the aussie "noyyy" never get's old
Really enjoyable video, sad that it ended though. Wanted to see you tackle the bottlenecks and rewrite some code 😊
@Pspet
10 ай бұрын
That probably takes weeks
For GetWorldSpaceTransformMatrix() if there is a parent, it gets called again because it's recursive, so for every transform matrix it might get called multiple times. Could that be the reason the amount of times the function gets called feels too high?
@Arwahanoth
10 ай бұрын
Yeah and it is counting recursive call but the out of scope is triggered after so maybe it is only counting time for the "leaf" ???
This was really cool to follow along with. I personally like this kind of content a lot, and I don't have anything that I would change about it.
Very nice video, good to see in depth thought process on detailed topics
Moving loads from the GPU to the CPU or vice-versa is useful, but if you're already hitting your target framerate then there's no real benefit to doing so. In that case you could also use the "free" resources to do lower priority work. For example: - Precomputation for future operations, which can smooth out framerates. - Preloading of assets that might be used in the near future. - Updates that normally only run every few ticks, but can benefit from being real-time. - Improving existing operations, for example physics accuracy. - Perform heavy computations that you would prefer happen now rather than when resources are scarce, such as garbage collection. And the good thing about many of these is that they can be aborted as soon as the GPU is done and simply resumed the next tick.
I'd love a video on how the compiler and other components work to actually package and ship the game itself. How is the exe built? How are the assets "cooked and packaged"?
Addiction to speed sounds like a paraphrasing for doing coke xD
@gamedev4432
10 ай бұрын
It's actually what they call meth.
Hazel is getting to the point I could see myself using it for actually releasing games, question is what would the price be? I don't have a studio at the moment but it is a goal, with that being said I am very interested in VR and mod support for games within an engine
Awesome! However can we also see the asset pack binary format stuff? Would be also a nice dev log to watch.
do you consider using valgrind to check the memory allocations/deallocations and/or intel vtune like cpu profiling or gpu profiling tools to check what’s going on and compare them maybe for unreal and/or unity?
"mmm, is too fast, something is wrong" 🤣
Awesome video like always!
Great video. PLEASE TALK ABOUT THE ASSET SYSTEM AND THE ASSET BINARY FILES PLEASSSSSSE 🙏
Cool video. If you want to trade memory for speed - you can always cache. Not sure if this is useful - but i'll share just incase it is. In my implementation of ECS i just return entity components by ref as opposed to by value. In the transformation objects themselves, I store the world matrix so that I update the matrix only when the transforms position,scale or rotation has changed. glm::mat4 Transform::GetWorldMatrix() { if (m_isDirty) { UpdateWorldMatrix(); } return m_mtxWorld; } I have an ECS-lite approach. I couldn't quite ditch OOP .... Components hold behaviour for manipulating the data they hold. It just makes sense to have that logic there.
much love man
we want more!
Do you plan to support custom shaders / scriptable pipelines ? Or Hazel renderer is fixed to the PBR pipeline?
I cache the world matrix and have a flag that indicates whether it needs to be recomputed. That way it only gets recomputed if you try to access it and it needs updating. Most entities don’t move, so setting the flag on all descendants when an entity moves is relatively cheap.
good vid! do you plan on making a hazel profiler similar to UEs?
Would you ever use a library like OpenMPI to partition tasks across CPU cores or is multi-threading sufficient for a game engine?
THREADS!! ICANT😂 you do realise threads is going to be an echo chamber?
i just found this series because ive been working on my own game engine and wanted to see how other people did stuff, ive learned so much from it! will the vulkan renderer ever be put on the github?
@cankarkadev9281
10 ай бұрын
It already is, but you have to be a patreon supporter to see it :D
Only mark object matrices (local and world space) as dirty, and only recalculate matrices when the matrix is requested. Recursive make child ws matrices dirty if needed, ie not already dirty or not dependent on parent matrix (world space object)
I have a FPS Tracker package in my game which I knew was slow, and I know I could've optimized it myself. When deep profiling it took roughly ~3ms. Copied that block and pasted it into GPT and asked it to optimize it for me, worked on the first try and now it runs ~0.02ms during deep profile, everything worked the first time around, the AI made no glaring errors, I just refactored it slightly. It all took like 20-30minutes.
Hes back
Cool video! I use Tracy myself and would be very interested in how you created these frame timers (HZ_SCOPE_PERF) 🙂
@imaymakesomevids
10 ай бұрын
They're covered in one of the really early hazel videos, maybe the logging one.
The thing I wonder is why not focus on optimizing the code running on the GPU? It might be bottlenecked by something silly even, like updating the textures every frame or sending tons of unnecessary buffers every draw? Because the Render Thread was waiting for the GPU, and the Main Thread was waiting for the Render Thread. The bottleneck was about 2 to 1 between the GPU and the CPU threads.
Why is Minecraft under the game category in the description?
Cherno, what you are missing is SPEED IS KEY. also, one way to really speed stuff up is (if its available on your hardware) enabling intrinsics, like simd replacements for memcpy, memmove, etc. (i don't know if thats an option in msvc)
Is that the stanford bunny in the background?
You forgot to add the annotation for your latest game jam game... 😭
That per-frame memory graph is fascinating - if the engine/game needs to allocate that stuff in one frame, then by the looks of things allocates it all again in the very next frame, why is it discarding it instead of reusing it? Would love to see words on that.
@rasmadrak
10 ай бұрын
A guess - The entities were re-evaluated per frame due to the nature of the game - a game jam one. :) Any proper game would utilize cache and early out's to avoid allocating new memory.
i wish to have vulkan series chernooooooooooo
hey Cherno. when are you going to switch vulkan in 2d hazel
@absorbingdude
10 ай бұрын
there’s no way I think, lots of things to cover, but if you are a little experienced with vulkan it’s not a problem to implement hazel with it, like I’m doin
@user-tz4tl1zw7j
10 ай бұрын
@@absorbingdude where can i learn vulkan-hpp
@GamerPlaya12
10 ай бұрын
@@user-tz4tl1zw7jvulkan-hpp is not needed. But if you want to learn it there are githib repos with samples
@absorbingdude
10 ай бұрын
@@user-tz4tl1zw7jWhat about these great resources that helped me a lot: 1) vulkan-tutorial (base-база) 2) vkguide dev (there’s pretty good abstraction around descriptors) 3) Dustin H Land’s site fasterthan life (he ported doom to vulkan) also he explains what it costs to port something to vulkan 4) This year I saw lots of vulkan videos on YT, so just explore If I remember something useful maybe I’m gonna edit this comment. Edit1: I also remembered, there’s an indie developer (cakez) he has game series vulkan c++ on YT, I advise you to look at them. Edit2: Sascha willems samples && vulkan samples Edit3: also some extremely helpful theory videos are called “Vulkan lecture series”
@user-tz4tl1zw7j
10 ай бұрын
@@GamerPlaya12 thank you
Wasn't the previous bottleneck because you turned memory streaming on and the gpu wasn't using vram, but system ram instead?
Is it possible to use c++ to transfer huge volume(10 gb or more) of data from one system to another. system..will it support? Thanks Cherno
@charlielarson1350
10 ай бұрын
our ancestors have used C++ to transfer large data between systems for millennia
can relate to the advice for optimizing for pc; i may have a mid range graphics card (for 2016), but theres no telling what the game is going to get run on though id personally work on the weakest hardware i find so as to cater to the greatest common denominator
@bobdagamer640
10 ай бұрын
When you're developing you need better hardware because the debug versions normally run slower
@not_herobrine3752
10 ай бұрын
@@bobdagamer640 thats literally the physical reminder to create software that doesnt run like treacle on underperforming hardware
@bobdagamer640
10 ай бұрын
@@not_herobrine3752 the debug version will run slower when you're developing than the release version that will go to users
@not_herobrine3752
10 ай бұрын
@@bobdagamer640 it is true that the debug version of some software will run slower on underperforming hardware than the release version that is expected to run on more performant hardware however if the developer ensures that this slow debug version runs fast enough on said underperforming hardware then surely there wont be any problem regarding performance because the user will logically only see a performance *increase*
Can you do a gaphics/engine react video on the GTA 6?
anyways gamefromscratch could do a review on hazelengine?
superluminal?
Show us most important parts of engines source code
Really... Need For Speed 💯🎮👌🏻💻
I am speed
need for speed hmh
So nobody is going to mention the cuteness at the start.. OK we live in a cold world I got it
@mastershooter64
10 ай бұрын
Nah lol you're the one who missed out and didn't see the cute baby editor, we all finished talking about it!
Sadly no one is using threads. Just stick to something like twitter. I'm not willing to download another app but wouldnt mind following you.
3:10 i know that hazel is the game engine. but you saying "huge thanks to hazel for sponsoring this video" triggered my fight or flight response and i had an impulse to skip this part of the video.
Hazel website is dead