Posts

Showing posts from 2020

Understanding ECS. The L1 and L2 cache and What makes ECS so fast?

Image
As explained in  this video . And this  Wikipedia page . Data-Oriented ECS?  L1 and L2 cache. this post is a continuation of the previous post , so if you haven't read it please do! Whenever we try to access and update a position component in our ECS (Entity Component System), for example, if we were using Object-Oriented techniques the entire object would get loaded into memory to just update the position. That's fine if you're not trying to make a mass-scale super Triple-A engine and all you want to do is get Georgy here to walk across the screen. In that case, ECS might be completely overkill. But if you  are  wanting to handle millions of Entities at once, memory efficiency becomes more important. You can see what using conventional Object-Oriented techniques might look like, and why it's inefficient below: As you can see we're loading all of Geargy and lots of components that we really don't care about. And it limits our ability to update lots of Georgy...

Understanding ECS. Finally explained

Image
What is ECS?  How did Unity make ECS?  How do I make ECS? Data-oriented ECS? And what does ECS stand for?  The last question: ECS stands for E ntity C omponent S ystem ECS is essentially a system primarily for game development where everything in the game world is defined as an Entity, and that entity can have attributes or aspects that we call Components. Hence the name ECS. So after my last post  I realized I needed to figure out these questions for myself a tad more before trying to explore them in detail on a blog post. I had three more blog posts on some conceptual ideas for ECS planned but realized, no one (myself included), would want to read that! So, after watching some talks by unity (specifically this one (Understanding data-oriented design for entity component systems - Unity at GDC 2019)   This one also helped (but not until I had watched the previous video did it make more sense). I am now ready to give an overview of Unity's ECS or at least how I...

Understanding ECS. Exploring Ideas

Image
Recently I’ve been looking into ECS and Data-Oriented Programming and I have been trying to figure out how to conceptually implement an ECS. Especially how unity implemented their ECS (Because it's so freaking fast!). I could’ve done more research but in my experience diving right in is more fun. Obviously the first ideas are not going to be correct but hey, I enjoy thinking and designing systems so why not?  Edit: Ok so I fixed up the explanations up a LOT so that they make more sense. Now a personal note, although this design works, it is horribly bad in terms of performance, one reason being... lists take up twice as much CPU cache. Arrays are always superior. If you don’t know what ECS is  Read this Wikipedia page. I really learned a lot about ECS and Data-Oriented design from reading  the bitsquid engine blog  and  the t-machine blog  they were part of the inspiration for this blog. Although t-machine is not as low-level and data-oriented as me or the ...

Big O notation

I’ll be using “big O” notation a lot to describe the efficiency of an algorithm, or some process that code is doing, so for all of you who don’t know big O notation here is a quick overview. I’ll start with an example. You need to find an element in a list, the number you trying to find is 18. To find the number, or to check if it is even there, your going to have to iterate over the list until you find the number 18. In the worst case scenario you won’t find it until you reach the very last element in the list. That would be O(n). - O  is used to express the worst case scenario. - ( ) is where you tell how many steps it will take in the worst case scenario to accomplish your goal. - n  is a common letter to use to signify the number of elements in the problem (in this case the number of “things” in our list) So O(n) is essentially saying, in the worst case scenario it will take us the same number of steps to find the number 18 as there are items in the list.