Speeding up consistency checks.

endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
Hey guys,

I'm currently testing a method to speed up consistency checking on the server side. I know some people may be interested in this, as they don't run consistency checks because of the additional overhead they add to map loads, or they are currently running them, and would like to speed them up.

Requirements for this to work.
You basically need 2GB spare ram. You will need to do your calculations based on how many servers you run per box.
My situation: 8GB total, 4 total servers. They can use about 5GB, leaving me with 3GB of ram.

Quick overview:
Create a 2GB ram drive, and run NS2 server from there.

How to do this:
Download and install this program:
http://www.ltr-data.se/opencode.html/#ImDisk
It allows you to create ram drives from cmd prompt.

Create a batch file, schedule it to start with the system.

imdisk -a -s 2048M -m n: -p "/fs:ntfs /q /y"
ping -n 15 127.0.0.1
steamcmd.exe +runscript yoursteamupdatescript.txt

Server Consistency checks have gone from about 62 seconds, down to 3 seconds.
Map loading now takes about 12 seconds total, down from something horrid that I never actually sat and timed.

Individual results will vary, this was such a valuable thing for me to do, because my server hard drives are very slow. Sequential read speeds have gone from 55MB/s to 6000MB/s.
I'm not covering how to launch ns2 or update it, as these are covered by other people in other places.

Comments

  • ScardyBobScardyBob ScardyBob Join Date: 2009-11-25 Member: 69528Forum Admins, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow
    Awesome work! Gonna try this out on our ENSL servers (the more involved consistency checking drags out server map changes).
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Hope it works out for you. It took me a while to set it up, because I had to change my configuration of having dedicated game directory files, to all loading from one location.

    Also, something worth mentioning. Since the throughput is so high, the next bottleneck on checking is your CPU, which means that it will hit 100% (of a single core) when it does it. Not a big deal i think, since any server should be expected to hit 100% or more anyway.
  • CoTTonCoTTon Join Date: 2005-02-28 Member: 42773Members
    edited March 2013
    Nice, but my 2 servers in Cgy are on SSD's.

    Loads pretty fast already

    My chi server though I can't run this since I don't have access to the box :(
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    This sounds like something that should be solved via programing. The server on first load should hash the files 1 time and use those hashes for when a player loads in. From what you describe it appears as though the server hashes these files every single time a player connects which is madness!

    Likewise a similar method should be used client side except with a method to verify that the file has not changed from the hash to prevent exploits and hacking. This would dramatically improve load times for players.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Oh it's not hashed on every player load, just every map change.

    And yes, I agree. It will most likely be solved in future by changing the frequency of hashing the files. But there are bigger issues plaguing consistency checks right now (of which I'm about to make a new thread).
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    Ok that is a bit better but still it should be on every server first start b/c the files should not be getting changed on the server after that point regardless. Things like this and the lack of file appending are some of the "little" things I hope they fix soon that can have impacts here and there on improving performance.
  • JektJekt Join Date: 2012-02-05 Member: 143714Members, Squad Five Blue, Reinforced - Shadow
    I don't recall consistency checking taking so long prior to gorgeous.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    The game got larger. I think the amount of models went from 2000 to 2600 (dont quote me), and there were various increases across the board.
  • JektJekt Join Date: 2012-02-05 Member: 143714Members, Squad Five Blue, Reinforced - Shadow
    Even so, across both hosts I run servers with the Waiting for server portion of a map change is taking at least three times as long.
  • GamerkatzeGamerkatze Join Date: 2012-06-27 Member: 153711Members
    Jekt wrote: »
    Even so, across both hosts I run servers with the Waiting for server portion of a map change is taking at least three times as long.

    same on my servers, but it could just be the first time run when the server is compiling the files for the map.
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    ZEROibis wrote: »
    This sounds like something that should be solved via programing. The server on first load should hash the files 1 time and use those hashes for when a player loads in. From what you describe it appears as though the server hashes these files every single time a player connects which is madness!

    Likewise a similar method should be used client side except with a method to verify that the file has not changed from the hash to prevent exploits and hacking. This would dramatically improve load times for players.

    Via programming eh? How do you check that a file hasn't changed without hashing it? The *only* way I can think of involves an exclusive lock on the file, which means that you can no longer make changes to the server while it's running. I'm pretty sure that no one wants to have to stop their server to upload new content.
  • lwflwf Join Date: 2006-11-03 Member: 58311Members, Constellation
    devicenull wrote: »
    ZEROibis wrote: »
    This sounds like something that should be solved via programing. The server on first load should hash the files 1 time and use those hashes for when a player loads in. From what you describe it appears as though the server hashes these files every single time a player connects which is madness!

    Likewise a similar method should be used client side except with a method to verify that the file has not changed from the hash to prevent exploits and hacking. This would dramatically improve load times for players.

    Via programming eh? How do you check that a file hasn't changed without hashing it? The *only* way I can think of involves an exclusive lock on the file, which means that you can no longer make changes to the server while it's running. I'm pretty sure that no one wants to have to stop their server to upload new content.

    You can ask the filesystem when the files were last modified. But know that feature may not always be available.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    devicenull wrote: »
    ZEROibis wrote: »
    This sounds like something that should be solved via programing. The server on first load should hash the files 1 time and use those hashes for when a player loads in. From what you describe it appears as though the server hashes these files every single time a player connects which is madness!

    Likewise a similar method should be used client side except with a method to verify that the file has not changed from the hash to prevent exploits and hacking. This would dramatically improve load times for players.

    Via programming eh? How do you check that a file hasn't changed without hashing it? The *only* way I can think of involves an exclusive lock on the file, which means that you can no longer make changes to the server while it's running. I'm pretty sure that no one wants to have to stop their server to upload new content.


    How about hash the files that exist when the server starts. Save these hashes until the server closes. On each map load, check if theres any new files (from mods), and hash those, replacing old ones if they exist, while keeping the existing hashes in memory.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    devicenull wrote: »
    ZEROibis wrote: »
    This sounds like something that should be solved via programing. The server on first load should hash the files 1 time and use those hashes for when a player loads in. From what you describe it appears as though the server hashes these files every single time a player connects which is madness!

    Likewise a similar method should be used client side except with a method to verify that the file has not changed from the hash to prevent exploits and hacking. This would dramatically improve load times for players.

    Via programming eh? How do you check that a file hasn't changed without hashing it? The *only* way I can think of involves an exclusive lock on the file, which means that you can no longer make changes to the server while it's running. I'm pretty sure that no one wants to have to stop their server to upload new content.

    If I had to stop my server to upload new content so that every time a player connects they can join faster I would stop my server right now to upload that content!
  • UzverUzver Join Date: 2012-11-20 Member: 172632Members, Reinforced - Silver
    For server side:
    It's not a bad idea to generate table of hashes once and save it to disk. And instead of reading the stuff again - just use already generated table of hashes. There is no reason to generate hashes again, again and once again if you don't make any changes. If you put a new stuff - just use a special console command in order to generate table of hashes again.
  • UzverUzver Join Date: 2012-11-20 Member: 172632Members, Reinforced - Silver
    edited March 2013
    endar
    But how about a standby memory? When OS read files, it put files to free RAM in order to achive an instant access. So if program read this file again, it will be read from RAM, but not from a slow disk.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    Reading a hash file is not IO intensive and thus you would not want to keep in ram for long to reduce useless memory usage. What currently takes time is the actual hashing process not reading the resulting hash itself.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Uzver wrote: »
    endar
    But how about a standby memory? When OS read files, it put files to free RAM in order to achive an instant access. So if program read this file again, it will be read from RAM, but not from a slow disk.

    I don't understand what you mean. Can you reword it, or reference is against what I said?

    And ibis, i'm not sure what you mean either. The file containing the hashes would be kilobytes in size, wouldnt matter if its ram or disk.
  • NordicNordic Long term camping in Kodiak Join Date: 2012-05-13 Member: 151995Members, NS2 Playtester, NS2 Map Tester, Reinforced - Supporter, Reinforced - Silver, Reinforced - Shadow
    edited April 2013
    I love to see more use of ram disks. This is cool.
  • UzverUzver Join Date: 2012-11-20 Member: 172632Members, Reinforced - Silver
    edited March 2013
    endar wrote: »
    I don't understand what you mean. Can you reword it, or reference is against what I said?
    I mean that after map change your server will be read most NS2 files from RAM without using a virtual RAM disk. Why? Standby memory - it's a some sort of file caching. When programs reads a file, operation system automatically caches this file to free space of RAM. It's looks like your virtual disk that uses RAM, but in automatic mode.
    In task manager you can't notice that your free memory is used for a cache. Use a resource monitor instead.
  • ZEROibisZEROibis Join Date: 2009-10-30 Member: 69176Members, Constellation
    edited March 2013
    endar wrote: »
    Uzver wrote: »
    endar
    But how about a standby memory? When OS read files, it put files to free RAM in order to achive an instant access. So if program read this file again, it will be read from RAM, but not from a slow disk.

    I don't understand what you mean. Can you reword it, or reference is against what I said?

    And ibis, i'm not sure what you mean either. The file containing the hashes would be kilobytes in size, wouldnt matter if its ram or disk.

    That is what my point was, that the file would not be large enough for it to need to be stored in RAM constantly.
  • endarendar Join Date: 2010-07-27 Member: 73256Members, Squad Five Blue
    Windows 2008 R2 file caching is a nice feature, in fact its a great feature when it works. But unfortunately you don't have much, if any? control over it.

    I did previously rely on it, and sometimes you would get nice load times (around 20s), down from the 60+ if you did two map loads in quick succession. But it was very random. If a map went for a long time, the chances of those files still remaining in cache are very low. Using a ramdisk will guarantee, with 100% certainty, that you will always have the fastest consistency checks possible.
Sign In or Register to comment.