• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Huge lags in the beginning

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Probably caused by you creating units using triggers that were not previously present on the map. This is if you actually mean frame drop by the word "lag" and not network latency.

The game is forced to wait for I/O until data is loaded for a unit not previously present on the map but created using triggers. Since I/O is very slow (and it might need to read many files not near each other) this can exceeded the allocated time slot for a frame forcing the game to drop rendering a frame. For very bad I/O or when a lot of such objects are created instantaneously it is possible that the game has to drop so many frames that the process becomes "unresponsive" for an extended period.

The simplest solution is to place all units created using triggers on the map so that their data is forced to be loaded when the map is loading. Obviously this adds to map loading time but it subtracts the initial frame drop when the unit is first created. Only 1 of each unit type is needed and to conserve memory you can instantly remove them after the map starts. You can also use triggers firing at map initialization to create such units but that diverts the necessary time to some other stage of the loading process which may or may not be favourable.

You can also get frame drops occurring if you requiring running a lot of trigger script shortly after the map loads. Try and make as much of the trigger initialization process to be run during map initialization as that will happen during the loading process as opposed to in-game.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I/O stands for Input/Output. As computer backing storage works approximately 1000 times slower than memory, any form of interaction with the backing storage impacts performance badly. WC3 can literally site idle for many milliseconds as it waits for blocks to be read from backing storage, as there is only 16 and a bit miliseconds in a frame, this is a huge amount of time. WC3 is also not very efficient when loading data, using a lot of O(n) type looks to process object data.

It can also be caused by abilities. Especially if you add abilities to units that were not on any unit during map initialization, the game will be forced to load the ability data. If the ability has hundreds of levels, this can take a huge amount of time, during which WC3 will be unresponsive.
 
If it is at the very start of the game, you should look at the triggers that expire after "Time - elapsed 0.00 seconds (or any similar event)".

Otherwise, preloading abilities will help. Just add all your abilities to a unit on map initialization, and then remove the abilities and the unit. This will usually shift the loading-time to the map loading screen, which is usually more preferable than having a huge lag spike when the game starts/when the abilities are added to a unit.
 
Status
Not open for further replies.
Top