A_RemoveLight causes severe lag on high detail maps

Fri Oct 02, 2020 2:06 am

Discovered this accidentally while playing my mod recently. I have a certain projectile that manually attaches a light to itself, then removes it on death (mainly because it uses the same sprite and frame on both spawn and death, so I can't simply use gldefs to assign it).

The following file is a stripped down version of that projectile. Typing "summon loveheart" in any map with lots of complex geometry (this even includes Frozen Time, so there's that for a test), and waiting for the projectile to hit something, you'll notice gzdoom will freeze for a while, every time. It appears that the slowdown happens somewhere in FDynamicLight::CollectWithinRadius (a_dynlight.cpp line 356).

Re: A_RemoveLight causes severe lag on high detail maps

Fri Oct 02, 2020 2:36 pm

Curious. Does it lag more if you just deactivate the light in particular?

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 03, 2020 3:42 am

The lag is ONLY caused by removing that specific light the projectile attaches to itself.

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 03, 2020 6:40 am

What happens if you deactivate, and then remove the light? (Just going on a haunch here)

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 03, 2020 9:15 am

It's not possible to deactivate the light if it's handled through AttachLight.

There's no function for that.

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 17, 2020 4:46 am

I cannot reproduce any slowdown, not even in a debug build.

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 17, 2020 6:02 am

Guess it fixed itself, can't reproduce it either.

Edit: Nevermind, it happened again, seems to be entirely random. In most cases it only happens on specific launches.

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 17, 2020 6:11 am

Are you even sure it's really the light and not a random coincidence?

This looks more like a garbage collection related problem. From the looks of it that projectile is spawning quite a bit of effects actors.

Re: A_RemoveLight causes severe lag on high detail maps

Sat Oct 17, 2020 1:10 pm

Considering that I don't see the issue ever happen if I get rid of the light attach/remove, I doubt it's the effect actors. I spawn boatloads of those in the mod proper and there are no issues with that.

Re: A_RemoveLight causes severe lag on high detail maps

Wed Aug 11, 2021 12:21 pm

Does this still happen after today's change to the light management?

Re: A_RemoveLight causes severe lag on high detail maps

Wed Aug 11, 2021 5:36 pm

It's not happening anymore, it seems. But it appears that even in 4.6.1 it's already fixed. (nvm it actually still happens in 4.6.1)

No matter how many times I relaunch my mod and frozen time and fire the projectile that causes the issue, there are no freezes whatsoever with a fresh build. It's definitely fixed.

Re: A_RemoveLight causes severe lag on high detail maps

Wed Aug 11, 2021 11:57 pm

4.6.1 was before the fix. I only addressed a potential problem there yesterday.