x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Does UFUNCTION have impact on performance?

Hi

I have a probably silly question.

Does the UFUNCTION or UPROPERTY or USTRUCT or UENUM decorators have impact on code performance? I'm wondering, because those macros aren't required in many situations (when I don't want to use this code from blueprints etc.). I wanted to search for variables that have UPROPERTies for no reason but I'm not sure if it is worth the time spend on refactor.

Are UE perform any extra actions for properties and functions that have those decorators?

Product Version: UE 4.7
Tags:
more ▼

asked Aug 03 '15 at 05:37 PM in C++ Programming

avatar image

zompi2
755 24 48 145

avatar image Corpse0327 Aug 03 '15 at 06:41 PM

Not runtime, but compile time.

EDIT: Wait, it does. But just load time, nothing else. Only UPROPERTY().

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

It does not impact the performence as when you call those function and propeties you normally access them, what UHT does to it (since those macros are empty and does nothing in compile time) it use them to know which functions should be reflected and generates reflection code, which register information about propeties and functions in to memoery, which happens when code module (dll with your code) is loaded and does not take noticable time. Only problem with those macros is it's bounded with capabilities of reflection system, you can't use stuff that it does not know.

You don't need to use those macros if you don't want to, only required one is UCLASS() on UObject classes, but then editor won't able to see those things and some engine features require them (like timers and delegates requires reflected function), so if something does not work or crash for odd reason then check if reflecting stuff can fix it. There might be also potential GC problems as engine automaticly deletes objects that are not pointed in any reflected pointer, assuming it a forgotten garbage. I recommand you to use UPROPERTIES on all varables and structs as it let you use commands like "DisplayAll" or "GetAll" allowing to view varable current state which is useful for debuging, it's a lot better then VS watchers.

more ▼

answered Aug 03 '15 at 07:04 PM

avatar image

Shadowriver
37.3k 936 172 1116

avatar image zompi2 Aug 03 '15 at 08:02 PM

Thank You for a thorough answer. The one think I wonder is GC and reflection. Doesn't GC iterate through bigger list of objects it has to check? I understand that the execution of function itself is like in normal c++, but what about systems that uses those macros to list objects and properties for checking?

avatar image Shadowriver Aug 03 '15 at 08:52 PM

I think shipping build don't use that in large extend as editor does so there should not be concerned. UObjects are forced to use UCLASS() so you won't avoid GC here, as for property i don't think adding few pointers of specific type will effect preformence in notable way. GC do check every specific time (every 30 sec by default if i'm not mistaken), so if GC will have too much work the symptoms will be small freeze or drop frames every time he does that

Etherway you want to study it i recomand you to use profiler (Window->Session Frontend) you can have exact info on what takes more time and eats your FPS.

https://docs.unrealengine.com/latest/INT/Engine/Performance/Profiler/index.html

avatar image zompi2 Aug 03 '15 at 08:55 PM

Thanks once again :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question