Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf / Crash: Hiring dwarves in large numbers at one time will eventually crash game #944

Closed
com1clyf3 opened this issue Oct 20, 2018 · 18 comments
Labels
A Bug High priority bug Crash Economy Features found in economy menu Performance Issues with lag, graphics, FPS, etc

Comments

@com1clyf3
Copy link
Collaborator

Okay. So I took a look at our hiring dwarves question.

For some context, the below save is in a world with a large amount of monsters in it, due to a large cave biome + a huge amount of snake spawns (maybe due to the desert biome?). The only way to actually progress naturally was to wage spawn war, by hiring a wave after wave of axe and muskets until the area was safe enough. So this is all technically a realistic play situation. It was the only way I was able to continue on anyhow. This behavior leads to a crash, which makes games like this one relatively short (maybe a couple of in-game days at most).

Hiring dwarves in large numbers, all at the same time, considerably reduces FPS. The more you already have, the more this slows down the game ( i think?), FPS dipping to maybe 0-2 FPS for a few seconds. Eventually this will lead to crash.
Repro:

  • Go into hiring screen and hire five, ten, or more at once. Enter game.
  • Then go back, hire more in the same fashion. Observe FPS taking a hit when dwarves are first spawned and gain tasks.
  • Continue this and eventually game crashes to desktop soon after a large hire.

Some solutions:

  • Some of this could be avoided, at least in Normal difficulty, by working on Design: Turn down high-level enemy spawns in normal difficulty #937.
  • balancing something else, for instance giving the dwarves units better starting stats, making the need to hire less urgent, deaths less frequent, etc.
  • Allow the player to hire as many as they want, but instead of spawning all dwarves at once, have the game deliver new hires in a paced manner, maybe once every half-hour in game.

It's important to note that the game seems fairly stable with a large number of dwarves. It's mainly the hiring that appears to be stressing things.

One other aside. It's currently very difficult to hire multiple dwarves at all. Can we add something to hire 5x/10x? The player will do it anyhow, and we're only causing it to be annoying to do so currently.

DwarfCorp181018_CallerCalleeSummary - profiling.zip
Bead Realm_411_131843937514660019.zip
Bead Realm.zip

2d713bb

@com1clyf3 com1clyf3 added Performance Issues with lag, graphics, FPS, etc Crash Economy Features found in economy menu A Bug High priority bug labels Oct 20, 2018
@mklingen
Copy link
Collaborator

Thank you very much for looking at this. I think I'm going to do the following.

  1. Add a delay between when you hire a dwarf and when the dwarf arrives. Maybe one dwarf per hour or so.
  2. Cap the total number of dwarfs you can have in your colony for performance reasons. This will be a parameter that you can adjust in the game settings -- so that if players get annoyed by the cap they can increase it and suffer the performance hit.

It's worth noting that other games in this genre simply don't allow you to get new colonists on your own, instead they have colonists arrive without your intervention so they can balance this quantity over time. I wanted DwarfCorp to give the player more control, but perhaps we gave away too much control!

@mklingen
Copy link
Collaborator

I fixed several crashes/issues in this save, but I suspect not the underlying issues you were experiencing with hiring yet.

@mklingen
Copy link
Collaborator

Okay, I have limited the maximum number of dwarfs to 40. I have made this a parameter that players can control in the settings menu. I have also added a delay to hiring dwarfs that is a random number of hours between 2 and 6.

@mklingen
Copy link
Collaborator

@com1clyf3 let me know if this is still a problem

@com1clyf3
Copy link
Collaborator Author

com1clyf3 commented Oct 23, 2018

This is still a problem. Got a crash. Again, it's likely multifaceted. I'll try and add a detailed report like last time.

One thing I notice is that if you hire a group of dwarves, they still show up all at once, just later. Wouldn't it be better to pace out their arrival? Like one every hour?

@mklingen
Copy link
Collaborator

Okay, I'll pace out their arrival even further. I really need the stack traces on those crashes btw... otherwise it's kind of useless

@mklingen
Copy link
Collaborator

I've spaced out dwarf arrivals so that one happens each hour.

@com1clyf3
Copy link
Collaborator Author

Given that I used this to stress a crash, I'd suggest making the time between dwarves longer. Let's say three hours.

@mklingen
Copy link
Collaborator

I don't understand how this could have possibly caused a crash for you, or why it possibly makes performance worse....

@com1clyf3
Copy link
Collaborator Author

I'll take some sampling to verify it's actually stressing things.

@mklingen
Copy link
Collaborator

even with 1 dwarf an hour it slows down your FPS by that much?

@com1clyf3
Copy link
Collaborator Author

image

Things have improved, but still not shippable.

So maxed out my hires to 40 by hiring in phases of ten. Good news is that maxing out hiring with the new spacing is not crashing the game (or hasn't so far, anyway). Bad news is it's not passable performance-wise.

Around 20 or so dwarves, FPS slowed down in 3x to 1-2FPS. 1x was still a workable 1-7 FPS.
As you scale past 30 , 3x remains near 1 FPS. 1x 1-3FPS
A full 40 will keep 1x at 1 FPS and 3x at 0-1 FPS

Took some sampling:
DwarfCorp181025(1)_ThreadSummary.zip

Here's the 40 dwarf save:
Giruholand.zip
Giruholand_34_131849952588870579.zip

77e0c8e

@com1clyf3
Copy link
Collaborator Author

I think making new hires more expensive is a fix we should consider. It would naturally pace how many get hired at once.

@mklingen
Copy link
Collaborator

When you create dwarves through the god menu, do you similarly get really bad performance?

@mklingen
Copy link
Collaborator

For reference, as usual, I get 60 FPS even with about 100 dwarves.

@mklingen
Copy link
Collaborator

We might also just want to beef up performance requirements on Steam so that people with computers as low powered as yours will be warned away from buying the game.

@com1clyf3
Copy link
Collaborator Author

com1clyf3 commented Oct 26, 2018

Okay. Spawned 40 dwarves into a flat debug world. With no tasks at all assigned and no other entities, performance is not affected at all. FPS is totally humming at 1x,2x, and 3x.

Once you assign some tasks, things do begin to falter, somewhat, but not nearly as bad as in a long game. At 1x with tasks, everything is pretty much normal. At 3x with tasks, FPS fluctuates from ten or so seconds running normally to ten or so seconds running at 01-8 FPS. Good news over-all. Took profiling in release mode, just in case, but assuming we should focus on long plays instead of hiring.

DwarfCorp181026_FunctionSummary.zip
flat_4030.zip
flat_4030_638_131850566276203953.zip

77e0c8e

I'm going to go ahead and open up a separate issue for long term play perf issues, and then link it here.

#966

@com1clyf3
Copy link
Collaborator Author

com1clyf3 commented Oct 31, 2018

40 miners at 3x digging an entire mountain now works pretty smoothly. Few little lags here and there, but it's working great regardless. Considering this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A Bug High priority bug Crash Economy Features found in economy menu Performance Issues with lag, graphics, FPS, etc
Projects
None yet
Development

No branches or pull requests

2 participants