Why does everyone say I DON'T need pooling in Godot?

preview_player
Показать описание
Here, I answer your quick questions about Godot and game development in simple videos.
If you have a question that we can answer in 5 minutes max, ask away!

Рекомендации по теме
Комментарии
Автор

A couple of extra notes:

1. This video doesn't mean you shouldn't care about performance or that you should never use pooling. It's more that, with performance, you should always make measurements and make educated decisions. You shouldn't blindly use a technique like pooling everywhere.
2. You don't *always* need pooling in Godot *when using a language like GDScript* (or a language with manual memory management, like C++ or Rust). But if you use C#, you do need pooling whenever you're freeing instances often. The reason is that C# was not designed for game development; it uses a garbage collection algorithm that can cause short freezes.
3. Technically, GDScript has a form of garbage collection (which means "automated memory management"), but it is suitable for real-time applications like games. It's called Reference Counting (in some languages, like Nim, it's called ARC, for Automated Reference Counting).

GDQuestQA
Автор

Pretty amateurish for the Godot dev to outright assume nobody needs pooling.
He got proven very wrong in this video.

GenericInternetter
Автор

Basically, thank you for saying that Juan was wrong politely.

RebelliousX
Автор

I first heard about the concept of "object" pooling from old C/C++ game dev books. So, I'm pretty sure that the concept doesn't have anything to do preventing gc freezes. Even the Game Engine Architecture book (C/C++) by Jason Gregory goes over the use of pool allocators in the memory management section.
My suggestion is to avoid premature optimization; but you should be aware of techniques like object pooling, should they become necessary.

dlpatri
Автор

This is an excellent topic, I’m glad you made it!

_gamma.
Автор

Dropped frames isn’t the only concern that pooling addresses. There’s also heat and (perhaps the most important) energy usage.
Games are played on a variety of portable PCs and on mobile phones. Even if pooling won’t affect your frame rate at all, it still could affect battery life.

ShaolinDave
Автор

Might be worth making a video about premature optimization. It's easy for novices to get the wrong impression about the importance of these things, and start wasting time trying to solve problems that don't exist yet in their projects. And especially considering most projects don't go past the prototyping phase, those optimizations could end up being a complete waste of time (and deplete motivation).

I know I fell for all of that...

Bottom line for me is, don't optimize until you have to.

skaruts
Автор

Question #1: How should one manage versions of their resources? Should I care that my .tres are of different version than my current script? Or I should just prepare for the fact that some @export'ed variable will have default values and that's all?

Question #2: It was mentioned that the best idea is to (on desktop) start with 1920x1080, setup the UI w/anchors and prepare textures/images for this resolution. What if I want the game to still look good on 4K? Wouldn't it be best to prepare images for the highest resolution and piggy-back on the good quality mip-maps to carry all the other resolutions?

BartoszBielecki
Автор

So to sum it up, pooling helps in both garbage collector stutter and frame to frame performance. While godot has no garbage collector issue, it may still benefit from pooling on frame to frame performance potentially, is that correct?

kruth
Автор

Another reason why object pooling is useful is that allocating and freeing memory can create fragmentation in your memory allocator. Basically the allocator keeps track of memory that can allocate, and every time you go to allocate a chunk of memory the allocator has to search the block of ram it has set aside for allocation for a chunk that is free and of the size you are wanting to allocate. This search can get longer and result in slow downs in the allocator that can be noticed if you are trying to reach high frame rates or allocating/deallocating a lot of memory each frame. Object pooling gets around this by not having to allocate or deallocate. To be clear, this has nothing to do with garbage collecting memory allocators.

Another optimization that can be used in languages that expose the capability, is to create your own memory allocator. Typically this is a fixed block size allocator. If you are going to be allocating a lot of objects of the same size (and you have control over the size), then you can make every memory allocation through that manager the same size. This makes it very fast for the allocator to find the next free allocation.

mythrando
Автор

I'm still confused on why state machines should be used and why there implementation get so complicated in other people's vids and games. can you make a vid on this topic

bini
Автор

saw a script reading extends resources script. what exactly is resources, and how to utilize it in godot? im mainly confused with the export function because of that, i mean it is in your game, why export, cant you just refer to them when you need those inside the resources script to be used by other scripts?

erkling
Автор

Honestly I still don't know what to do when there are many enemies spawning bullets, do I put timers on the bullet scene so after X seconds they queue_free? is that a bad thing?

bubblemage
Автор

Lol, pooling has nothing to do with whether or not you have a GC, even C# handles extremely well with thousands of small objects being instantiated and deleted from memory at runtime (it's pretty much instantaneous for most of them, just not for big objects). The cost that pooling solves is mainly having to allocate memory, which is itself an expensive operation for the system (i.e. compared to simply reusing).

diadetediotedio
Автор

Wait, but if I use C#, only the C# classes are subject to GC? The default GD nodes should behave as usual, so why frame freezes? Or if I add C# script, it recreates whole node in C#?

syriuszb
Автор

Any notable downsides if you go with pooling anyway? besides overhead of actually implementing it

EisenFlammeberge
Автор

Hello can you tell us how to use enum effectively.

shardaojha
Автор

Someone made a video about this a year a two ago and you do, in fact, need pooling when you have a large number of nodes. Juan's post was just misinformation and I don't know why he wrote it honestly. He says these kinds of things anytime someone brings up performance in godot.

rainsong
Автор

If you wanna make a GOOD survivors clone (or any game with bullet hell, f.e. Tohou, Enter the Gungeon, etc.), you'll need this. There, answered the question.

hiiambarney
Автор

How come more people don't Animate with Godot? It has a really powerful animation tool.

ianmclean