NLua performance and other differences
Posted: Mon May 10, 2021 3:17 pm
Just an FYI post really, I've been a bit concerned about the performance of Dialogue System for our game since we're pushing for 60fps. Even for a simple one-liner using the more lightweight bark subsystem it was allocating 227k and taking 6.7ms to display a single line.
edit: image isn't showing up, you can see it here https://zippyimage.com/image/speech-eve ... warm.zjqSm
The deep profile showed that most of this came from the EvaluateLinks function in the conversation model which calls lua repeatedly so I looked into optimizing the interpreter and also tried out NLua which gives a significant gain, reducing memory allocations to 49k and execution time to 3.3ms.
edit: image isn't showing up, you can see it here https://zippyimage.com/image/speech-eve ... rm-2.zjyyX
This is still a lot imo but its a good gain without having to make significant modifications to Dialogue System (and subsequent merge headaches on updates).
Some other interesting changes are:
- underscores in conditions don't seem to work anymore, where I previously had Variable["this_that"] I had to change it to Variable["this/that"]
- object binding is way better in NLua, you can just push any .NET object into the VM and call its methods and properties from with Dialogue System. If anyone is interested I can make a follow up post on that.
edit: image isn't showing up, you can see it here https://zippyimage.com/image/speech-eve ... warm.zjqSm
The deep profile showed that most of this came from the EvaluateLinks function in the conversation model which calls lua repeatedly so I looked into optimizing the interpreter and also tried out NLua which gives a significant gain, reducing memory allocations to 49k and execution time to 3.3ms.
edit: image isn't showing up, you can see it here https://zippyimage.com/image/speech-eve ... rm-2.zjyyX
This is still a lot imo but its a good gain without having to make significant modifications to Dialogue System (and subsequent merge headaches on updates).
Some other interesting changes are:
- underscores in conditions don't seem to work anymore, where I previously had Variable["this_that"] I had to change it to Variable["this/that"]
- object binding is way better in NLua, you can just push any .NET object into the VM and call its methods and properties from with Dialogue System. If anyone is interested I can make a follow up post on that.