Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3

Author Topic: Is there a way to tell what is slowing me down?  (Read 10274 times)

Talanic

  • Bay Watcher
  • Struggling author / pizza delivery guy.
    • View Profile
Is there a way to tell what is slowing me down?
« on: March 12, 2012, 10:22:09 pm »

This has happened several times now.  I play a fortress, keeping the number of dwarves low to preserve frame rate.  I've modded out clothing and I make only very expensive craft items (steel battle axes, for example) to minimize the number of items.

Then, I get an invasion.  Or, sometimes, a caravan.  And my framerate goes from 125 / 180 down to 39-45.  Even after the invaders have been repelled or the caravan has left (even if I took nothing) my fort is down the tubes because there's no way I know of to recover from that frame rate hit.

No flows.  No abundance of items.  I'm at a loss.  Any clues?
Logged
I'm an aspiring Science Fiction and Fantasy writer.  I'm telling the tale of a hapless cyborg everyman lost in a savage fantasy world.

My first review from a real magazine!

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #1 on: March 12, 2012, 10:25:45 pm »

There is an unavoidable performance degradation that occurs, apparently just because of items having ever been on your map.

I can only speculate, but it might just be a giant array or vector of items that just never really gets cleaned up, and as the game goes on, this vector keeps on getting filled up with items that, even when they are destroyed or permanently removed from the map, are still taking up some sort of reference slot in memory, and the game keeps on checking past them.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

TeleDwarf

  • Bay Watcher
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #2 on: March 13, 2012, 07:28:23 am »

Have you tried saving, rebooting and restoring? does it change framerate anyhow?
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #3 on: March 13, 2012, 07:39:04 am »

There is an unavoidable performance degradation that occurs, apparently just because of items having ever been on your map.

I can only speculate, but it might just be a giant array or vector of items that just never really gets cleaned up, and as the game goes on, this vector keeps on getting filled up with items that, even when they are destroyed or permanently removed from the map, are still taking up some sort of reference slot in memory, and the game keeps on checking past them.

I strongly suspect that this is the case as well.  Are there any utilities that will allow you to view the entire item list and permanently destroy items?  Can DFHack do this?

It's not an ideal solution, but might be something you could try if you're desperate.
Logged
Through pain, I find wisdom.

Kogut

  • Bay Watcher
  • Next account: Bulwersator
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #4 on: March 13, 2012, 08:03:58 am »

I also noticed this problem, now I am trying to produce a bug report with:

*save before event and decent FPS
*save about season later, with the same number of items ad creatures and half of FPS

This should help Toady to track this problem. It may be related to clothing (even in games without clothing items), so maybe upcoming fixes will end this.
Logged
The worst bug - 34.11 poll
Tired of going decades without goblin sieges? Try The Fortress Defense Mod
Kogut, the Bugfixes apostle of Bay12forum. Every posts he makes he preaches about the evil of Bugs.

Rhodan

  • Bay Watcher
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #5 on: March 13, 2012, 03:14:01 pm »

Does this mean FPS death can be postponed by embarking on a site with no access to other civs? Less traders would mean less imported items and thus less clutter.
In theory, putting the trade depot behind a narrow passage would also prevent wagons from entering your site meaning even less items from traders. (Wagons are basically garbage trucks anyways, taking away your useless goods)

This might be useful for people who suffer from severe FPS slowdown in older fortresses.
Logged

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #6 on: March 13, 2012, 03:38:50 pm »

There is an unavoidable performance degradation that occurs, apparently just because of items having ever been on your map.

I can only speculate, but it might just be a giant array or vector of items that just never really gets cleaned up, and as the game goes on, this vector keeps on getting filled up with items that, even when they are destroyed or permanently removed from the map, are still taking up some sort of reference slot in memory, and the game keeps on checking past them.

I strongly suspect that this is the case as well.  Are there any utilities that will allow you to view the entire item list and permanently destroy items?  Can DFHack do this?

It's not an ideal solution, but might be something you could try if you're desperate.
I also noticed this problem, now I am trying to produce a bug report with:

*save before event and decent FPS
*save about season later, with the same number of items ad creatures and half of FPS

This should help Toady to track this problem. It may be related to clothing (even in games without clothing items), so maybe upcoming fixes will end this.

That's not the way this works, it's a structural programming issue.

If the way this works is the way I think this works, Toady either has to be using a vector, or else a custom-made data structure that behaves in vector-like ways.


The probable problem is that what we are dealing with is a very, very large list inside of a very, very large vector.

When a programmer deals with a large list in an array or vector, even when they have to continually add or subtract values, they tend to avoid sorting like the plague.  (Think of it this way - if you have a list that has 100,000 entries in it, and you erase something from that list, and think the blank space on that list is ugly, are you going to write in the piece of information on the space on your list below that into the blank spot, erase the piece of information that you just copied, then copy the information in the space below that up, over and over and over again every single time you mark something off that list?  No, it's a massive waste of time and resources, especially when you are doing things like constantly keeping track of a tree being chopped down into a log, then that log being turned into a barrel.)

What this would result in, however is eventually you have a list that is a million entries long, but where almost all those entries are blank.  And in order to actually find anything in your list, you have to search through all the blank pages in order to actually find the few pages that still have some information on them. 

Hence, the problem I am speculating might be happening is a structural problem that could only really be solved by an occasional sorting of this list, no matter how long that sorting might take.

This would probably be best done on the year change, when all the other heavy lifting and "spring cleaning" is taking place, anyway, and would basically result in a "don't bother waiting, just go make yourself dinner and come back when you're done" sort of year-end wait, but it would sweep up the gradual FPS death that occurs after several years of a fortress running.

EDIT:
Ah, damnit, I just realized there's a faster way to do the same thing as that previous list source, since there's no need for the data fields to have any sort of order.

You could simply have a pair of pointers, one starting at the front of the list, and stopping when it hits a blank space that needs to be filled, and the other starting at the end of the list, working backwards, and stopping at and transferring any memory field that has data (and garbage collecting completely emptied arrays).

However, that would depend on the ability for you to actually be able to traverse the list backwards somehow, whether by double-linked list or by giving the second pointer a memory of how it got to where it is.
« Last Edit: March 13, 2012, 03:45:37 pm by NW_Kohaku »
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #7 on: March 13, 2012, 04:58:53 pm »

I also noticed this problem, now I am trying to produce a bug report with:

*save before event and decent FPS
*save about season later, with the same number of items ad creatures and half of FPS

This should help Toady to track this problem. It may be related to clothing (even in games without clothing items), so maybe upcoming fixes will end this.

Having a set of saves like this would be helpful in building our own suspicions about how Toady handles data, and would tell us if I'm wrong because the game actually doesn't behave in a way that I am speculating, but Toady wouldn't need a save to understand what's happening if I'm right about this.  The evidence is simply in what code he uses to contain his data.

I did a quick search on Mantis for "FPS", and didn't see anything related specifically to this topic, so if my speculation is accurate, it would probably be best to just create a bug report, and give the suggested solution to the speculative problem?

I'm just a little worried that it seems like so obvious a solution that I'm wondering why someone else wouldn't have thought of it, first... which is usually a sign that someone has thought of it first.  I guess I should just swallow my doubts, and throw it out as a stab in the dark, and take the risk of getting shot down, though?

EDIT:
Well, went and made it - bug report.

I might be wrong and laughed at, but I might not be, and I suppose it's worth taking the risk on the slim chance I'm right.
« Last Edit: March 13, 2012, 07:29:52 pm by NW_Kohaku »
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #8 on: March 13, 2012, 07:50:25 pm »

Quote from: Footkerchief
We need evidence. The bare minimum for reports of decreasing in-game performance is before/after saves. To demonstrate the problem, the saves need to control as well as possible for extraneous factors, such as population, flows, and items that are still present on the map.

 Evidence from memory hacking would be preferable for confirming the specific algorithmic hypotheses e.g. dummy pointers.

 When evidence become available, please reopen this report.

So, if you can get that save, Kogut, that would be necessary, it appears.  I don't have a fort set up to test this right now, so it would help if someone else could supply that fort with the "Before and After" shots.

(Of course, just letting Toady look at it would confirm it with or without evidence - Toady will know what's in his code.)
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

-Firestar-

  • Bay Watcher
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #9 on: March 13, 2012, 08:05:52 pm »

I've never gotten past mayor because my FPS goes from 100 to 3 in just a few years. It COULD be because I usually clear out an entire level just dedicated to piles but without knowing what exactly needs testing, there's no way to tell.
Logged

red_29A

  • Bay Watcher
  • [DO_NOT_CULL]
    • View Profile
    • Nexus Page
Re: Is there a way to tell what is slowing me down?
« Reply #10 on: March 13, 2012, 08:16:33 pm »

NW_Kohaku is awesome! i remember reading bug reports about this ~1 year ago, and the reporter seemed to think it was due to the amount of tiles dug out or designated... Pretty sure it had fps in the title, no wait, try searching for 'lag'. It was a long, whiny sounding title that had lag in it i think. And the word unplayable, i believe.

Also, if you have a decent system are you affected? my machine is getting on 3 years old, but i don't notice any fps issues. Also, is there a shit load of shit running in your task bar? Is adobe acrobat constantly trying to update? Fuck that, use Sumatra PDF. EVERY PC i have ever worked on is just plagued with useless crap running all the time. MSI Afterburner (for screenshots) and the volume control is the only thing in my task bar. i'll kill the service for windows security center and search and a lot of services/processes before i do any serious gaming. It mattered more years ago with less RAM, but old habits die hard. And my gaming machine has only been connected to the interbutts to activate a few games, so no anti-virus crap slowing it down either.

I'm pretty sure any one who plays DF is mighty intelligent, and possibly in some sort of IT field, so you can probably disregard my post, and i'm sorry if i sound like a dick. Upgrading or buying a new machine is a poor solution to improper/poor data management, but it seems like the people with fps issues have older machines. And 3 years ago when i built mine i made less than minimum wage, $7 an hour. i ate peanut butter sandwiches and drank water and rolled my own cigarettes, and in ~9 months i had 2 solid state drives a Q9550 4 GB of RAM a sweet case and a sweet MOBO with a 1333 FSB. oh and 1 25" HP 1920 x 1080 screen. Also i have a room-mate to split the bills, but we have no television or interwebs (i'm at the library now) so its just rent, gas and electric. i never eat out or eat fast food. At $7 i made ~$180 a week. < 2 weeks pay covered all my bills, and the rest was Whoo-hooooo! Oh, and i drive the speed limit and have no car insurance to save $40 a month. I've never gotten government aid either, and my poor ass bought RAGE a few days after it was released and it played silky-smooth at 60fps on my old machine.

Sorry to rant, But this doesn't seem to affect everyone...
Logged

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #11 on: March 13, 2012, 08:23:43 pm »

Well, if we want to specifically stress-test the specific notion that objects that no longer exist are the specific cause of lag, then what we need is a situation where dwarves are creating a very large number of objects which are then destroyed.

The easiest way to do this would be to generate custom reactions that generate and then destroy large numbers of objects at once, while at the same time turning sieges off, and setting dwarves to NO_EAT, NO_SLEEP, NO_DRINK.  "Operation FPS Bomb" would be all about doing as little as possible besides generating and then subsequently destroying large volumes of items. 

A control fortress could be set up by starting a new fortress, building the custom workshops, and setting up the reactions to start taking place.  Then, saving, copying the save, and then running a "Control" save where the dwarves basically do nothing all day, and a "Test" save, where the dwarves repeatedly create and then annihilate materials. 

Provided my educated guess is correct, this should give some corroborative evidence as to how Toady has coded the game. 

... Of course, again, Toady could simply look at it, and declare my guess inaccurate fairly easily, as well, so I'd rather take the one that's faster if I could help it.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Orkel

  • Bay Watcher
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #12 on: March 13, 2012, 08:27:35 pm »

Get DFhack and use the commands

"clean map"
"clean units"
"clean items"

You most likely have thousands upon thousands of contaminant splatters (like blood, even if you can't see them DF still tracks them) that have accumulated over the years and they are taking a huge amount of your FPS.

I've kept my 130 dwarf fort, currently 7 years old at a steady 140 FPS by atomsmashing excess stone and items, and editing my raws (prior to genning world) so dwarves/goblins have no clothes (some speculate rotting clothes causes significant lategame FPS drop, plus they're messy as hell). I also have weather turned off (temperature still enabled), but in my case it doesn't impact the gameplay at all because it never rains in my area in the first place. Without weather the FPS is around 80-90.

Using the clean commands for the first time and watching several thousand tracked contaminants disappear and my fps jumping up by +30~50 was a sight to behold. I do it regularly now, usually after every siege.

My G_FPS is capped at 20 (default 50) with no ill effects whatsoever, dunno if that also affects it.
« Last Edit: March 13, 2012, 08:42:05 pm by Orkel »
Logged
Quote from: madjoe5
Dwarf Fortress: The game in which people place abducted children in a furnace to see what happens.

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Is there a way to tell what is slowing me down?
« Reply #13 on: March 13, 2012, 08:43:13 pm »

Get DFhack and use the commands

"clean map"
"clean units"
"clean items"

You most likely have thousands upon thousands of contaminant splatters (like blood, even if you can't see them DF still tracks them) that have accumulated over the years and they are taking a huge amount of your FPS.

I've kept my 130 dwarf fort, currently 7 years old at a steady 140 FPS by atomsmashing excess stone and items, and editing my raws (prior to genning world) so dwarves/goblins have no clothes (some speculate rotting clothes causes significant lategame FPS drop, plus they're messy as hell). I also have weather turned off (temperature still enabled), but in my case it doesn't impact the gameplay at all because it never rains in my area in the first place. Without weather the FPS is around 80-90.

Using the clean commands for the first time and watching several thousand tracked contaminants disappear and my fps jumping up by +30~50 was a sight to behold. I do it regularly now, usually after every siege.

Right, but the idea is that if, even when deleted, those splatters and objects you atom-smashed still "took up" a slot in an array in an index vector (or vector-like data structure) that contains references to every object on the map, then even atom-smashing and removing splatters would still leave a "footprint" in terms of "empty slots" in the index vector that must be skipped over whenever the index vector is referenced.  That act of skipping still takes a (smaller, but still present) number of cycles, and when you have removed millions of objects or spatters from the game, then you will have millions of "empty slots" that the game will have to overlook every time.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

mikelon

  • Guest
Re: Is there a way to tell what is slowing me down?
« Reply #14 on: March 14, 2012, 12:25:11 am »

I modded out most clothing in game as well as most of the useless items that animals produce (hair, etc) and i get an averge of 20+ fps more by the time i reach a 150 population.
Logged
Pages: [1] 2 3