Advertisement

High Lua engine call rate

Started by May 11, 2018 06:35 PM
1 comment, last by Kaptein 6 years, 4 months ago

Hello all. I'm currently mid developing a game with my engine. There is currently a stage during loading that takes 21ms, where the script is creating lots of objects by calling into the engine. I noticed that each extra call needed to fully define an object cost me around 3ms overall. I was prototyping using a lua table to model the whole object to reduce the number of calls, but its a slight pain to implement. Right now 21ms is not very noticeable. However as development progresses I will eventually reach that 3-digit millisecond number where its noticeable during loading.


*** Entering 'treskott_village' (in maps/overworld) on start
[18:36:48] INFO: Loaded map 64x64 (F= 2 L=6, 24576 tiles)
-> Loading tiles took 1.77 milliseconds
-> Adding MOD scripts took 1.13 milliseconds
-> Adding MAP scripts took 0.09 milliseconds
>> Player life delta=64
Tile scan callback took 0.031000.2 milliseconds
Tile scan callback took 0.412000.2 milliseconds
Tile scan callback took 0.102000.2 milliseconds
Tile scan callback took 0.138000.2 milliseconds
Tile scan callback took 15.023000.2 milliseconds
Tile scan callback took 0.229000.2 milliseconds
*** Tile scan objects created: 618
>> Map season is 
[18:36:48] WARNING: Image already loaded: bitmaps/npcs.png
-> Calling entry functions took 18.14 milliseconds
Loading map took 21.44 milliseconds

How do you go about making it take less time?

 

EDIT: I thought about some instancing-like behavior, but it still requires some calls to the engine to at least move the object. I guess that will greatly reduce the time compared to what is going on now.

Does anyone have a ballpark number for when players really notice the loading time?

For posterity: I ended up implementing a call that can clone an object N times. So for say 600 trees: Create one tree in Lua, ask engine to clone it 600 times and return a list of 600 ids. Then iterate in lua over IDs and move the new objects into place. It cut really deep into the loading time which is now at 11-13ms.

This topic is closed to new replies.

Advertisement