In T248925#8188458, @cookmeplox wrote:FYI: PHP 8.1 made major changes to how $GLOBALS works, and one of the side effects is that using array_key_exists on $GLOBALS is now a linear-time operation instead of constant-time. MediaWiki uses this construct pretty extensively in GlobalVarConfig, which is ~1000 times slower in 8.1 than it is in 8.0, due to $GLOBALS having 1000-2000 entries in it.
The effect of this (in our testing on runescape.wiki, at least) is that total parse time silently went up about 50% when switching from 8.0 to 8.1, due to many thousands of calls to GlobalVarConfig::get, which now takes about 20 microseconds each.
I have filed a bug against PHP core about this. In the mean time, changing GlobalVarConfig::get to
isset( $GLOBALS[$var] ) || array_key_exists( $var, $GLOBALS );seems to reduce the time spent in array_key_exists back down to pre-8.1 levels (note that just using isset on its own won't quite work if the value is null). If you are currently using PHP 8.1 in production, I recommend trying this out.
Filing as a stand-alone task so we don't forget.