Performance Bottlenecks in My Game Engine

Sdílet
Vložit
  • čas přidán 10. 07. 2023
  • 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

Komentáře • 72

  • @mastershooter64
    @mastershooter64 Před 11 měsíci +72

    Haha yea who isn't addicted to speed!

    • @rapidstress2008
      @rapidstress2008 Před 11 měsíci

      "That's what she said" - A wise businessman, maybe

    • @Th3Y4nnix
      @Th3Y4nnix Před 11 měsíci +3

      You can't sleep as a developer

  • @Zyhorn
    @Zyhorn Před 11 měsíci +26

    Really enjoyable video, sad that it ended though. Wanted to see you tackle the bottlenecks and rewrite some code 😊

    • @Pspet
      @Pspet Před 11 měsíci +1

      That probably takes weeks

  • @sumikomei
    @sumikomei Před 11 měsíci +1

    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.

  • @cookiecan10
    @cookiecan10 Před 11 měsíci +32

    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
      @Arwahanoth Před 11 měsíci +4

      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" ???

  • @aaronmark3930
    @aaronmark3930 Před 3 měsíci +1

    14:00 ohhh the aussie "noyyy" never get's old

  • @ChaoticFlounder
    @ChaoticFlounder Před 11 měsíci

    Very nice video, good to see in depth thought process on detailed topics

  • @emilemil1
    @emilemil1 Před 9 měsíci

    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.

  • @redafakih12
    @redafakih12 Před 11 měsíci +1

    Awesome! However can we also see the asset pack binary format stuff? Would be also a nice dev log to watch.

  • @hawks3109
    @hawks3109 Před 11 měsíci +3

    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"?

  • @ThyTrueNightmare
    @ThyTrueNightmare Před 11 měsíci +3

    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

  • @osys7832
    @osys7832 Před 11 měsíci +3

    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?

  • @Omar-mm6ms
    @Omar-mm6ms Před 11 měsíci

    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.

  • @vineilan
    @vineilan Před 11 měsíci

    Awesome video like always!

  • @GameSmilexD
    @GameSmilexD Před 11 měsíci +4

    Addiction to speed sounds like a paraphrasing for doing coke xD

    • @gamedev4432
      @gamedev4432 Před 11 měsíci +1

      It's actually what they call meth.

  • @arrowsdev
    @arrowsdev Před 11 měsíci

    much love man

  • @arsenbabaev1022
    @arsenbabaev1022 Před 11 měsíci +3

    Do you plan to support custom shaders / scriptable pipelines ? Or Hazel renderer is fixed to the PBR pipeline?

  • @kirammanenjoyer
    @kirammanenjoyer Před 11 měsíci +2

    Great video. PLEASE TALK ABOUT THE ASSET SYSTEM AND THE ASSET BINARY FILES PLEASSSSSSE 🙏

  • @ShermanDev
    @ShermanDev Před 11 měsíci +1

    "mmm, is too fast, something is wrong" 🤣

  • @nuttolum
    @nuttolum Před 11 měsíci +1

    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
      @cankarkadev9281 Před 11 měsíci

      It already is, but you have to be a patreon supporter to see it :D

  • @m00nshoes
    @m00nshoes Před 11 měsíci

    good vid! do you plan on making a hazel profiler similar to UEs?

  • @JohnSmith-ze7sv
    @JohnSmith-ze7sv Před 11 měsíci

    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.

  • @goodecheeseburgers6320
    @goodecheeseburgers6320 Před 11 měsíci +1

    THREADS!! ICANT😂 you do realise threads is going to be an echo chamber?

  • @mascit
    @mascit Před 11 měsíci +1

    we want more!

  • @zacharymiller7573
    @zacharymiller7573 Před 11 měsíci

    Would you ever use a library like OpenMPI to partition tasks across CPU cores or is multi-threading sufficient for a game engine?

  • @andy9999andy
    @andy9999andy Před 11 měsíci

    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)

  • @Mnmn-xi6cj
    @Mnmn-xi6cj Před 11 měsíci +4

    Cool video! I use Tracy myself and would be very interested in how you created these frame timers (HZ_SCOPE_PERF) 🙂

    • @imaymakesomevids
      @imaymakesomevids Před 11 měsíci

      They're covered in one of the really early hazel videos, maybe the logging one.

  • @martinlarsson6621
    @martinlarsson6621 Před 11 měsíci +3

    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.

  • @luigidabro
    @luigidabro Před 11 měsíci +2

    Why is Minecraft under the game category in the description?

  • @infiteri6030
    @infiteri6030 Před 11 měsíci +1

    Hes back

  • @bagel7860
    @bagel7860 Před 10 měsíci

    You forgot to add the annotation for your latest game jam game... 😭

  • @andersonklein3587
    @andersonklein3587 Před 11 měsíci

    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.

  • @user-sl6gn1ss8p
    @user-sl6gn1ss8p Před 11 měsíci

    Is that the stanford bunny in the background?

  • @Asdayasman
    @Asdayasman Před 11 měsíci +1

    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
      @rasmadrak Před 11 měsíci +1

      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.

  • @nerdastics3987
    @nerdastics3987 Před 11 měsíci +2

    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)

  • @eggmeister6641
    @eggmeister6641 Před 11 měsíci +1

    Wasn't the previous bottleneck because you turned memory streaming on and the gpu wasn't using vram, but system ram instead?

  • @MrHuman-iy5lw
    @MrHuman-iy5lw Před 11 měsíci +1

    i wish to have vulkan series chernooooooooooo

  • @randomWork111
    @randomWork111 Před 11 měsíci

    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
      @charlielarson1350 Před 11 měsíci

      our ancestors have used C++ to transfer large data between systems for millennia

  • @user-tz4tl1zw7j
    @user-tz4tl1zw7j Před 11 měsíci +4

    hey Cherno. when are you going to switch vulkan in 2d hazel

    • @absorbingdude
      @absorbingdude Před 11 měsíci +2

      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
      @user-tz4tl1zw7j Před 11 měsíci +2

      @@absorbingdude where can i learn vulkan-hpp

    • @GamerPlaya12
      @GamerPlaya12 Před 11 měsíci +2

      @@user-tz4tl1zw7jvulkan-hpp is not needed. But if you want to learn it there are githib repos with samples

    • @absorbingdude
      @absorbingdude Před 11 měsíci +3

      @@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
      @user-tz4tl1zw7j Před 11 měsíci +1

      @@GamerPlaya12 thank you

  • @not_herobrine3752
    @not_herobrine3752 Před 11 měsíci +4

    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
      @bobdagamer640 Před 11 měsíci

      When you're developing you need better hardware because the debug versions normally run slower

    • @not_herobrine3752
      @not_herobrine3752 Před 11 měsíci

      @@bobdagamer640 thats literally the physical reminder to create software that doesnt run like treacle on underperforming hardware

    • @bobdagamer640
      @bobdagamer640 Před 11 měsíci

      @@not_herobrine3752 the debug version will run slower when you're developing than the release version that will go to users

    • @not_herobrine3752
      @not_herobrine3752 Před 11 měsíci

      ​@@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*

  • @Bodzilla001
    @Bodzilla001 Před 6 měsíci

    Can you do a gaphics/engine react video on the GTA 6?

  • @mrthomaschannelearth
    @mrthomaschannelearth Před 11 měsíci +4

    So nobody is going to mention the cuteness at the start.. OK we live in a cold world I got it

    • @mastershooter64
      @mastershooter64 Před 11 měsíci +3

      Nah lol you're the one who missed out and didn't see the cute baby editor, we all finished talking about it!

  • @fatsu
    @fatsu Před 9 měsíci

    superluminal?

  • @keptleroymg6877
    @keptleroymg6877 Před 11 měsíci

    Show us most important parts of engines source code

  • @yanko694
    @yanko694 Před 11 měsíci

    anyways gamefromscratch could do a review on hazelengine?

  • @alec_almartson
    @alec_almartson Před 11 měsíci

    Really... Need For Speed 💯🎮👌🏻💻

  • @xXkelseyXx1
    @xXkelseyXx1 Před 11 měsíci +2

    I am speed

  • @Jkauppa
    @Jkauppa Před 11 měsíci +1

    need for speed hmh

  • @debonairrose
    @debonairrose Před 11 měsíci +1

    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.

  • @crazycdn8327
    @crazycdn8327 Před 11 měsíci

    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.

  • @MuhammadHosny0
    @MuhammadHosny0 Před 11 měsíci

    Hazel website is dead