Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How do I make LCS run faster?  (Read 1611 times)

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
How do I make LCS run faster?
« on: April 05, 2013, 01:31:08 pm »

When I get enough liberals, the game starts to slow down. While this is understandable, it seems to me that LCS doesn't use that much processing power. How can I allocate more power?
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Jboy2000000

  • Bay Watcher
  • Hello good people of the interwebs!
    • View Profile
Re: How do I make LCS run faster?
« Reply #1 on: April 05, 2013, 05:55:29 pm »

You don't, when the save file starts getting big theres no helping the lag.
Logged
"Wanna be a better liberal? Go get shot in the fuckin' face."

Just goes to show, even a Male Doctor that Looks Like a Female and a Criminal with Poor Hygiene Habits can fall in love.

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: How do I make LCS run faster?
« Reply #2 on: April 08, 2013, 10:31:52 pm »

Is this only noticeable when days are passing? I am guessing it is indeed the game saving to disk every day that is causing this. I don't think there's anything else in the game that would be remotely as slow as writing the game state to disk, at least on a modern computer.
Logged

Cheedows

  • Bay Watcher
  • Still a dwarf, right?
    • View Profile
Re: How do I make LCS run faster?
« Reply #3 on: April 08, 2013, 10:52:23 pm »

Personally I've never had LCS lag for me, but that's just me anyways. 
Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: How do I make LCS run faster?
« Reply #4 on: April 09, 2013, 12:43:41 am »

Personally I've never had LCS lag for me, but that's just me anyways.

Neither have I, but I don't play with large numbers of Liberals, and it sounds like that's the issue.

Ultimately, if what's slowing the game down is disk access time, you won't be able to make it run faster unless you run the game on a solid state drive or something. Normal hard drives are always slow; unlike most things in the computer, they have moving parts.

In code, we could have the game save less often, or try to get away with saving less data, but that's about it. I don't think there's a safe way to spin it off into a thread so it saves in the background without blocking gameplay. We'd need to copy the entire game state to avoid the data changing in mid-save, and we'd have to handle the case where the game tries to save before the previous save is complete. If it were a really big deal, it could probably be done, but it's a non-trivial amount of work to fix.
Logged

seth--

  • Bay Watcher
  • We need a slogan!
    • View Profile
Re: How do I make LCS run faster?
« Reply #5 on: April 09, 2013, 01:24:23 am »

I use an encrypted WD green (5200 rpm) and the saving isn't noticeable.
I don't have big squad but I could test it if somebody uploads a suitable save.dat. If it it's fast enough here, the hard drive probably isn't the problem unless you are doing something strange like saving the game over a network connection.

Personally I've never had LCS lag for me, but that's just me anyways.

Neither have I, but I don't play with large numbers of Liberals, and it sounds like that's the issue.

Ultimately, if what's slowing the game down is disk access time, you won't be able to make it run faster unless you run the game on a solid state drive or something. Normal hard drives are always slow; unlike most things in the computer, they have moving parts.

In code, we could have the game save less often, or try to get away with saving less data, but that's about it. I don't think there's a safe way to spin it off into a thread so it saves in the background without blocking gameplay. We'd need to copy the entire game state to avoid the data changing in mid-save, and we'd have to handle the case where the game tries to save before the previous save is complete. If it were a really big deal, it could probably be done, but it's a non-trivial amount of work to fix.
The ammount of data to write could be reduced by using something like msgpack instead of xml
Logged
I am confused are you saying you changed the kidnapping so it is less... Saw?
Did Saw consist of you beating them then yelling Ronald Reagan in their face?

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
Re: How do I make LCS run faster?
« Reply #6 on: April 09, 2013, 07:52:30 am »

Personally I've never had LCS lag for me, but that's just me anyways.

Neither have I, but I don't play with large numbers of Liberals, and it sounds like that's the issue.

Ultimately, if what's slowing the game down is disk access time, you won't be able to make it run faster unless you run the game on a solid state drive or something. Normal hard drives are always slow; unlike most things in the computer, they have moving parts.

In code, we could have the game save less often, or try to get away with saving less data, but that's about it. I don't think there's a safe way to spin it off into a thread so it saves in the background without blocking gameplay. We'd need to copy the entire game state to avoid the data changing in mid-save, and we'd have to handle the case where the game tries to save before the previous save is complete. If it were a really big deal, it could probably be done, but it's a non-trivial amount of work to fix.
It depends. Do you think that LCS would actually run faster on a flash drive? How can you tell what’s slowing it down?
Also, it depends on the definition of "large amounts of liberals". Sometimes, it will run slowly with just one squad.
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: How do I make LCS run faster?
« Reply #7 on: April 09, 2013, 03:18:42 pm »

It depends. Do you think that LCS would actually run faster on a flash drive? How can you tell what’s slowing it down?
Also, it depends on the definition of "large amounts of liberals". Sometimes, it will run slowly with just one squad.

Depends on whether your flash drive is a USB stick or an internal drive. Probably slower, if anything, with a USB stick. But an internal solid state drive, plugged into the motherboard with a SATA port? Yeah, I speculate that would be faster, if the save file is the bottleneck.

A heuristic for judging what's slowing it down is to 1) look at your computer's resource usage, then 2) look at when the slowdown occurs.

1) Is LCS taxing the CPU? If not, the bottleneck is not CPU speed, and the game is spending most of its time waiting for something. That could be player input, but it can also be memory access or disk read/write. If you're seeing big numbers on CPU usage for the game, then it's probably your processor speed that's slowing it down. Though that seems unlikely to me, I just don't think LCS is that taxing.

2) Is the slowdown occurring only when waiting between days? That points to saving being slow, though there are a lot of other things that go on between days too. Is the slowdown occurring at other times too, such as when you're running around a site fighting, or when you hold down the fight key in a brawl? That points to memory, keyboard input, or drawing to screen being slow instead. If the lag also scales up with the number of characters you've recruited, that points to either hard drive or memory, rather than player input or rendering.
Logged

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
Re: How do I make LCS run faster?
« Reply #8 on: April 09, 2013, 07:04:06 pm »

Yes, between days.
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Carlos Gustavos

  • Bay Watcher
    • View Profile
Re: How do I make LCS run faster?
« Reply #9 on: April 10, 2013, 11:43:36 am »

I noticed slowdown between days some time ago. I profiled the code back then and it was the writing xml in the save file that was the culprit.
Logged

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: How do I make LCS run faster?
« Reply #10 on: April 10, 2013, 02:46:31 pm »

I noticed slowdown between days some time ago. I profiled the code back then and it was the writing xml in the save file that was the culprit.

I think you are the one that switched the save files from being entirely raw data to using xml for creatures, is that correct?

What benefit do we get from saving the creatures as xml? Is it just less fragile and prone to error as the game is updated?
Logged

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
Re: How do I make LCS run faster?
« Reply #11 on: April 10, 2013, 05:20:18 pm »

I like raw data better, because then I can mod my liberal for better roleplaying. Having a genius liberal with paralyzed legs, and naming him Dr. X. Then I give him a school of mutants.
Edit: if it makes it run faster so much the better.
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Jonathan S. Fox

  • Bay Watcher
    • View Profile
    • http://www.jonathansfox.com/
Re: How do I make LCS run faster?
« Reply #12 on: April 10, 2013, 07:40:24 pm »

Modifying your Liberal is easier when it saves as xml, because then it's all written out in text and is labelled. xml is human readable, while just dumping the raw data to disk would require you to use a hex editor, and then you'd need to look at the game code to figure out what to edit.
Logged

tahujdt

  • Bay Watcher
  • The token conservative
    • View Profile
Re: How do I make LCS run faster?
« Reply #13 on: April 10, 2013, 07:41:43 pm »

Apparently I got my terminology confused. Sorry.
Logged
DFBT the Dwarf: The only community podcast for Dwarf Fortress!
Tahu-R-TOA-1, Troubleshooter
Quote
I suggest that we add a clause permitting the keelhauling of anyone who suggests a plan involving "zombify the crew".
Quote from: MNII
Friend Computer, can you repair the known universe, please?

Carlos Gustavos

  • Bay Watcher
    • View Profile
Re: How do I make LCS run faster?
« Reply #14 on: April 14, 2013, 11:26:13 am »

I think you are the one that switched the save files from being entirely raw data to using xml for creatures, is that correct?

What benefit do we get from saving the creatures as xml? Is it just less fragile and prone to error as the game is updated?

Yes, I did do that. I am unsure what benefit there is other than the readability.
Logged