0 votes

When I use GDNative plugin writen in C++, can I gain more performance by using standard library containers (adequate to use case) instead Godot's Array, Dictionary?

Godot version 3.4.2
in Engine by (25 points)

1 Answer

0 votes
Best answer

A little late, but better last than never.

From my experience working with the the Godot engine you can get massive performance gains by using the standard library containers/classes in Gdnative. You could get more if you write your own, As the standard library containers are generics and not specific to what you are trying to do. Rewriting your own container class is of course not recommended , just an option.

This is apparent when you do anything that is sizeable, because they don't have to run within the constraints of the engine. Generally most classes that are that are within the the engine are good enough for general usage. Yet can have crashing issues or performance issues depending on what you are doing. By sizeable for example I mean do string manipulation on strings bigger than 100000 characters, same thing with most built in classes, Arrays, Dictionary, etc.

Gdnative is a bit of a learning curve though, and will require you to learn a decent amount of the engine to get things done, but if performance is an issue then you should be using Gdnative to do the heavy algorithms within to compute values and pass them back to the engine.

I will link a Youtube video below that helped me get started, I didn't make this, but it definitely lead me in the right direction. GL

10,000 subs GDNative YT

by (286 points)
selected by

Thanks for answer. I have tried migration of code to std containers and got performance boost.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.