Wednesday, July 2, 2014

Skyrim INI tweaks -- Papyrus and Scripts

Papyrus is the name of Skyrim's scripting engine. These are my current settings:

[Papyrus]
fUpdateBudgetMS=11 <-- A tweak I see a lot is to change this to 800ms. Don't.
fExtraTaskletBudgetMS=11 <-- Again, 800ms? No.
fPostLoadUpdateTimeMS=2000.0 <-- 2000 is the maximum value.
iMinMemoryPageSize=256 <-- Default is 128. This must always be smaller than the value below.
iMaxMemoryPageSize=512 <-- Never change this or Skyrim's memory allocation will fail.
iMaxAllocatedMemoryBytes=153600 <-- Only change if you have an actual reason for doing so.
bEnableLogging=0 <-- Setting this to "1" will create a log file of Papyrus activity while you play.
bEnableTrace=0
bLoadDebugInformation=0
bEnableProfiling=0

*Set these values to anything you want but that doesn't necessarily mean the game engine will listen.

These settings belong anywhere inside the SKYRIM.INI file. Caution: Anytime you run the official skyrim launcher SKYRIM.INI will be recreated with vanilla settings. So either make the file read-only or use Mod Manager.

What is a script
Simple answer; it's just like in the movies. Scripts are a set of instructions that the game carries out, more often that not applied to actors (NPC's).

Before we start
Your computer has 16 milliseconds to complete all calculations and draw the image to your screen in order to maintain 60 frames a second. To achieve 30 frames a second your computer has 33 milliseconds.

The settings
Below are the only values you can safely change:

fUpdateBudgetMS
Defines the maximum number of milliseconds allowed, per frame, that the game may spend executing scripts before moving on to other tasks such as rendering graphics to your monitor.
Skyrim will determine it's own maximum value. This will only ensure the game doesn't spend anymore time than what is set here. If you're aiming to run your game at 60 fps the computer only has 16ms to complete every calculation the game is calling for. Setting this value too high will drop your frame rate because the game will spend more time running scripts than doing anything else.

fExtraTaskletBudgetMS
Determines the maximum number of milliseconds the game may use to execute scripts if the scripting system itself becomes over-loaded.
Pretty much the same as above but this kicks in when the scripting system becomes overloaded. Again Skyrim will pick it's own setting. All you can do is set the maximum amount of time the game may spend calculating scripts before moving on to other tasks (a.k.a. everything else).

fPostLoadUpdateTimeMS
Determines the minimum amount of time the game must spend on calculations during load. Loading a save, entering a city, entering a building, basically anytime you see the loading screen - that's a "load".
For whatever reason the default setting for PC is 500ms but you may raise this as high as 2000ms. All console versions of Skyrim are set at 2000ms. With this set at 2000 even the fastest CPU's and SSD's quickest load time will be two seconds. Papyrus will use those two seconds to execute scripts during load. Unfinished script load leads to Papyrus freeze (mods stop working) and/or CTD.

iMinMemoryPageSize
Determines the minimum amount of memory the game must allocate to the scripting page file (if you'd like more information on page files Wikipedia is a good place to start).
If you're running a massive amount of scripts that are constantly breaking then raising this value can help. Otherwise leave it at the 128 default value because, like all Skyrim settings, raising a value when it doesn't actually need to be raised will raise overhead, hurting your game not helping it.

iMaxAllocatedMemoryBytes
Determines the maximum amount of memory the game may allocate to the scripting memory block (read back to my post on memory blocks if you need a refresher).
Similar to the above. Best to leave this at the default value of 76800 unless you have an actual reason to change it.

bEnableLogging
Tells the game whether or not to create a log file of Papyrus activity running behind the scene while you play. It's one way to hunt down mods that are creating script lag or CTD's.
Only useful for finding rogue scripts or determining sources of Papyrus freezes/CTD's. Warning: A lot, and I mean a lot, of mods will spam harmless errors into the log. If you see a particular mod spitting out error after error check with the mod author. Some authors don't care if your log is spammed because this setting should be off while playing. The generation of the log while playing will cause slowdown in of itself.

What is Papyrus lag/freeze
It's when something in your game stops working. I usually experience this when More Hotkeys Please (try AH Hotkeys or Grimy's Utilities instead) stops working in the middle of a large battle. If you notice a freeze of any mod you need to save right away, exit the game, reload, and pray.
If you continue to play with Papyrus frozen, every unresponsive command you send will continue to stack and  will execute all at once next time you load that game causing instant CTD.
The occurrence of a Papyrus freeze indicates either start tweaking the .INI file and/or getting rid of script heavy mods. Papyrus freezes won't go away by doing nothing and errors will continue to pile up in your save possibly leading to a completely unplayable game that may not manifest until 50 levels down the road.
I chose to give up Player Headtracking and Footprints (both awesome but script intensive mods) in favor of gigantic yet stable battles where I can bind different shouts through hotkeys, not menus.

**Note on my settings: I run a beast, which allows me to spend up to 11ms on just script calculations alone leaving only 5ms for rendering graphics yet still achieve 60fps during battles between 40 Stormcloaks and 40 Imperials and two dragons along with NLA ENB + AO + DoF @ 1920x1080 resolution.

***Specs for your information and comparison:
CPU: 3630k overclocked to 4.2ghz
GPU: 3x GTX 670's 2GB in Tri-SLI
RAM: 16GB DDR3 2133 @ 9-11-10-28 T2
SSD: 240GB Samsung 830
OS: Windows7 64-bit

****Script heavy mods I'm (was) using
More Hotkeys Please (outdated)
Wet and Cold + Ashes
Locational Damage (outdated)
Smart Cast (outdated)
Lively Inns And Taverns (outdated)
Dual Sheath Redux (outdated)
Bash Patch: 50 active AI + 40 combat AI (running 100/80 now)