Cocos Performance Discussion

Hi all,

I’m new to Cocos. Our team is looking for a new home after what happened to Unity. We’re trying out Cocos Creator and liking it.

Over at Godot reddit, someone posted a detailed break-down of why Godot’s engine bindings will result in some bad performance. I can’t post the link, but you can search for “godot is not the new unity the anatomy of a godot api call”

I’m a technical designer / application engineer, so I don’t like to work in engine code, but I also care a lot about performance.

How does Typescript interact with the cocos engine?
Is it JIT?
Will we run into similar performance bottlenecks outlined in the article while using Cocos Creator on Android / iOS?

Thank you!

Could you send the article link as well so we can look further?

Firstly, Cocos uses v8 to run JavaScript (compiled from TypeScript) code with JIT enabled on all platforms except for iOS (doesn’t allow).
Secondly, cross language binding API calls always have noticeable cost in almost all engines, there is no surprise here. But we have a very long history of using and improving javascript binding performance, it’s mainly related to invocation count, parameter unpacking and return value packing. Currently, Cocos has found a very nice binding layer to limit the invocation between JS and C++, take a look at the following chart

So you can see the main binding invocation happens when components needs to initialize data in renderer and assets loading. They are all low frequency calls during loading and initialization of Renderer components. As for high frequency Node transform modification, we have shared memory design between JS Node and C++ Node, so all modifications happen in JS with JIT, while it also sets a dirty flag to the shared memory chunk. In the C++ main loop execution, we will check the dirty flag to update Node transform in C++ directly, so no direct binding calls involved.

These know-how has been cumulated during the last ten years, and we will continue to improve the engine performance in all aspects.

1 Like

Thank you so much for the detailed response!