Bolt 2’s flagship feature will be C# Script Generation. Both Flow Graphs and State Graphs will be automatically converted to C# scripts in order to maximize runtime performance. Thanks to Unity’s IL2CPP pre-compiler, the C# scripts generated from graphs will be in turn converted to C++ upon build, meaning users will benefit from native performance while using visual scripting. Our goal is to put an end to the compromise between workflow and performance.

Performance Gains

The Bolt 1 runtime uses reflection to execute the content of its graphs, be it invoking to invoke methods or access fields and properties. It is well established that reflection is significantly slower than direct invocation, which is why there are already multiple optimizations in place to mitigate this effect:

With these improvements in place, we are already seeing a significant speed boost over traditional reflection, which is enough to run most games on modern architecture, even on mobile and consoles. However, there is additional overhead due to:

This overhead cannot be mitigated with the current approach. This is in part why we are moving to C# script generation. In short, we want Bolt to support:

More generally, we want every developer to be able to trust Bolt as a performant, long-term solution that will never be the bottleneck of their end-product.

Evaluating the exact performance gains of C# script generation is not possible, because it wildly varies per use-case. However, we if take some rough benchmarks as a baseline, we can expect the following results for a method call:

Speed Comparison (Lower is better)

As demonstrated in this example case: