Lua performance


#1

Currently Lua performance becomes increasingly bad, consistently hitting the roof at 17-20 hearthlings (around 85-90% when not paused). Framerate virtually stops. Anyone else experiencing this?

Win7 x64, A24.5 r821

Update: Relaunching the game fixes the problem for next 10-15 minutes, hinting at the possible leak.
Update2: Usually happens when the game hits 2 Gb RAM (I have 8 Gb). Since the game generally uses 1.5 Gb on startup, there is a time frame for normal performance.
Update3: Don’t know why, but at some point Stonehearth splits to 2 processes with combined RAM drain of 2.5-2.7 Gb.


#2

When i Run Stonehearth for over 2h straight, it spikes up to 8-14 GB RAM usage (over 30 Hearthlings)
I can confirm the 2 processes


#3

Yeah, I get the same issues. It’s why I wind up restarting my little villages constantly.


#4

I believe the two processes are there because they recently (Alpha 24, or perhaps even Alpha 23) switched to a client/server model for integrating multiplayer. So even in single-player, there’s a server process that’s handling all the game logic and a client process that handles the player experience.


#5

It’s been that way right from the start, they chose that model because the game was built with multiplayer in mind. It seems like the server process is a little more resource-hungry after the last couple of updates though, which is interesting.

That said, the “after 2 hours the game slows down to a crawl” has been observed for a really long time, so while the last couple of updates might have made that worse, this isn’t a new issue.

The good news though is that saving, exiting and re-starting the game seems to clear most of the slow-down and lets you get back to playing again. Inconvenient to be sure, so I hope they sort it out soon.


#6

Yeah, but that only works if the group of hearthlings isn’t very large. If there’s a lot going on with the map, restarting doesn’t help that much.


#7

I noticed today, that it really started after i defeated the first goblin chieftan. (that is when the lootfest begins)

On top of that i had alot of resources awaiting collection in the wild.

I stopped all orders and gave the hearthlings time to clean up the map.

It was a pain to just sit and wait, but after they cleaned it all up, the Lua went down to normal and i could continue my game…


#8

That suggests that maybe the slowdown is connected to many unlooted items and AI not being sure what to do next.


#9

The lua uses up to 85%, leaving almost no room for the AI processes and thus causing the hearthlings to be idle.
I still do not know why they’re literally lagging around when moving. This also does affect animals and monsters as well. Perhaps it’s a server side thing.
With the new weather feature, this may also have a negative impact on AI perfomance for the following reasons:

  • Fog causes monsters to spawn all over the world, sometimes, or not even at all, despawning them when the fog is over (still had zombies lying around after the fog). While they are idling around, I’m certain they still use up some of the resources

  • Thunderstorms may hit trees, causing them to drop wood (i.e. more unlooted items on the map). Even though they’ve reduced the rate of lightning hitting an object or hearthling, they can still hit nonetheless, slowly filling your world with wood, most of the time unreachable for hearthlings. While I’m not a programmer myself, I’m sure this causes the hearthling’s AI to try picking up the wood from the lightning, though this command may be overburdened by high priority tasks such a building or picking up nearby items instead, leaving an endless loop of commands and thus consuming more resources

Again, these statements are just theoretical as I’m not a programmer and don’t know exactly how the code works. However, I do see a negative perfomance impact from weathers as one of the possibilities.


#10

To add to what @fornjotr said, try experimenting with how many people have hauling as a job, I could actually improve my experience by limiting the amountt of criss-crossing haulers

Edit @Cusuno what mainly kills “brain power” is calculations, specifically loops. Stuff that has to be done again and again and again…
My current guess is the programming is fighting itself somewhere (this is why more hearthlings makes it slower instead of having more manpower to throw at problems)
For instance haulers having to double check if someone else is not going to haul a block. If you have four lings, that’s 3 checks. If you have 20 lings, that’s 19 checks… Per hauling heartling. Going from a net 12 checks to nearly 4000 checks just to get them to haul things… That kinda stuff