NLua performance and other differences

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
diccon
Posts: 27
Joined: Wed Sep 23, 2020 2:20 pm

NLua performance and other differences

Post by diccon »

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.
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: NLua performance and other differences

Post by Tony Li »

Thanks for your analysis. I'll look into the Variable["this/that"] issue. The Dialogue Editor's Database > Global Search & Replace be useful in the interim. It sounds like the issue is that the DialogueLua code for NLua doesn't convert "/" to "_" in table indices like it does with the built-in Lua, in which case it's something I'll need to fix in 2.2.17.
Post Reply