WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Local optimizations take forever to complete on 24-player maps with 2 forces

Open ElusiveMori opened this issue 6 years ago • 3 comments

Steps to reproduce:

  1. Make a 24-player map like this: 1

  2. Make 2 forces like this: 2

Saving this map in WorldEdit produces this monstrosity of a function: https://pastebin.com/JED2J7V3

If inlining is turned on, this gets turned into an even bigger monstrosity: https://pastebin.com/r3kURDAY

That is 4 thousand lines of JASS code.

If you now turn on local optimizations, it takes forever for them to actually run, compared to 2-4 seconds on normal 12-player maps (or a 24-player map with no forces). If you remove these 2 forces, everything goes back to normal.

I don't know how this bug should be addressed, but it can be a major pain for maps with 24 players where 2 or more forces are involved. I like compiling with all optimizations enabled because even on my big project (15k lines of optimized jass emitted) it doesn't take too long to finish, with 90% of stdlib imported. But this function, it just can't regurgitate.

One of the safer options would be to just disable optimizations on the config function directly, since it only runs once per map and hardly needs optimization at all. I don't think anyone would suffer from it.

ElusiveMori avatar Jul 31 '18 15:07 ElusiveMori

Saving this map in WorldEdit produces this monstrosity of a function:

What does it look like normally?

If you now turn on local optimizations, it takes forever for them to actually run, compared to 2-4 seconds on normal 12-player maps (or a 24-player map with no forces). If you remove these 2 forces, everything goes back to normal.

Just a big amount of lines shouldn't make local opts take exponentially longer - so probably another issue at hand here.

One of the safer options would be to just disable optimizations on the config function directly, since it only runs once per map and hardly needs optimization at all. I don't think anyone would suffer from it.

Seems kind of overkill - fixing this behavior should be sufficient.

Frotty avatar Jul 31 '18 16:07 Frotty

Idk, did you highly exaggerate here? Takes like 10-15 seconds instead of 5-10 for me. Really not critical.

e: @SamuelMoriarty The minimal "workaround" for this seems to simply not inline the SetPlayerAllianceStateAllyBJ BJ. Pushed a fix to keep these things in blizzard.j. Please verify.

Frotty avatar Aug 02 '18 06:08 Frotty

The problem is that TempMerger has a quadratic running time in the length of the function, since it always starts from beginning of the function after finding the first thing it can replace. Of course this is problematic for such a big function.

I created a branch with a change that should reduce the running time of the TempMerger, but I have to think about it a bit more. I am not sure if it is still correct this way ...

peq avatar Aug 08 '18 20:08 peq

has been fixed by #1024

Frotty avatar Jan 14 '24 21:01 Frotty