Fallout 4

File information

Last updated

Original upload

Created by

SKKmods

Uploaded by

SKKmods

Virus scan

Safe to use

About this mod

Suffering from lag spikes ? Is it rendering or script lag ? CC content clogging your quests ? Equip a ring to receive regular on screen notification on script latency.

Requirements
Permissions and credits
Mirrors
Changelogs
Suffering from lag spikes ? Is it rendering or script lag ? CC content clogging your quests ? Equip a ring to receive regular on screen notification on script latency. 


This is a diagnostic tool not a solution



Install this mod at any time and the player is given some Elven* forged rings of power:

.SKK Script Latency Ring 05 sec
.SKK Script Latency Ring 10 sec 
.SKK Script Latency Ring 20 sec
.SKK Script Latency Ring 30 sec
.SKK Script Latency Ring 60 sec 

They will test the latency of the papyrus script environment every NN seconds and OnLocationChange with an on screen message (and debug log output) for an indication of the load on that game system along with a script "frames per second" processing rate, learn more HERE.

Try to stay out of menus, holotapes and notes when you are investigating lag, as each time you open one the test timer is cancelled when the world stops to avoid reporting that on hold time as lag.

Remove the ring to stop the test. Spare rings can be crafted at a Chemlab if misplaced and not in inventory. 
 
As script processing priority is not known to be load order dependent, it probably doesn't matter where it goes.


Papyrus script lag diagnostic

The test starts a real time script timer for the specified duration. The on screen message shows the percentage of extra real time the timer ran for, which is an indication of the processing queue - backlog - latency - lag.

If you see no messages, you do not have any detected latency at the moment. After 60 seconds of silence a comfort message [ No script latency detected ] will pop so you know the test is still running.

Using the 10 second timer test, a notification of 50% lag means it took 15 seconds to complete the ticks. Be aware that the Papyrus scripting sub-system is s l o w and only has a tiny amount of compute resources allocated to it compared to the other real time subsystems. Using tools like the (excellent) Fallout Performance Monitor will not show script resource over commit.

The script "frames per second" test runs a set of Utility.RandomInt() functions every test timer interval on a separate thread. Each of those function calls takes one game frame, so its simple to count the number of function calls completed in a known time to get the script frame rate. Yes, it is always the same as the Nvidia overlay FPS counter, so this empirical evidence can help to educate the nonsense opinions passed off as fact on Reddit. 



Just too many Papyrus script function calls ...

... trying to do too much with not enough real time to do it in.  The recent promotion of Sim Settlements and Pack Attack NPC as best ever Fallout 4 mods ever in the history of everness has generated a spike in combined installs. Those users of my real time combat mods like Combat Stalkers and/or Settlement Attack System observe extreme actor behaviour lag (responsing to events) and Script Lag Detector reports a significant back-log, especially around workshop combat.

That's simply too many scripts calling too many functions with not enough script processing time slices to cope with all of those threads in the real time frame rate. There is no PRACTICAL way to rob more time for the script system AND preserve frame rates, you are asking for too much from limited resources. The only solution is to switch off real-time script functions (headshots and limb damage scripts are horrible resource hoovers) in quality mods that provide in game settings or configuration switches. Disable functions, but of course don't remove scripted mods from a save game unless the mod has a clearly documented and tested  shut-down method, else that will cause you even more problems with orphan scripts running wild.

Further reading: Papyrus Latent Functions (note latent functions LOCK a script, the language on that page is OPPOSITE to actual behavior d-oh !). Papyrus non-delayed native functions (from Skyrim). Papyrus Threading (do more with less).


OnCellAttach and OnLoad event scripts

A clean vanilla base game will run with 0% lag until you hit busy rendering + actor AI spaces like College Square, Boston Common and outside Goodneghbor when script lag usually coincides with FPS drops and cell load stutters. The faster you move the more queue or backlog can build up. Console [ player.setav speedmult 200 ] and see what happens when you sprint across those cells.

One of the authors of the Papyrus scripting engine (SmkViper) authoritatively published that script calls can't affect the display system as they execute IN BETWEEN FRAMES, it's the other way around; frame rate can affect script execution.  Except where a script is vomiting up large numbers of spawned actors & complex objects which need to be drawn/rendered, the objects will affect FPS. Point is the script function calls themselves do not affect frame rate. Even the most nasty recursive script while loop has no impact unless its doing stuff to graphically rendered world objects or compute intensive AI. It is the number/complexity of objects and messing with optimisation systems which affect your frame rate.

If there may be a significant number of actors in the loaded area causing issues, use SKK Object Counter to count them. The vanilla game maximum is 130 actors in the default 5 uGridsToLoad active area around GoodneighborExt02. Fallout4.exe will not load games with more than 300 actors in the active area, which is 13 uGridsToLoad around GoodneighborExt02.

The OnCellAttach/OnCellLoad visual freezes may be high scenery/actor poly counts rendering in, missing previz or broken precombines choking the rendering system, a crap-tonne of actor AI waking up to do immHursive stuff, and that frame rate drop slows down script engine processing which is mostly bound to frame rate.

Many objects with complex 3d also have scripts attached like Actors or Workshops. A tonne of them loading in from over ambitious spawning mods will increase both the the rendering and script processing loads. Ideally this latency test would run OnCellAttach() or OnCellLoad() to help nail those naughty sources, but there is no generic registerable event for that, so we have to make do with  the less predictable OnLocationChange() which is irregular as named world location boundaries vary wildly.


TL;DR Game freezing for N seconds on cell transition is either:
broken previsibines, broken facegen, loose textures, over complex meshes or slow storage device.
No, not scripts.



Workshop Settlements & polygons

Players love to break precombines to scrap dirty scenery objects in their settlements (or adding yet more stuff to already stressed downtown areas). Breaking precombines generally slows down the frame rate.  Frame rate governs the execution rate of many script functions, and settlements are chock full of objects running scripts like settler actors and resources. Double-whammy. Then add in the immersive high polygon 4K UHD texture settler overhauls and hundreds of high poly high texture built items with increased build areas and build budgets ... LOL come on, free lunches are only for children.


Actors and Textures

Or it may be that your custom actors have not regenerated facegen data, or, that face data is strewn around in cancerous loose files rather than fast streaming BA2 archives. As those actors cells load, the game engine has to work extra hard to regenerate the mess that you created, on the fly. Applies to slooty clothing, shiny armor, and awesome weapons as well.  

Or it may be that the complexity of all your lovely UHD ponytails, clothing and weapons use so many polygon/triangles that there is just too much stuff to draw. Apparently 100K polygon items (backpacks ? weapons ?) are bad news, so 20 settlers wandering around on screen looking awesome with ModenWarfare weapons and Halo armor will generate a significant load.


Donwntown Actors

Old model consoles regularly lock up in Downtown Boston after the cancerous November 2019 1.01.162 Fallout4.exe update. Yes there is a heap of scenery to render, bu there are also a tonne of actors in the active area around the player. Whilst most of the base game limits itself to ~50 active actors in the uGridsToLoad around the player, the highest counts (from SKK Object Counter) are:

Spoiler:  
Show

CELL,Actors,RETriggers
GoodneighborExt02 (0000E097),124,9
FinancialPostalSquare (0000E096),117,8
TheaterHub360Ext (0000E0B6),111,9
MassFusionExt02 (0000E059),109,7
CrossRoadsExt01 (0000E0D5),96,9
FaneuilHallExt (0000E058),95,5
CombatZoneExt (0000E0D7),93,7
BostonCommonExt03 (0000E0B8),91,8
Vault114Ext (0000E099),91,8
Financial21Ext (0000E076),90,3
BostonCommonExt04 (0000E0F7),87,5
Financial18Ext (0000E057),87,3
MassFusionExt (0000E05A),86,7
BostonCommonExt02 (0000E0D8),84,6
VaultTecOfficeExt02 (0000E07A),81,8
ShamrockTaphouseExt (0000E0B4),77,4
USSConstitutionPostExt (0000E039),77,4
BackBayCarDealershipExt (0000E116),76,4
MassBayMedicalCenterExt (0000E0F5),74,7
BeaconHillPlaygroundExt (0000E05B),73,6
BostonCommonExt (0000E09A),73,7
FensStreetSewerExt (0000E4EC),72,0
CustomHouseTowerExt (0000E075),69,2
BostonPublicLibraryExt (0000E4C7),68,4



Complex Actors linked to complex scripts

Typically engineering issues are the result of not one but a combination of problems or a cascade of events, so look out for;

(1) Larger settlement areas + increased build budgets + lots of settlers with combat ponytails and immersive eye shadow.

(2) Lots of followers + high polygon backpacks + visible high poly weapons (naturally with ponytails, eyeshadow & the rest).

(3) Massive actor spawning solutions + complex combat AI scripts and corpse retention hacks (ponytails and backpacks optional). 

(4) Pick and mix from any and all of the above. 


Just too many objects in the world

Skyrim has a limit of 1,048,576 persistent + temporary object references loaded in memory, some say Fallout 4 can cope with double that (unverified). Permanent references are always loaded in memory, Temporary should only be loaded in the active uGrids around the player, but all references in ESP and ESL mods are apparently always loaded regardless of temporary or persistent. 

Mods that change, add or create large volumes of object references either static placed or dynamic spawns can cause issues, so count your load order static object references with this xEdit script (it will not detect stuff dynamically spawned in game). Fallout4.esm has 62,700 persistent references, NukaWorld adds 17,000 and the largest SKK mod 4-76 OpenWorld only adds/modifies 155 references (plus up to 2,000 scripted actor spawns when the game runs). Its the overhauls/worldspace mods known to touch, place or spawn 300,000 references to look out for ...


Messing about with Papyrus INI settings

Some script intensive mods suggest adjusting Papyrus INI settings. Adding memory for scripts that use stacks of properties and variables seems sensible. Monkeying with time such as fUpdateBudgetMS seems futile as YOU CAN'T CREATE TIME. Allocating more time to Papyrus processing steals it from some other CreationEngine process like the rendering pipeline, no one has done performance profiling to publish the actual impact pain/gain curves. Amusingly some Papyrys execution is tied to framerate so stealing time from frames can actually SLOW DOWN Papyrus script execution. LOLs all 'round, like putting bigger brakes on a car that has fucked tyres.



TL;DR Summary

Some of the principle causes of FPS drops which slows down framerate bound script execution:

> Increasing uGridsToLoad active area from the default 5 (10,240 game unit radius)
> Disabling or breaking static item precombined cells (also breaking precomputed visibility).
> Scripts that spawn complex objects, or large volumes of objects or (best yet) large volumes of complex of objects !
> Large numbers of actors with complex real time scripts in the active area (SKK scripts cap at 64 for Xbox, 96 for PC).
> Actors without packed face data.
> Unnecessarily high polygon count meshes.
> Uncapping settlement build budgets (too many polygons again).
> Unnecessarily high texture resolutions. 
> Loose textures not packed into BA2 archives. 
> Too many ObjectReferences loaded in memory.


Who to blame ?

Working out which mod or script is causing lag is the really tough part. If you are on PC, use the debug log to see what may be dumping when the persistent lag starts. For Xbox it's more qualitative: what were you doing, and which of your scripted mods do stuff around that event or location.

I don't make any graphical/precombine/actor changes to my games and always find that visual or script lag coincides with high volumes of object and actor OnLoad() scripts firing as the parent cells attach. Look out for mods that generate large numbers of HACKED actors or SPAWN and then DON'T CLEAN THEM UP, or mods that change actors behavior with super-clever scripts. That all costs compute.


Sample Debug Log output (if enabled):


                            Actual     Delta     Delta    Frame
Cell Location               Time       Time      Percent  Rate  
<SanctuaryExt03 (0000DD61)  10.033001  0.033001     0       0
<SanctuaryExt (0000DD60)    10.015999  0.015999     0      57 < Sanctuary bridge OnLocationChange visual stutter
<Wilderness (0000DD80)      10.483002  0.483002     4      59 < Sanctuary bridge OnLocationChange script lag 
<RedRocketExt02 (0000DDA0)  10.022003  0.022003     0      59
<POICC07 (0000DDC1)         10.027000  0.027000     0      59
 

This is a 5 minute high endurance sprint from Vault 111 new game start (plain vanilla base game, no DLCs, no mods, no women, no children) to Diamond City main gate. Shows the usual cell load stutters at Sanctuary bridge and passing the Switchboard.  Notice how script lag and fps drops are related, but don't appear to be simultaneous:

Spoiler:  
Show





If nothing is dumping to the debug log, the only way to be sure is to unpack mod scripts using Bethesda Archive Extractor  and run Champollion PEX to Papyrus Decompiler to find things like script recursion, tonnes of real time event handlers or complex OnLoad events and then instrument them with Debug.Trace() output. Unfortunately those forensics need a lot of time and a high level of specialist papyrus scripting knowledge which is not worth investing just to identify broken mods.


To be clear: this diagnostic provides direction, it is not a solution to the poorly constructed or conflicting software you chose to run. Solving latency issues in complex real time systems is an expert job that takes a heap of training and experience. 


Known Issues


(1) Screen notifications may stop after long periods in workbench crafting menus. Clears on save and reload.

(2) DO NOT RUN THIS CONSTANTLY it is a diagnostic tool to investigate specific issues. There have been several reports that the framerate script instances can stack up not closing down, even though the calling script has a lockout to prevent multiple active instances.


Compatibility 

The mod has no dependencies on extenders or DLCs and does not change any base game assets or objects, its 100% pure new Creation Kit forms and scripts. Remove rings before disabling this mod.  Only remove mods if you are happy to accept potential conflicts from load order changes in a save game.


Nexus PC manual installation

Copy  SKKScriptLatencyTest.esp and SKKScriptLatencyTest - Main.ba2 to your ...\Fallout 4\Data directory, enable in the Bethesda mod menu, mod manger or whatever.


Nexus FAQ

> Why is there no ESL version ? Because life contains enough hassle already, you can ESL flag the ESP yourself tho.

> Wont running this detector cause more script lag ? Possibly, and if starting a timer causes more script lag then your save game has some really serious issues.


********************************************************************************************
If you have read the comprehensive solution description and still need help,
use the SKK Mods Discord channel discord://discord.gg/tgKNT77DC8
********************************************************************************************