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


#11

This should be fixed in recente versions, or you are seeing a common monster not spawned from the fog.

It does not. The A.I. will only search for its own (faction) items. Those are not owned by anyone and will not be considered by anyone, unless you manually order it to be looted.

When someone tries to haul something, even before starting it, the item is marked as “busy” and no one else will even try to search for it.


#12

well, then thats probably not it… (smart sollution, go devs!)


#13

I thought logs that aren’t for “its own faction” are outlined red. Guess that’s not the only thing then.


#14

Red are for enemies, yellow is neutral, white is owned by yourself.


#15

So that’s where all these random wooden logs are coming from!


#16

Just to add some more info to this troublesome issue. I have been noticing the perpetual idling or amnesia of hearthlings at less than 20 hearthlings. Around 14 or 15 typically for me. In addition to this yes my game is modded and is the reason the crafting UI takes a couple of seconds to load. However would this be creating issues for general gameplay? Additionally I am noticing that the ai lua is being dominated by other processes (primarily light blue [sorry cant remember the name properly]) I do not receive any crash or issue notifications for the most part except when having an issue with a mod. I am using the 64 bit version of the game with the graphics adjust to mid level, I am using an intel i5 4690K, 16Gb of RAM, and an NVidia GTX 1060 ASUS RoG with 4Gb of RAM. Oh and the game is installed on a SSD. I dont know whether I am missing something here but I am getting bothered by the lag in reaction timing from the game, I would understand if my system was budget but this is anything but. It’s not bleeding edge but if I can run Fallout 4 with max graphics, the HD texture pack and 147 mods why can’t i run this just as well? (I realise this is in alpha, but so was Rimworld, Rise to Ruins, Castle Story just to name a few similar games I am currently playing as part of their early access.) Are the devs any closer to a solution to this issue? I ask only for the fact that another game i liked, Clockwork Empires, flopped because they spent more time making it look shiny and not bug fixing. I was disappointed with that one and would hate to see Stonehearth fall to the same fate. (Again I realise that the dev team is more than likely working on it but I have not seen a desktop Tuesday tackle this specific problem and even address how it can be alleviated even a little by the user.)


#17

P.S. Soooooo Sorry for the wall…


#18

@PFC_Calico As a general rule of thumb, before they get the game optimized further, you generally want to save and restart your game every couple of hours. While I do notice that at 20 Hearthlings my game bogs down, a lot of times all it takes is reloading to help fix some of that. The game was, once upon a time, far worse when it came to performance.

Making sure to have containers to stow all your stuff in helps loads, too. If you go on a serial tree-killing spree, do it in bursts rather than one huge wave. Give your hearthlings time to clean up the mess. In MP, I’ve noticed that a lot of people will chop down huge swathes of forestry right at the outset and simply leave at least two hundred logs laying around on the map. When you’ve got four people all doing the same thing, it slows things down heavily.


#19

We’ve already started to work on performance. In fact, several of the errors from the last unstable releases were caused by some optimizations that we were trying.


#20

Well, er… I am very embarrassed. I re-read the post with a fresh head today and am very ashamed that I came across ignorant and obnoxious. Not my intention, and I apologise.

@Spell_Blade, thanks for the tips, I will try to replace as many of the stockpiles with storage containers. Today I was beginning to get issues with slow down after 10 hearthlings. I also had the goblin chieftain and one goblin fire pit but no loose items apart from what was in my 1 stockpile. (I try to live hand to mouth as much as possible to help alleviate the known issues)

@Relyss, again I am saying many mea culpa’s and only want to see stonehearth succeed where so many early access games fail, even in-spite of their awesome communities. But I thank you for your patience and quick reply.