Let's write an ECS (Part 5) - Performance | Ep. 7

Поділитися
Вставка
  • Опубліковано 13 чер 2024
  • This is the fifth and final episode of the 5 part mini-series dedicated to writing our own ECS from scratch.
    If you missed the fourth episode you can watch it here: • Let's write an ECS (Pa...
    In this episode, we're focusing on performance and how our ECS compares to other Entity Component Systems and also just other methods of handling entities. I think the results are really interesting, let me know what you think!
    As promised, here's the code: github.com/DanWillans/ECS. Feel free to do what you want with it. Experiment, fork or contribute if you want!
    The fantastic EnTT library: github.com/skypjack/entt - Check it out!
    As always, leave me a comment to let me know what you think :) I love hearing back from you all.
    Cheers!
    Dan
    00:00 - Introduction
    00:50 - Benchmarking Application
    07:35 - Benchmarking Results
    09:35 - Performance Optimisations
    19:26 - Outro
    #cplusplusprogramming #cplusplus #gameengine #gamedev #gamedeveloper #gamedevelopment #gamedevelopmenttutorial #codingtutorial #programming #developer #games #entitycomponentsystem
  • Розваги

КОМЕНТАРІ • 6

  • @Veeq7
    @Veeq7 21 день тому

    Great series, neat to see how you did type erasure for the component array with casting and not virtuals. I think you can have a GetComponentArray there tho to only have the static cast once (it's very verbose). Still learning details about how to implement decent ECS... Also like the way you did IDs.
    Why not use std::vector for the index map? Pretty sure the extra pointer dereference doesn't matter when you are iterating over a lot of data (the actual data address should get into a register). Also makes the cache grab ECS controller when you are accessing it and grab the vector data when you are grabbing it (cache size is 64B, so this should actually be better overall), if you think what things will get into cache together when accessing controller I think it makes more sense to grab controller collections, rather than a small part of one of them. So I suspect the vector is as fast, but curious, if it's slower.
    Also I feel like view like iterator is better for cache than having manual getters, you can quickly skip over components that are not in the combined bitset (you will want a concept of mandatory and optional component I guess). I like the entt view model, and I like the function callback model from flecs. They seem super easy to use, which is neat. Your APIs are a bit verbose and require a bunch of boilerplate, which maybe is fine for reduced template complexity, not sure...
    Also any plans of multithreading this? Would be awesome to see distinction between mutable and not mutable access component in systems (1 writter or multiple readers, like in Rust), keeping systems deterministic and fast.

  • @Daniel-tx6hx
    @Daniel-tx6hx 23 дні тому

    Hey Dan, great episode as always. I have a question regarding your development process. Do you use AI code assistant in your engine development and if so which models do you use?

    • @marblexeno
      @marblexeno 23 дні тому

      AI models are shite

    • @Daniel-tx6hx
      @Daniel-tx6hx 23 дні тому

      @@marblexeno Most of them are useless. My question is if there really is a model that understands what should be and helps you, because I haven't found anyone

    • @DanWillansYT
      @DanWillansYT  22 дні тому +1

      Hey @Daniel-tx6hx, thanks for watching again :)
      I've not really used many AI code assistants. I've heard github co-pilot is great for some languages and not so great for others (like C++). I work for Amazon and they have their on generative assistance called Amazon Q. I need to give it a go and see what it's like at work but with limited experience I've found the assistance to be a hinderance at times.
      Things I have used ChatGPT for to help me with:
      - If there is a bit of code I don't understand or a design pattern that I want to manipulate or understand further for example, then I have asked ChatGPT which has been useful in some instances. I find it useful to probe with deeper questions but sometimes it can go off on a tangent so you have to steer it back on the right path.
      - I have also used it to help me with new languages if I don't understand some syntax or I have a niche problem that I can't quite google.
      - It's very helpful for writing specific scripting loops in bash, for example, "Write me a bash script that will recurse a directory structure deleting every file with a timestamp greater than X".
      Like most things in software engineering, this stuff is very subjective and your experience may differ so why not give co-pilot a free trial and see if it's what you're looking for?

    • @Daniel-tx6hx
      @Daniel-tx6hx 22 дні тому

      @@DanWillansYT This is probably what I will do (co-pilot).
      The point you made is even clearer to me now. So far, I have used AI for C++ and C# languages, and the results were poor. However, when I used it for web development (HTML, CSS, JS), the various models gave me impressive results. I will continue to follow the different models, and if I come across a breakthrough on the subject, I will share it with you. :)