Skip to content

Global Variables cause stuttering lag

Daedalus87mDaedalus87m Member Posts: 92
edited November 2012 in Original BG2 Bugs
Global variables which are used in various scripts are stored inside a hashmap which is resized only when it's full. When there are many variables and hash table is nearly full, its performance degrades to O(n) instead of average case O(1). As a result under certain point of gameplay, when number of variables is close to 1024/2048 or even 4096, some GetGlobal's will be executed in linear time instead of O(1). And some script variables will be accessed by far longer than the others.

There is a workaround that partially fixes this by adding dummy variables to the map, which force it to overflow and get rehashed, but upon closing BGMain the map is stuffed again and the procedure has to be done again at every launch.

Credits to Suslik for finding out.


Edit: As a sidenote, I just found out that the newest release of "ToBEx" fixes this.
Post edited by Balquo on

Comments

Sign In or Register to comment.