Thalassicus / cep-bnw

Civ V Communitas Expansion Pack
32 stars 22 forks source link

Long delay at start of turn #252

Closed Thalassicus closed 10 years ago

Thalassicus commented 10 years ago

Identify and solve the cause of the 10-20 second freeze at the start of each turn, getting longer by late game.

Thalassicus commented 10 years ago

I think I managed to solve this.

The problem is Lua copies code to every file that uses it. As a result, every version of YieldLibrary runs duplicate copies of the "reset yield cache" functions. I introduced a small time window to prevent dozens of resets occurring all at once. This reduced the start-turn delays from 16.8 seconds to 3.1 seconds in my tests.