Search Unity

Bolt & C# performance question

Discussion in 'Visual Scripting' started by TheGamery, Apr 19, 2021.

  1. TheGamery

    TheGamery

    Joined:
    Oct 14, 2013
    Posts:
    94
    I have a large project (AAA-ish grade) and looking at moving to a hybrid of Bolt/C# in order to make the code more accessible to artists whilst keeping more complex code in their own C# files but referenced in Bolt much in the same way Unreal Engine works with Blueprints & C++ files, I've read that Bolt is ~5x slower than C#, is this always the case or will this be less of an issue for us as complex code will be in C# files rather than all visual scripted?

    Does anyone have any experience with this?

    (Our project is CPU limited so it's very important that Bolt doesn't create too much excess overhead.)
     
  2. If you're already CPU-bound it is a bad idea to put more workload on it. Even the best VS-solution, hypothetically if it compiles down to C# will put more CPU-load on your game since you're introducing a new abstraction layer.
    But existing VS-solutions like Bolt are interpreted graphs, they are very slow.
    Obviously this all depends how much your game is CPU-bound and if you can do something about it.
     
  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,062
    Bolt currently is 5-10x times slower than C# because it runs mostly using reflection. Calling stuff in Bolt from C# scripts the regular way also involves reflection based calls to the scripts. You can gain some performance by custom coding Bolt nodes but it can be a pain with the current, poorly documented custom node API. And the API is in the process of being replaced entirely.

    Unity are working on a new interpreted runtime that's supposed to be around 12x times faster than the existing Bolt runtime. It *should* drop sometime later this year. That said, any VS tool will always have a performance overhead - you trade performance for flexibility.
     
  4. gfrast

    gfrast

    Joined:
    May 5, 2014
    Posts:
    30
    I've made a few performance-comparisons in this thread here.

    Without any C# optimizations it is quite slow, yes. Performance-wise, you can't compare it to UE4 Blueprints (like others already mentioned, Bolt uses reflection)

    BUT, basically it boils down to on what you want to use Bolt for. Imo its totally feasable to use it if you pack otherwise performance-heavy code into custom C# nodes.
    I'd recommend to just create a graph like you'd imagine it in your project, run some tests and see if it fits your project or if it takes too much performance.

    I can't share the experience that its too difficult to find information on custom nodes tho - took me some digging and just a few hours of trial and error, and i was able to replicate any node. Granted, that info wasnt official and rather some youtube tutorials.

    Here you can find a nice collection of custom nodes, in case you're interested in reverse-engineering them:
    https://github.com/RealityStop/Bolt.Addons.Community

    The Wiki also has some insight on how they work:
    https://github.com/RealityStop/Bolt.Addons.Community/wiki
     
    Deleted User and TheGamery like this.
  5. TheGamery

    TheGamery

    Joined:
    Oct 14, 2013
    Posts:
    94
    Your tests seem to suggest the performance difference would neglible or at least worth it given the productivity gain from using Bolt, and I suppose if a particular piece of code was troublesome that could be run outside of Bolt entirely, I shall go ahead and give it go, thanks!