Garry's Mod

Garry's Mod

MelonWars: Factions
 This topic has been pinned, so it's probably important
JonahSoldier  [developer] 9 Jul, 2024 @ 7:13am
Performance Tips
Read this first!
This post was written to be accessible to people who are inexperienced with Garry's Mod and/or technology in general. If you think you already know what you're doing, skip directly to "How to actually deal with lag"



Before anything else:
I highly recommend you disable any addons you don't intend on using while playing. Most gmod addons have at least some sort of impact on performance. And addons that change how basic game systems work may break things (e.g. VFire breaks any fire-using units in Melon Wars).

If you don't know how to disable your addons:
Go to the addons menu (from the main menu in-game), and hover over the icon of an addon you want to enable/disable. It should display the description of the addon, and several buttons, among which will be an enable/disable button.

In-order to manage your addons more effectively, look for the wrench icon in the bottom right. Clicking that will open a menu with options to enable/disable all addons at once, as well as to create presets. I recommend you set up a minimal preset for MW if you're going to be switching back-and forth a lot.

Different types of lag
Not all lag is created equal
It's important to be able to recognise the different types of lag you can experience, and to know what causes them. Don't immediately blame other people if you're having performance issues. That's not helpful, and it usually isn't their fault either.

  • Client-Side lag
    Experienced as a low frame-rate. This occurs when your computer isn't strong enough. Usually this is related to rendering, but can be caused by any code running solely on your computer.

  • Server-Side lag
    High frame-rate, can look around fine, but the world around you seems to freeze / only move in steps. Sometimes described as "rubber-banding". This is experienced very similarly to network lag, but with the difference that everyone on the server will be experiencing this, and the host will be experiencing client-side lag. This happens when the host's computer isn't strong enough to process everything that's going on (e.g. if a lot of physics objects are moving).

  • Network lag
    High ping. As mentioned, this is a very similar experience to server-side lag, the big difference being that the host of the server won't be experiencing any lag. Different players may also experience a different amount based on their proximity to the host. This can be an issue with both the host and individual players. And can manifest in different ways, as your internet upload/download speed may be different. As a rule-of-thumb, if everyone in a particular region is experiencing this an equal severity, it's the host's fault. If they're all experiencing it with different severity, it's their fault.

How to actually deal with lag
There are different approaches to dealing with different types of lag. Many of them involve trade-offs or compromises.

  • General Tips
    If all else fails, just slow things down. You can reduce game-speed using the host_timescale console command. I personally use this ULX extension as it makes it a bit easier to manage, and slows sounds.
    Slowing the game down will do at least a little bit to alleviate every type of lag, but it is most effective at dealing with Server-Side lag, and very limited in its effectiveness against Client-Side lag.


  • Dealing with Client-Side lag
    Client-side lag is almost always rendering-related. So most of the methods of dealing with it focus on that.

    Commands
    There are a number of console commands that can be used to improve this, the biggest among them being:
    gmod_mcore_test 1
    I won't go into detail on every single console command you can use as that'd make this (already long) post even longer. Go look up optimization tips in the guides section. You should be able to find info on what commands to use, and how to set it up so that they're run automatically.

    Prop Maps
    There's a common misconception that prop maps (maps built in-game out of physics props) cause increased strain on the server compared to hammer maps. If you've done everything correctly this isn't the case.

    Prop maps DO however have a notable effect on client-side lag, as every prop needs to be drawn. Normal gmod maps use a lot of tricks and pre-processing to reduce the amount that needs to be drawn, and to do it more efficiently. Prop maps, obviously, don't. If you're struggling with low frame-rate you should seek to optimize the prop map (by reducing the number of props it's made from) or switch to a hammer map.

    Misc
    In the player menu, in the tool, you can switch outpost zone rendering to use spheres instead of outlines on the floor. This is somewhat less intensive than the default method of drawing them, but not by a huge amount.

    Lowering your graphics settings in the options menu may help improve your framerate.

    r_3dsky 0
    hides the 3D skybox (the stuff you can see outside of the map), which may help, especially on maps with a lot of detail in their skybox.

  • Dealing with Server-Side lag
    If your host is lagging, there isn't a huge amount you can do. You either need to choose someone with a stronger computer to be the host, reduce game-speed (as mentioned in general), or reduce the max power. This type of lag is most likely when a lot of units are present, and especially when a lot of units are moving.

    If you're playing on a prop-map, you should click the "Set Props Static" button at the bottom of the admin menu. This will only show up if you're a super-admin (i.e. the host), and will make all frozen props on the map static. This prevents physics updates to the props, and may improve your performance, though usually not by very much. This is most effective when you have a very large number of turrets/baseprops spawned in, as these also receive updates when the prop they're attached to does.

  • Dealing with Network lag
    Choosing a good host
    Before doing anything in-game, you should prioritize the person with the best internet to be the host. In particular you want someone with high Upload Speed. Your upload/download speed can be checked easily online.
    After good internet you should try to choose someone who's closest to everyone else. Especially closest to anyone with weak internet, as they'll be disproportionately affected by distance.

    Limiting players
    In-game, try to limit the players on the server to just those who are actually in the match. More players means more people who need to be sent data about what's going on. If need-be, a participating player with a good connection could stream their screen to anyone intending to watch the match.

    Close anything else using the internet
    If you're still experiencing network lag, try closing anything else that might be using up network resources. Streaming music or videos in the background while you already have a poor connection will make things worse. So can being in a discord VC during the match. If things are really bad, use in-game chat instead.

    Misc
    Network Performance mode can be enabled at the bottom of the admin menu (only visible to super-admins). This trades a bit of extra strain on the server and the possibility of some mildly weird behaviour for a reduction to network lag. Specifically this makes it so that only units players are looking at will be networked to them. This is less helpful for 1v1s, as you'll probably be looking at whatever's happening anyway. But it is incredibly helpful for larger matches (2v2s, 3v3s, etc), as action is likely to be occurring in several places at once.

    The (very limited number of) tips for Server-Side lag also apply to Network lag.
Last edited by JonahSoldier; 1 Aug, 2024 @ 9:55am