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

Game freezes during long actions (crafting/reading/disassembling etc) #288

Closed
SilearFlare opened this issue Dec 23, 2020 · 3 comments · Fixed by #295
Closed

Game freezes during long actions (crafting/reading/disassembling etc) #288

SilearFlare opened this issue Dec 23, 2020 · 3 comments · Fixed by #295

Comments

@SilearFlare
Copy link

SilearFlare commented Dec 23, 2020

Describe the bug

All of the sudden after two seasons, the game has become horribly laggy, but only when crafting/reading/disassembling, and in weird spurts. It starts, runs fine for a second, but for each second it freezes for another 5/10.
I've managed isolate the problem to the overground by disabling Z-levels and going underground: crafting, sleeping etc runs fine there.

I've included the save (actually the entire folder, since there's a lot of custom stuff in there) in the zip. Just uh, ignore the red warnings, they're nothing gamebreaking but I did some fuckery to fix PK from crashing on startup, but since it's mostly PK items that got removed that really shouldn't be the problem.
I've fucked around with overmap teleportation and editing the time after finding out the problem, but that did nothing.

Steps To Reproduce

Unzip the zip and just read or craft anything above ground.

Expected behavior

Not that.

The whole dang thing

https://files.catbox.moe/hffgdu.zip

Versions and configuration

linux, curses, 64 bit :^)

@olanti-p
Copy link
Contributor

olanti-p commented Dec 23, 2020

A cursory glance through profiler shows that ~90% of CPU time is spent in game::overmap_npc_move on pathfinding.
image
This looks suspiciously like CleverRaven#44452

@Coolthulhu
Copy link
Member

Looks like the NPC is trying to reach an island or a bit of land that is "effectively an island" by the virtue of being very far from nearest connection to the NPC.
The get_npc_path function is not equipped to deal with cases like this. It is also incredibly unoptimized, performing multiple string comparisons per tile.

There's no trivial fix. For now, I propose a vile hack: a NPC that fails to find an overmap path, becomes dumbstruck and refuses to (overmap) path until loaded into reality bubble at least once.

A proper solution would be to generate reachability maps, either for preset path types or on-demand.
The problem is combining the results from multiple overmaps: it is unacceptable to run an algorithm over an unbounded number of overmaps. Having to recalculate it over nearest 9x9 overmaps might be doable.

It would help a lot to cache the terrain types properly instead of literally checking "do the first 4 characters of the terrain type match the word 'road'?". The check should look like "does this terrain type have a 'road' flag?", with the flag ideally being an int (I think DDA has inty flags, I'll need to grab that someday).

@SilearFlare
Copy link
Author

Oh wow, I really just thought that my PC was being extra janky as usual.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants