Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

[Tutorial] The definitive guide to properly hosting a lag-free server (v0.0.3)

Discussion in 'Multiplayer' started by vmrob, May 9, 2014.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. vmrob Apprentice Engineer

    Messages:
    135
    Some, probably very few, of you have played on my server "Hardcore Survival/Pvp" and almost every one of my regulars have stated that I have excellent management policies and very responsive gameplay.

    There's a good reason for this. I use extensive utilities to manage the content of the server as well as have my savefiles backed up regularly. I'm going to teach all of you how to be an excellent host and, I must warn you, it's not as straightforward as you might think. However, if you follow this guide, you'll be hosting excellent servers in no time.

    For what it's worth, it's actually impossible to be lag-free, I just said that because saying lag-free sounds a lot better than not-as-much-lag-as-you-had-previously. Lag-free is also only 8 characters long.

    The definitive guide to properly hosting a lag-free server (v0.0.3)

    Contents

    1. Change log
    2. Requirements
    3. Evaluation
    4. Setting up the world
    5. Preparing backups
    6. Running your server
    7. Maintenance
    8. Conclusion

    1. Change log

    • v0.0.3 update pythong instructions, thanks Schinxz! Updated segc instructions to latest version
    • v0.0.2 update git setup instructions and simplified script, thanks manveti!
    • v0.0.1 initial release
    2. Requirements

    You should be familiar enough with the command line to enter commands, navigate through directories, and know what I mean when I say "run this command".

    I'm also going to present to you a series of tools that will greatly assist you in your endeavours to become an excellent host. Don't bother downloading the optional tools until you read the relevant sections.
    The evaluation and save file preparation steps are optional if you already have a world you want to keep. The next time you generate one, be sure to refer to this in order to get the best experience.

    3. Evaluation

    To start off, you're going to want to evaluate your computer's ability to handle a server with many people. This is mostly a guessing game that comes with a little bit of experience. Mentally compare your computer with my own. I don't have a top of the line modern computer, but I believe it to be a decent rig. This comparison is important because you need to be able to evaluate whether my default settings will work for you or if you think you can handle more.

    • i5 quad core processor at 3.4ghz
    • 16gb of DDR3 memory
    • AMD 6870 graphics card with 1gb gddr5 vram
    • 256gb Samsung SSD with 500mb/s read/write
    • 30 megabit download / 6 megabit upload
    These are the important specs for hosting an SE server. Hopefully, when dedicated servers arrive, graphics cards will be less important as the server would be headless. Let me now explain what each of these components does for your ability to host a server.

    Processor

    The processor allows your computer to handle more objects floating around. This might not strike you as an immediately obvious point, but from experience, I can tell you that SE uses a lot of processing power to iterate through game entities and do update calculations. This is probably the area where we'll hopefully see the most optimization from the Keen team. If you guys are reading, I hope we'll talk to each other soon; I'm a talented C++ programmer and I'll be submitting my resume soon.

    I run statistics on my save files regularly to determine object counts and notice an obvious trend when it comes to update speed vs object count. For the record, here are the statistics for my current save:

    Code:
    ================================================
    Sector Statistics
    ================================================
    Total entities:    359
    Asteroids:          72
    Ships/Stations:    221
    Floating Objects:   64
    ================================================
    During regular gameplay, my computer idles at about 60-70% cpu usage with this type of object count. During periods of extreme lagginess, the cpu usage hovers around 95%. The trick is to keep overall CPU usage moderately low through optimization techniques.

    If your computer has a better processor than mine, it's likely that you can support a higher object count than I can. Subsequently, if you have a lesser CPU, you probably won't be able to support a very high object count.

    Memory

    Space Engineers is absolutely notorious for its memory leaks. I wish I had a screenshot, but after a long while of play, you'll notice the memory usage climbs until the server either crashes or becomes unresponsive. For me, this usually happens after a good several hours of idling. I've woken up before to find that the process was consuming over 6gb of memory with no end in sight. I restarted my server recently and I'm currently sitting on 3.3gb used.

    Why, then, is memory so important? Simple: If you run out of memory, your applications don't crash unless you have non-default pagefile settings on your computer. What happens instead is your memory is virtualized to areas of your hard drive. So? So that means that when you run out of memory, your computer swaps your memory contents with the hard drive as necessary. For comparison's sake, I have a fast hard drive that's able to read at 500mb/s. My memory, slow by today's standards, can read almost 7 times that speed.

    Memory usage is paramount to a speedy server but remember, unused ram is wasted ram. Your computer can and should use as much of it as possible. A healthy memory usage [on a windows computer] tends to be 80% or less. To check your memory usage, push ctrl-shift-esc and view the performance tab of task manager.

    [​IMG]

    Note the free memory on my computer. Even with Space Engineers, there's plenty of room to grow. That's the important part. If you don't have as much memory as you need, honestly, just go buy some. It's highly likely that you can both afford it and that your computer supports more memory. Seriously, memory is dirt cheap.

    Graphics

    Unfortunately, this is a requirement. Eventually, it might not be, but as it stands it is for now. All I can say is that if you have a card that's older, you're going to have to deal with lesser graphical settings while you play the game. Thankfully, the only person who will experience problems with a older graphics card is you. The other members of your server get to rely on the other components of your computer.

    Hard drive

    The only reason this is important is if you have autosave turned on. If you plan on hosting a server and you don't have autosave turned on, you're a terrible person. Turn autosave on, seriously. Do it right now. The reason that your hard drive read and write speed matters here is because if you have autosave on, everyone on your server will experience some lag while your computer writes the savefile. For a server like my own, the savefile can get pretty big. Mine tends to get to about 25mb before I clean it out. Likewise, your asteroids need to be saved too. Of all of the requirements to properly host a server, the hard drive speed is probably the least important.

    Network speed

    To evaluate your network speed, head over to your friends at http://www.speedtest.net/ and run a speed test. The reason your network speed becomes important is because if you have too many players online at the same time and your network can't handle them, you'll find that they lag out. It's far better to lower your maximum player count than to allow shoddy performance. I can comfortably host a group of about 8 people, myself included, before performance becomes an issue. Keep that in mind when you evaluate your settings.

    4. Setting up the world

    In the first step, we evaluated your computer against a baseline. Now remember, if your computer is better than mine, you can probably adjust these settings <em style="font-size: small;">reasonably.</em> Your computer absolutely cannot work miracles though, so don't expect to max everything out. Unlike AAA games where "Ultra" is possible on high end machines, indie games tend to define "Ultra" as an asymptotic line that no computer can comfortably achieve without an extreme amount of money.

    In this step, we're going to create a savefile and tailor it to your computer's performance needs by removing some asteroids. If you think a default number of asteroids is acceptable, you can safely skip this whole section. I would highly recommend changing the number of floating objects on your server to 64 though. Trust me on this one.

    step 1: create your savefile

    If your computer is similar to mine or better, create a savefile with 16 large asteroids. If your computer isn't as good, feel free to create a server with 16, but just remember that you'll have to remove more. Believe it or not, this is actually one area where the graphics card really does matter. If you don't have a graphics card at least as good as mine, expect to lower the count. If you do have a great card, awesome! You might be able to plan on extreme with little problem.

    Now, change the floating object count to 64. Yes, 64. I know you think your computer is awesome (and I'm sure it is) but trust me on this one. You'll hardly notice the difference and lowering your object count here means you can have more ships later.

    Create a new world with 16 large asteroids and set the object count to 64.

    Step 2: remove extra asteroids

    This step is only necessary if you want more than 7 but less than 16 large asteroids. I, personally, found 7 to be too limiting and 16 to be too many.

    After you've created your world, enter it, save it, and shut down the game.

    Now, open up your file browser and navigate to the folder containing your save files. If you're on Windows 7, the default path will be here:

    Code:
    %appdata%\SpaceEngineers\Saves\&lt;steam id>\&lt;savefile name>


    What you're about to do is modify the SANDBOX_0_0_0_.sbs file and remove some of the larger asteroids from the game. To do this, it's probably easiest to use a tool like SEToolBox, but I'm the get-your-hands-dirty kind of person so we're going to do this manually.

    Open SANDBOX_0_0_0_.sbs using your favorite text editor

    When you open the file up, you'll see a data format called XML. XML is easily recognizable because it exists in a tree-like structure where indentation denotes the level. More indentation means deeper in the tree.

    [​IMG]

    Note that every node has a start and an end marked by the "&lt;tag>" and "&lt;/tag>" markers. What we're interested in doing right now is removing a few of the asteroids. If you wanted to remove the asteroid cleverly referred to as "CentralAsteroid.vox", you'll have to completely remove lines 13 through 22 in that example.

    In your own file, do a ctrl-f to find the last occurrence of "asteroid". You'll note that the asteroids are named centralAsteroid&lt;number>.vox and asteroid&lt;number>.vox and their moons centralAsteroid&lt;number>moon&lt;number>.vox and asteroid&lt;number>moon&lt;number>.vox respectively.

    Each asteroid definition looks like this:

    Code:
        &lt;MyObjectBuilder_EntityBase xsi:type="MyObjectBuilder_VoxelMap">
          &lt;EntityId>-1585641296703617821&lt;/EntityId>
          &lt;PersistentFlags>CastShadows InScene&lt;/PersistentFlags>
          &lt;PositionAndOrientation>
            &lt;Position x="-1781.54041" y="-2031.78015" z="-1400.35547" />
            &lt;Forward x="0" y="0" z="-1" />
            &lt;Up x="0" y="1" z="0" />
          &lt;/PositionAndOrientation>
          &lt;Filename>centralAsteroid.vox&lt;/Filename>
        &lt;/MyObjectBuilder_EntityBase>
    To remove an asteroid, you need to remove each of those lines, starting with the beginning "&lt;
    MyObjectBuilder_EntityBase ..." all the way to &lt;/MyObjectBuilder_EntityBase>. Luckily, it doesn't matter if you keep indentation or whitespace (newlines and spaces) around.

    Remove 4 of the large asteroids and 16 moons. It doesn't matter which ones.
    Don't remove the central asteroid unless you just don't care, it's always the biggest one around and definitely the most fun to explore. Save the file when you're done.

    step 3 (optional): remove the starter ship

    While you're in there, you might as well remove the starter ship you spawned too. This will give you practice splicing out ships and might even save you some time if the game ever pulls another one of those lets-make-partially-built-components-ruin-saves.

    To remove the starter ship you spawned with, find the tag that starts with
    &lt;MyObjectBuilder_EntityBase xsi:type="MyObjectBuilder_CubeGrid"> and remove it, along with all of the lines between itself and the closing tag: &lt;/MyObjectBuilder_EntityBase>. Don't forget to remove the closing tag as well. Save the file once again and close out of it.

    5. Preparing backups

    This is one of the more important steps but, unfortunately, also an optional one. What we'll do in this section is set up a version control system (git) to allow you to save versions of your save files in case anything ever happens. If you ever need to "rewind" your save because an update corrupted it, this is what you'll use. Even if you don't fully understand what is happening in this section, following these steps will make recovering your game much much easier. I may not cover that functionality in this tutorial, but I'll certainly make another with that in mind. Please, please, please make your life easier and do this step.

    Git is what is known as a version control system. We're going to use it as a backup system.

    step 1: install git

    You can download git from http://git-scm.com/. Follow the installation instructions, defaults are ok. It will give a relatively scary warning in the section titled "Adjusting your PATH environment". Be sure to keep the default option of "Use Git from the Windows Command Prompt" and not the other two options.

    Once you've installed git, you should be able to open a command prompt and type "git --version". Doing so will produce the version of git you just installed.

    If that was successful, you'll want to set up a username and email address for git by using the following commands:

    Code:
    git config --global user.name "My Name"
    git config --golbal user.email "my@email"
    Note that they don't have to be real.

    step 2: initialize the repository

    If you installed Git with the default settings, you won't have to do this the long way. I'm going to present both ways here

    Long way:

    What you'll need to do here is open up your command prompt and navigate to the folder your save file is located. This would be the %appdata%\SpaceEngineers\Saves\&lt;steam id>\&lt;savefile name> path. To get there from your command line, you'll want to type "cd" followed by the name of the directory you're getting to. cd stands for change directory. If you get somewhere and you don't know what folder you're in, run "dir" to see a list of the files and folders in that directory. If you accidentally go into a folder you didn't mean to, you can use "cd .." to go back to the parent folder. You should also note that when you start typing a folder name, you can use tab to help you out. This is called tab completion and makes navigating directories much easier.

    Once you're in the folder, you're going to type "git init". If all went according to plan, you should see a message along the lines of "Initialized empty Git repository in ..."

    Now, you're going to add all of the files in the folder to be tracked by git. To do that, type in "git add ." Note the period, it's important. Now, if you type "git status" you should see a bunch of green files. If you do, you can "commit" those files by typing in the following command

    Code:
    git commit -m "first commit"


    Now, a snapshot of those files you added, the ones that showed up in green, have been saved in an invisible folder called ".git" in your save file directory.
    Short way:

    If you installed Git with defaults, you should have some fancy context menus when you right click. You can go into the save folder where your SANDBOX_0_0_0_.sbs file exists and right click anywhere in the folder. Select the "Git Init Here" option. Now, select all of the files in that folder and right click on them. Select "Git Add all files now". Then, right click in the folder again and select "Git Commit Tool". A new window should have opened up with a big white box to the bottom right titled "Commit Message". Type anything you want into the box; I would recommend saying something like "initial commit" and then click the commit button to the left.

    By following that process of "Git Add all files now" and "Git Commit Tool", you can effectively save versions of your save files in case you need to restore them. The best part about this is that we're going to write a script that will do all of this for us.

    step 3: simplify the git-add-commit process with a script

    This script is, by no means, a good script on an elegance perspective, but it gets the job done quickly. What you'll want to do is copy the below text into a new text file and save it with a sensible name like "backup.bat". Make sure you save the file with a .bat extension so that you can double click on it to run.

    Code:
    git -C "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP" add -u[/SIZE]
    [SIZE=3]git -C "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP" commit -m "backup"[/SIZE]
    [SIZE=3]pause


    You will want to change those paths appropriately. I included my example in order to show you what the final script should look like.

    Once you're done with that, go ahead and load up your save file, fly a little bit, save it, and then double click on that .bat file you just created. If it worked, you won't have any error messages.

    I would recommend running this, at a minimum, every time you restart your server. You <em style="font-size: small;">should</em> be able to run this script even during the operation of your server. This is a good idea.

    6. Running your server

    This is actually going to be the shortest part of the whole tutorial because running your server is simple, just do it like you always have. I do, however, have some tips for you while you're running it. I'll present these in no particular order.

    Monitor your performance

    To monitor how your server is handling, you're going to use the debug statistics menu. To display these statistics, use shift-f11.

    [​IMG]

    The important components of this screen are the two metrics Update Lag and Sent KB/s.

    Update lag is probably the most important as it tells you how close to real-time your simulation of the game world is. If you've ever been in a game where everything was just slow, it's because the Update Lag was too high. For good performance, you want no more than 100ms of update lag at any given point in time. Ideally, it will hover around zero as it is in this picture. I will show you how to reduce that number and keep it low in the next section.

    Sent KB/s is a measure of how much data your computer is sending to the players of your world. In my experience, anything above 150 or so will cause severe lag. The only way to reduce this is by reducing the number of players you have in your server.

    What to do when you're afk

    I leave my server up almost 24/7. When I afk, I go into the graphics settings of the game and reduce the screen resolution to the lowest possible, disable fullscreen, set the FOV to the minimum, and change render quality to normal. I also take a small ship and fly outside of view of all of the asteroids and turn off the power while I sit in the cockpit. Currently, sitting in a cockpit without power will not reduce your energy usage thus allowing you to afk indefinitely.

    I do these things to reduce the amount of hardware required to keep my client running and to reduce overall system stress. I would recommend the same to anyone who keeps their server open while they are away.

    Restart every couple of hours

    This is a pretty self-explanatory tip. When you do restart the server, make sure you completely close out of the game before loading it back up. When you get to the next section, you'll have an especially good reason to restart.

    7. Maintenance

    This is easily the most important part of this entire guide. This section deals with the inevitable slowdown that comes with running a server for an extended period of time. What will happen is more and more ships will enter your world, more space debris will float indefinitely into the void and the only thing you [previously] thought you could do was to remove all non-beaconed ships. The days of such an archaic and barbaric solution are over.

    Technically, this entire section is optional, but if you skip over it, you will have wasted all of the time you spent reading this guide, all of the time I spent writing it, and, more important, will continue to have terrible servers. I also, you know, spent a good 40 hours writing the software I'm about to present to you, so hopefully that makes a difference or something.

    Step 1: Install Python 2.7.6

    You can get Python here: https://www.python.org/downloads/

    Install it using all of the defaults, there's nothing to it. When the installation has finished, you're going to have to add the Python folder to your PATH variable. This is what lets you run Python on the command prompt.

    To do this, o
    pen the Control Panel and go to System and Security -> System -> Advanced System Settings.

    [​IMG]

    Go to the "Advanced tab" and click "Environment Variables" at the bottom. In the bottom scroll box "System variables" locate the entry called "Path". Select it and click edit. In the field that says "Variable Value", append "C:\Python27;C:\Python27\Scripts\;" to the very end. Make sure theres a ";" between the previous entry and what you just added. It's very important to have a semicolon separating each entry in the PATH variable.

    [​IMG]


    Once you've done that, you should be able to open a command prompt and type in "python --version" to get your python version. Verify you can do this before proceeding to the next step.

    [​IMG]


    Step 2: Install Pip

    Pip is a package manager for Python. It will allow you to install great packages for Python including the totally amazing SE Garbage Collect package that I wrote myself.

    To install Pip, you must first download the get-pip.py file from here: https://bootstrap.pypa.io/get-pip.py

    Now, open up a command prompt and navigate to that file. Run "python get-pip.py" to install Pip. If this works, you should be able to run "pip --version" to see your pip version. Make sure you can do this before proceeding to the next step.

    Step 3: Install SE Garbage Collect

    This is the tool that inspired me to write this guide. It will change your life. Tell me all about it in the comments. In fact, what you should do is post before and after numbers for what your "Update Lag" was and now is after cleaning out your save file.

    To install segc, run "pip install sbsmanip". If it was successful, you should be able to run "segc --help" to see the usage of the tool.

    Step 4: Cleaning your SANDBOX_0_0_0_.sbs

    This is the most exciting part of all. You're about to remove so much junk from your save file that you'll just be amazed.

    As the usage from "segc --help" suggests, you'll need to type in a big long command. Luckily for you, you can put this command in a script, possibly even the same script you use to do backups, to make operation super easy. I don't want to bother explaining quite what the arguments are yet, I'll just show you an example of the command that I use for my own save file.

    Code:
    segc --whitelist "beacons|players|asteroids" --remove-ship "C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Content\Data\Prefabs\RespawnShip.sbc" --remove-debris 6 --remove-far 50000 --remove-pure-armor "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP\SANDBOX_0_0_0_.sbs"
    With the paths taken out, it's pretty readable:

    Code:
    segc --whitelist "beacons|players|asteroids" --remove-ship "RespawnShip.sbc" --remove-debris 6 --remove-far 50000 --remove-pure-armor "SANDBOX_0_0_0_.sbs"
    Let me walk you through what the script will do and what the arguments mean.

    --whitelist "beacons|players|asteroids"

    This flag prevents ships with beacons and power sources from being the targets of removal as well as asteroids and players. If you didn't care about whitelisting any of those, feel free to change it up: "beacons|players", "beacons|asteroids", etc. Make sure you add quotes around this argument if you use the | symbol.

    --remove-ship RespawnShip.sbc

    This flag tells segc to remove all ships from the save file that look like the ship contained in RespawnShip.sbc. It does this by figuring out exactly what types and how many components are in the ship and then compares those numbers to every other ship. The end result is that it's extremely unlikely that any ship other than the respawn ship will be deleted.

    --remove-debris 6

    This flag tells segc to remove all ships and stations with less than 6 components. This is incredibly useful for leaving the big stuff in your world but removing the cruft.

    --remove-far 50000

    This flag tells segc to remove all entities that are beyond 50,000 meters from the center of the sector.

    --remove-pure-armor

    This flag tells segc to remove all entities that are composed entirely of armor

    Example usage:

    Here's an example from the output of the program on my current save file. I first need to fully close out of the game. Technically, you just need to close out of the world, but I have no way of knowing if they ever read those files when you're not in the game. Now I'm going to invoke that long command I previously showed you.

    segc takes a second or so to parse the save file and then presents me with a list of everything that should be removed asking if I would like to remove them:

    Code:
    ignoring  5705143158378874429 due to powered beacon on board: I left fuel for recovery. - Your friendly neighborhood pirate.
    ignoring -7961055990757412822 due to powered beacon on board: Fundevin's Green Transport
    ignoring -8408024416618332233 due to powered beacon on board: The Ore Shitter
    ignoring  2511031136477662399 due to powered beacon on board: Red Viper
    ignoring  8234831843309987027 due to powered beacon on board: Jolly Cooperation
    ignoring    44440885724470034 due to powered beacon on board: station
    ignoring  1489526915954518402 due to powered beacon on board: .
    ignoring -7249007408327830867 due to powered beacon on board: If you are lost and confused
    ignoring   431688034701747931 due to powered beacon on board: Black Bird (Glad to make your aquaintence)
    ignoring -1893249825500890074 due to powered beacon on board: unknown
    type: CubeGrid  id:  5178954256996494317  dist:  54.07 km  parts:  81
    type: CubeGrid  id:  9069767951205192221  dist:  52.88 km  parts:  99
    type: CubeGrid  id:  5301811506999815034  dist:  61.14 km  parts:  46
    type: CubeGrid  id:   641482647259257243  dist:  60.14 km  parts:  91
    type: CubeGrid  id: -8058217298132555620  dist:  54.65 km  parts:   8
    type: CubeGrid  id: -5419942396869964729  dist: 136.34 km  parts:  72
    type: CubeGrid  id: -7347964388341811968  dist: 125.92 km  parts:  67
    type: CubeGrid  id: -3632231220873488533  dist:  71.07 km  parts:  30
    type: CubeGrid  id: -9107354498612320208  dist:  76.53 km  parts:  62
    type: CubeGrid  id:  3227181864197887796  dist: 802.98 km  parts: 105
    remove 10 entities? [y/n]
    Once I type "y", it presents me with another list of entities to remove. Note how all of those entities were over 50 km from the center of the sector.

    Code:
    type: CubeGrid  id: -1706439644339640395  dist: 48.98 km  parts: 1
    type: CubeGrid  id:  3302587750057306277  dist:  1.28 km  parts: 1
    type: CubeGrid  id:   636553739865243924  dist: 23.11 km  parts: 3
    type: CubeGrid  id: -5327121460745511815  dist: 25.13 km  parts: 1
    type: CubeGrid  id: -4484550015202037877  dist:  3.02 km  parts: 3
    remove 5 entities? [y/n]
    This new list is all of the entities with less than 6 components. I'm going to remove those as well.

    Code:
    type: CubeGrid  id:  8318323656404013613  dist: 2.42 km  parts: 106
    type: CubeGrid  id: -2339999346588380284  dist: 9.30 km  parts: 106
    type: CubeGrid  id: -6435787237300181658  dist: 8.82 km  parts: 106
    remove 3 entities? [y/n]
    These ships are starter ships that have been introduced to the game world since I've last restarted it. You can tell because they all have exactly the same number of components: 106. It doesn't say so here, but they also have the exact same component composition as well.

    Once I've confirmed that I want to remove each of those sets of entities, segc tells me that it's writing to disk.

    Code:
    writing changes for 18 entities
    And now it's done!

    To read more about usage and other features or to ask questions about the script, please post in the relevant topic:

    http://forums.keenswh.com/post/show_single_post?pid=1282380850&amp;postcount=1

    Creating a script to do it all:

    The next step is to combine all of what we've learned into a single script that can be executed to backup the save, run the garbage collection on it, and then save the result. Here's the simple script that I use:

    Code:
    git -C "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP" commit -a -m "pre-gc"
    segc --whitelist "beacons|players|asteroids" --remove-pure-armor --remove-far 50000 --remove-debris 6 --remove-ship "C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Content\Data\Prefabs\RespawnShip.sbc" "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP\SANDBOX_0_0_0_.sbs"
    git -C "C:\Users\Victor\AppData\Roaming\SpaceEngineers\Saves\76561198019075550\Hardcore SurvivalPvP" commit -a -m "garbage collection"
    pause
    Note the -C parameter to git. That tells git that a valid git repo exists at that location and to run the command from that location. This allows your script to be anywhere on the system and still work. The -a parameter tells git to add the changed files before committing that version to the history.

    You will obviously have to modify the locations of your respective files, but this gives you a good template to go off of. You'll want to save the file with a .bat extension and now every time you want to back up everything, run the scripts, and then save the result, you can just double click on this file!

    8. Conclusion

    I hope this guide has been informative. All of the software that I've linked to here is entirely open source, so I really hope some of you guys might consider contributing to these projects at some point in your lives. Like those projects, my own source is available for anyone to use and I happily receive criticisms and suggestions for improvement.

    If you found this information useful and are just dying to learn more about all of this stuff, please drop me a line either here, my email victor.robertson.iv@gmail.com, or over at Github if it's related to the SE Garbage Collect program.

    https://github.com/vmrob/sbsmanip

    I'm a starving college student like so many others, so if you feel like contributing to the monetary effort required to feed me Chipotle and Jimmy John's, feel free to donate a dollar or two. All contributions go towards keeping me alive and producing excellent code.

    [​IMG]

    Thanks for donating Jan! I'll be sure to add a picture the next time I eat at one of those excellent establishments.
     
  2. Maul555 Apprentice Engineer

    Messages:
    239
    That's a lot of text that could have been replaced by "wait for dedicated servers and beta", but it's great advice for the impatient.

    dont you have school work to do? It looks like this cost you at least an entire evening.

    sorry if that sounded like a jerk thing to say... I probably shouldn't post before I've had my coffee...
     
  3. vmrob Apprentice Engineer

    Messages:
    135
    School work. Like what? Write a toy program that sums up a list of numbers or think really hard about doing something with my life but then just graduating and working at the library?

    Sir. I would prefer to sail through life doing what I love to do. That, right now, is writing utilities for Space Engineers. In fact, I think I've actually spent more time out of game thinking about it than I have in-game playing it.

    Also, on a more serious note, I don't think dedicated servers will come out for at least 2 months and until then SE games become unplayable after a certain amount of time passes without cleaning out the save files. When I first wrote the utility I describe here, I went from over 700 ships on the server to less than 400. That made the game playable again.

    Moreover, I wrote the utilities in python to better acquaint myself with the language and in best practices regarding python. Unfortunately, the little time I spent writing that is more than most people in my field do before graduating which makes them woefully unprepared for the real world.

    In my field, school isn't required under the right conditions and my graduation will just be a cherry on top of a huge pile of experience that exists at the foundation of my being.

    I also don't sleep.
     
  4. gh0st Apprentice Engineer

    Messages:
    137
    I agree with the cleaning out of the session. I've been using the SEToolBox to remove small rocks and debris from the game. After a while the game just simply starts to chug with each new patch of debris, so by doing this and then restarting the environment is smooth.

    Also, good list/tutorial. Just to try it I am tempted to drop money on a new rig.
     
  5. vmrob Apprentice Engineer

    Messages:
    135
    You shouldn't have to do that! My computer is over 2 years old at this point. It runs SE just fine.
     
  6. Replic TuaniOne Apprentice Engineer

    Messages:
    482
    I've tried the removal of the astroids, that worked, but the thing with the git didn't work, I listed everything with that program, but then when I wanted to do this:

    Code:
    [SIZE=3] I would recommend saying something like [B]"initial commit"[/B] and then click the commit button to the left.[/SIZE]
    
    Then I got the error that I needed to sign something?
    
    But anyhow, it helped a little already by removing some astroids :)
    
    
    
     
  7. vmrob Apprentice Engineer

    Messages:
    135
    I would be happy to assist!

    Also, regarding the lag you had in your other topic, I think this will help you with that!

    If you want, I can run the program against your save file for you. Could you zip it up and put it somewhere I can access it?
     
  8. Replic TuaniOne Apprentice Engineer

    Messages:
    482
    OK, that would be awesome!

    This is the file: http://sta.sh/02dndkmjdtoq

    Like I said, The astroids are removed ( most of them ) Only had the problem with git :) ( and the rest of the steps then )
    Thank you for helping me out, would be awesome to have a lag free server, since my friends wanna play on it, but it's just to much lag to have a good play, So if this could fix that, than it will be so awesome ^^
     
  9. vmrob Apprentice Engineer

    Messages:
    135
    Code:
    ================================================
    Sector Statistics
    ================================================
    Total entities:    157
    Asteroids:          91
    Ships/Stations:      7
    Floating Objects:   58
    
    I took a pretty good look at your savefile and I couldn't find anything to remove based on the criteria I usually use for myself. In fact, you only have a handful of entities in the world.

    Could you take a look at your debug statistics menu and tell me what the "Update Lag", "Game Logic", and "Render Requests" fields say? Just provide an average.

    I think, more than likely, the lag you're experiencing is related to the number of asteroids you have. I would recommend heavily reducing the asteroids and then lowering the number of allowed floating objects to 32.

    It would probably be best for you to try to cut the number of asteroids in that save in half. You should aim to remove the large asteroids in order to save yourself some framerate.
     
  10. Replic TuaniOne Apprentice Engineer

    Messages:
    482
    [​IMG]

    This is from the world that I sended you, I shall sent you the survival map, that I made a topic from, Maybe you can see what the problem is there.


    [​IMG]
    I guess you can see that this one is lagging a lot with 30 fps, I need to say though, I had this one Normal now since Extreme was having 12 fps ( Because of the lagg maybe? )

    This is the sandbox for that map http://sta.sh/0b1837bjyji
    It's my survival map one, Maybe you can find something out there?

    Thank you!
     
  11. vmrob Apprentice Engineer

    Messages:
    135
    It seems to be the same thing, very few game entities, a lot of asteroids. What does your cpu usage look like while you play? (task manager should show you)

    What are the specs on your computer?
     
  12. Replic TuaniOne Apprentice Engineer

    Messages:
    482
    I've been looking at it while I was playing ( using my G510 keyboard for that ( display ))
    I've been using 50% CPU at most and same goes for RAM, although I have just 8 GB of ram, sometimes it only hits 60%

    My CPU is a eight-core 4.7Ghz processor, Only issue could be my videocard, but that is giving me 40 fps all the time... ( HD6870 from sapphire ati )

    Any I myself don't have that much lagg, it's mostly friends that play on the server that I host, even though I have a 50MBit connection ( 5MB Download and 10 Upload ) So that should be ok.

    And those friends even have a better videocard than me ( aside from the Same CPU and stuff like that )
     
  13. manveti Trainee Engineer

    Messages:
    76
    I've never used git on Windows, but it's possible that your commit problem is that you don't have a username/email configured, which can be fixed by the following two commands:
    git config --global user.name "My Name"
    git config --golbal user.email "my@email"
    Note that they don't have to be real (for example, I use "manveti" and some "noreply" github email address).

    Also, for the OP: in case you didn't know about it, you can stage and commit existing files in one command ("git commit -a") without having to "git add" and then "git commit". Not that it's that big of a deal, but it can cut the commit scripts in half (as a subversion man myself, I'm not a fan of git's "use 'git add' to tell git I've changed the file git knows I've changed" paradigm, although I can see some situations in which it might be helpful).
     
  14. vmrob Apprentice Engineer

    Messages:
    135
    Great comments; I suppose it's been a while since I've set up a git installation myself. I'll modify my own local and the one I have here accordingly. I've made the changes you suggested and I'm quite pleased with that. Ideally, I would probably use a variable for the path, but meh, oh well.
     
  15. Replic TuaniOne Apprentice Engineer

    Messages:
    482
    I will do that, thank you :) Gonna give it another try ^^

    EDIT: It seems when I do that and press commit, it gives me the same error that I need to identify myself.. No matter what I do, I even used Omit --global, But it didn't work, Guess I need to reinstall the app maybe...

    And else I'll just try to fix it another way or hope that the SE crew will find a way to reduce it much more.
     
  16. vmrob Apprentice Engineer

    Messages:
    135
    Could you try posting the actual output of the command? Screenshot?
     
  17. DrVagax Administrator

    Messages:
    821
    Stickied!
     
  18. vmrob Apprentice Engineer

    Messages:
    135
    Thanks! I'll try to keep this guide up-to-date as I discover new excellent tips and as the nature of the game changes.
     
  19. gFleka Junior Engineer

    Messages:
    562
    Great and useful tutorial :D
     
  20. Niluje Trainee Engineer

    Messages:
    5
    Hello,

    vmrob, this is a great post who give me an idea, because your maintenance part was too hard for me, I decide to make a little soft for clean my save :)

    More info here http://forums.keenswh.com/post/se-clean-clean-your-save-remove-all-debris-6911200?pid=1282884999#post1282884999

    Thanks
     
  21. Hank Trainee Engineer

    Messages:
    2
    The whole pip installation part was written quite poorly..
    Either that or I just really don't know what im doing with Python.
     
  22. Schinxz Trainee Engineer

    Messages:
    5
    Thanks for this guide, it was helpful indeed.

    However, I suggest you add some additional information in the section explaining how to install python, as I know that part can be confusing to people who are not used to that kind of thing.

    You wrote:
    I suggest adding


    Thanks again for the guide :)
     
  23. vmrob Apprentice Engineer

    Messages:
    135
    Thanks for the feedback! I'm glad you pointed this out. It's been a long time since I've done this myself so it's helpful to hear what happens when new people try it. I'll update the topic with the information you suggested.
     
  24. Kordusain Trainee Engineer

    Messages:
    4
    As I wrote in the SEGC main thread, you'll also need to add pip (C:\Python27\Scripts\ by default) to the path variable. That threw me for a loop for some reason. Had to download SEGC from the source by hand instead, heh.

    Still, it's gonna be handy in the future, so thanks for the thread and the program.
     
  25. vmrob Apprentice Engineer

    Messages:
    135
    I've added that information to this tutorial. I would like to avoid repeating myself in as many places as possible, so I'm really considering a portable executable instead of a python script. I would like to cut out the python dependency altogether.
     
Thread Status:
This last post in this thread was made more than 31 days old.