Garry's Mod

Garry's Mod

112 ratings
Precacher -Load before you lag-
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Comic, Fun, Realism
File Size
Posted
Updated
28.559 KB
12 Oct @ 9:40am
17 Oct @ 4:52pm
2 Change Notes ( view )

Subscribe to download
Precacher -Load before you lag-

In 1 collection by Freef
Freef's Misc Mods
48 items
Description
I recommend switching to the 64-bit branch for a potential cache above 4GB.
Allows you to manually pre-cache models and sounds. Will freeze your game!
In case of multiplayer: This can cause client time out when the host does this. Adjust to cl_timeout 500 or more and let the clients start the caching process before the host starts it.

What is caching?
Loading resources from the hard drive into the CPU takes much time and causes the game to temporarily freeze (aka lag.) To fix this, games will utilize the RAM to cache elements near the CPU for quicker access times, usually before they're actually required (hence loading screens.) Gmod only loads the minimum amount of assets (e.g. the map) on startup, which is why you'll often lag the first time a model or sound is used, but not the subsequent times.

The solution
The context menu now comes with a new app called "Precacher". In here, you can select your favorite addons (or base HL2 NPCs) and load their models and/or sounds. This will freeze the game until it's complete without a fancy loading screen, but it will play a sound and close the menu upon completion. Once done, you should have significantly lower inital lag for any assets you cached, like guns or NPCs.

Does it stay with map change?
The Gmod cache is not unloaded upon singleplayer map change, so you won't have to re-cache the assets. However, if you restart the game, much of it will be lost, and once you shut down your PC, the entire cache is gone. That's why Gmod's second start is usually faster than the first one, since the old RAM hasn't been fully overwritten yet. Gmod may also un-cache certain assets over time on its own, so use the 64-bit branch to maximize the cache usage.

If you are tech-savvy then you can also toy around with the precache commands, which are precache_sound_dir and precache_model_dir. The amount of information printed to the console is controlled by precacher_verbosity. Use precacher_verbosity -1 to make it shut up, and precacher_verbosity 2 to be informed of every single action.
Finally, there are also the commands precache_all_addons (not recommended if you have many addons enabled) and precache_all_hl2, which you can add to the Server side of my Auto Command on Start addon.


Have fun!!!
13 Comments
King Of The Family 20 Oct @ 5:17am 
another idea you could make is a "preset" of what you want precached on start. like if i wanted to make it where only modded weapons and VJ SNPCs will precache.
seb 19 Oct @ 12:56pm 
@CADO
that could fix *some* of the lag
arc9 in general is one of the most poorly optimized bases on this workshop
and ironically mw base is like one of the most optimized lmao
CADO [JCT caliphate] 18 Oct @ 4:19am 
This seems like a great optimisation method, I tend to use ARC9 weapons and they lag a metric fuck ton.
Freef  [author] 17 Oct @ 4:59pm 
Awesome, I was thinking you'd use that. The new commands are precache_all_addons and precache_all_hl2, add them to the Server side
King Of The Family 17 Oct @ 3:26pm 
the reason why im asking is cause that way i can use your "auto execute on server start" mod to bypass the whole thing where you have to do it manually after every restart.
King Of The Family 17 Oct @ 1:38pm 
is it possible to make both? one command with and one command without?
Freef  [author] 17 Oct @ 8:24am 
@King Of The Family With or without HL2 assets
King Of The Family 17 Oct @ 12:52am 
can you make a "precache all" console command?
Freef  [author] 14 Oct @ 1:09pm 
I could say a lot here, but long story short:
- You will not have to reapply it on map change
- You will have to reapply it on a Gmod restart, but it should be faster
- You will have to reapply it after booting your PC (since that wipes the entire cache)
I'll clarify it a bit more in the description, thanks for the questions!
Milkyway22 14 Oct @ 10:25am 
real question is does this need to be manually re-applied each time you launch gmod? or a new map? cause if so i feel like that would be a huge negative for this mod and should have a feature [if thats the case] to have it stay applied intill you undo it.