Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Lag solution  (Read 4125 times)

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Lag solution
« on: April 22, 2009, 11:11:44 pm »

So in my latest fort I went for mass production.  The target was to get the fortress to 100,000,000 total net worth.

6x6 non-mountain, magma pool, sand, limestone+iron, lotsa trees.  Pop cap 250, children allowed.

Metalworking of all types, stonecrafting, glassworks, jeweling, clothesmaking, everything.

You know what happened.

Lag.

I got to 63,000,000 net worth before giving up.  6 FPS dropping to 4 at times.  Not worth playing.

So I decided to experiment.  Does forbidding items speed up the game?  Does removing stockpiles?  Etc.

Eventually I got to removing items from the game entirely.  So I built a few atom item-smashers.

I destroyed around 90,000 items, 39,000 of which were goblets and mugs.  9000 assorted pieces of clothing.  9000 metal bars.  4000 bins.  Toys, instruments, jewelery, furniture.  It took two seasons.  Dropped the net worth by 75%.

Now the game is running at 30-35 FPS, dropping to 25 at times.

That is a 6x speedup.

I'm never going to do mass production again.

So... what do I do with the fort now?
Logged

Neruz

  • Bay Watcher
  • I see you...
    • View Profile
Re: Lag solution
« Reply #1 on: April 22, 2009, 11:17:56 pm »

Not really surprising; just tracking all those items sucks up a fair bit of power.

Make a megaproject, or start modding.

Derakon

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #2 on: April 23, 2009, 12:47:51 am »

Agreed on the megaproject. I'm curious if using up items into constructions has any effect on lag, though it'd take so long to do all the construction that it'd be hard to measure.

I suggest you hollow out the bottom floor of the world, fill it with magma, and then hollow out the layer above that...and then so on, until your embark region is a shell on top of a magma lake with all your dwarves forced to live on the surface. It'll make dumping items (aside from iron, steel, and bauxite) easier, if nothing else.
Logged
Jetblade - an open-source Metroid/Castlevania game with procedurally-generated levels

Moron

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #3 on: April 23, 2009, 05:27:52 am »

I wonder if, as has been suggested elsewhere, even items taken away by the merchants add to lag as they are still stored in memory or something somewhere.
Logged

kotekzot

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #4 on: April 23, 2009, 05:53:21 am »

just being stored in the memory shouldn't really impact the fps. i think that the fps drop comes from the game having to process them.
example 1: mason's looking for stones, the game has to look for them in the index but OMGWTF there are millions of crafts! it doesn't take a long time to figure out that a craft is not a stone but because there is quite a lot of them it takes a while.
example 2: dwarves check if there are any objects that need hauling to stockpiles, items that need to be put into bins, etc.
Logged
Dwarf Fortress: Where violent death is a renewable resource
Bro, your like... thinking like a square man... its like, the WHOLE lamprey is just like, one big NECK dude, you know? its like hahahaha! dude protect the trees though, seriously. *inhale*... anyways... you like, want this dead black bear, bro?

Nerserus

  • Bay Watcher
  • Rawr.
    • View Profile
Re: Lag solution
« Reply #5 on: April 23, 2009, 06:59:13 am »

Creepy, i think i found a solution to the lag problem and i was just about to post it. Anyway, i'm not sure if it will work for you people but it did for me so here is goes :),
Step 1: Go into the Init file ( It's in the data file ), then scroll down to:
[PARTIAL_PRINT:NO:2]
Replace that, with this:
[PARTIAL_PRINT:YES:5]
( Do NOT have DF up whilst doing this, or eye rape! )
I tested it, mine went from 25 FPS, to 100 FPS ( Max, even with multiple traders and kobold thieves. )

Step 2: PROFIT FROM LACK OF LAG! ;D
Logged
stack of 10 prepared dragonfly brains - I'm trying to imagine what's more funny: a dwarf popping a tiny dragonfly brain into his mouth for a snack, the butcher who actually prepared this feast, or the brave hunter who ventured out into the wilderness and returned with this bounty.

sonerohi

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #6 on: April 23, 2009, 07:01:28 am »

Partial_Print was discovered awhile ago.
Logged
I picked up the stone and carved my name into the wind.

Creamcorn

  • Bay Watcher
  • [FANCIFUL]
    • View Profile
Re: Lag solution
« Reply #7 on: April 23, 2009, 07:03:26 am »

Place all items in one super huge dump pile, build pile on most top Z level, supported only by one pillar, pull lever. ZOMG THE SKY IS FALLING! Actually I'm mostly curious about the mechanics of items falling.
Logged
"OH NO! That carp is gulping at me menacingly, even though it cannot really threaten me from here on land!  I KNOW! I'll dodge into the water, where I'll be safe!"

Nerserus

  • Bay Watcher
  • Rawr.
    • View Profile
Re: Lag solution
« Reply #8 on: April 23, 2009, 07:42:34 am »

Partial_Print was discovered awhile ago.
Yeah but not everyone knew that, for example, i didn't :o
Logged
stack of 10 prepared dragonfly brains - I'm trying to imagine what's more funny: a dwarf popping a tiny dragonfly brain into his mouth for a snack, the butcher who actually prepared this feast, or the brave hunter who ventured out into the wilderness and returned with this bounty.

Shoku

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #9 on: April 23, 2009, 08:31:09 am »

Partial print doesn't help my fps in any noticeable way, though I've already turned down the max graphical refresh rate to 15 fps anyway.
Mostly it just gives me a reason to exit the game after generating worlds and not play adventure mode.
Logged
Please get involved with my making worlds thread.

ScreamingDoom

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #10 on: April 23, 2009, 11:16:54 am »

just being stored in the memory shouldn't really impact the fps. i think that the fps drop comes from the game having to process them.
example 1: mason's looking for stones, the game has to look for them in the index but OMGWTF there are millions of crafts! it doesn't take a long time to figure out that a craft is not a stone but because there is quite a lot of them it takes a while.

This sounds like a job for a HASH TABLE! (*insert John Williams score here*)

Quote
example 2: dwarves check if there are any objects that need hauling to stockpiles, items that need to be put into bins, etc.

This seems like something that could be done iteratively in a background thread. Especially since only items that announce they need moving should have to be processed in this way (which should be a comparatively rare event).
Logged

kotekzot

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #11 on: April 23, 2009, 01:19:44 pm »

just being stored in the memory shouldn't really impact the fps. i think that the fps drop comes from the game having to process them.
example 1: mason's looking for stones, the game has to look for them in the index but OMGWTF there are millions of crafts! it doesn't take a long time to figure out that a craft is not a stone but because there is quite a lot of them it takes a while.

This sounds like a job for a HASH TABLE! (*insert John Williams score here*)

Quote
example 2: dwarves check if there are any objects that need hauling to stockpiles, items that need to be put into bins, etc.

This seems like something that could be done iteratively in a background thread. Especially since only items that announce they need moving should have to be processed in this way (which should be a comparatively rare event).
fair points, but df is not optimized, so i assume such earthly things are done in a quick and easy manner.
Logged
Dwarf Fortress: Where violent death is a renewable resource
Bro, your like... thinking like a square man... its like, the WHOLE lamprey is just like, one big NECK dude, you know? its like hahahaha! dude protect the trees though, seriously. *inhale*... anyways... you like, want this dead black bear, bro?

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: Lag solution
« Reply #12 on: April 23, 2009, 02:11:53 pm »

Well...

I already use PARTIAL_PRINT, I was involved in the initial testing of it.  It doesn't help me much as my video card is nearly top of the line.

I've already done a megaproject on this fort.  A 10,000 block, 15 story green glass tower with around 350 rooms.  The top is covered with skull totems.  I really don't know if the constructed blocks create lag, and I'm not going to take it apart to check.  It's my dwarves' housing, after all.

The magma is a pool, not a pipe, so there's not much to play with.  It was a small pool too, it barely filled my forge plumbing.

I think I will just let the fort sit.  Maybe an idea will come to me.  I did keep a copy of the fort before destroying the items, for comparison purposes.

I mainly wrote the report to get the idea out there that not all lag is pathfinding.  Item overhead can add up to a lot as well.

I really wish I could optimize the source.  Even under an NDA and non-ownership agreement, I'd work on it.  (I do understand Toady's reasons, I just wish things were different.)
Logged

mithra

  • Bay Watcher
    • View Profile
Re: Lag solution
« Reply #13 on: April 24, 2009, 08:07:27 pm »

but df is not optimized . . .

Now there's an understatement.
Logged