Announcement

Collapse
No announcement yet.

Why is BP slower than pure C++ ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Why is BP slower than pure C++ ?

    I started to look into C++ and learned that in UE4 it is possible to write own nodes in C++. So i assume every node in the engine is written in C++. So basicaly when a node gets executed there is a C++ code running. Now, if that is the case then why is BP slower than pure code ?
    I already googled but only found posts which were about the difference in speed.

    #2
    I believe that every blueprint node is separate c++ function that need to be called. Faster to have only one c++ function instead with the same functionality (written in c++ language that communicate more directly with the engine) that you want create as blueprint.
    Last edited by SaOk; 01-12-2019, 06:20 PM.

    Comment


      #3
      Code in blueprints needs more CPU instructions to perform task than C++. C++ is compiled by visual studio to native CPU opcodes.

      I am not quite sure how unreal runs blueprints in packaged game (never bothered to check this really), but i think it interprets blueprint nodes in runtime, then finds single node implementation and runs it (calls C++ code). Compiled C++ has all that runtime interpretation already done by visual studio compiler.

      Also when you create function in C++ all code inside is run together. When you create blueprint code each instruction is like separate function in C++. Arguments need to be read, node for single instruction called, then results saved to variable. That all platter code adds up quickly, when you consider that real work of some basic blueprint node can be less than 10% of all code needed to run it. And 90% is that calling function, storing variables, loading them etc.



      Comment


        #4
        Blueprint functions are objects containing info about the C++ function to call. These objects have a runtime cost, they cost cpu, ram, etc.

        They can't be inlined by the compiler, accessing objects in RAM will always be slower than accessing objects in L1, L2 or L3 cache levels or inlined methods.

        Calling a C++ function directly, skips all of that depending on what exactly you're doing and if compiler inlined your function or not;
        But it's way easier to make "stupid moves" in C++ than Blueprints and it's unforgiving if you do so.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment

        Working...
        X